-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSSUM
92 lines (64 loc) · 1.46 KB
/
SSUM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
#######################
# SSUM main script #
#######################
### set environment vars
prompt_start='> '
prompt_end=' : '
SSUM_install_dir="/var/SSUM"
### functions
source "$SSUM_install_dir/functions.sh"
### prevent exit
prevent_exit
if ( ! is_file "$SSUM_install_dir/.config" ) then
error "Invalid installation"
fi
### mount disk
/sbin/mount -uw / >/dev/null 2>&1
### read config
source "$SSUM_install_dir/.config"
### clear
clear
### are we in single user mode or not?
single_user_mode=`sysctl -n kern.singleuser`
if [ "$single_user_mode" == "0" ] && [ "$mode" == "SUM" ]; then
exit
fi
info "Secured Single User Mode (SSUM)"
### ask for password
input_password=""
while true; do
if ( is_empty "$input_password" ) then
prompt "Please enter password to continue" 1
input_password="$data"
if ( is_empty "$input_password" ) then
error "Password is empty" 0
fi
elif [ "$input_password" != "$password" ]; then
input_password=""
### update counter
((amount_of_tries--))
tmp="tries"
if [ "$amount_of_tries" == 1 ]; then
tmp="try"
fi
info "$amount_of_tries $tmp left"
if [ "$amount_of_tries" == 0 ]; then
case "$action" in
### shutdown
'shutdown')
shutdown -h now >/dev/null 2>&1
;;
### reboot
'reboot')
reboot
;;
esac
fi
error "Incorrect password" 0
else
break
fi
done
success "Welcome" # , type 'change' to make changes or 'exit' to continue
exit