-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathusermanag.sh
More file actions
126 lines (99 loc) · 2.66 KB
/
usermanag.sh
File metadata and controls
126 lines (99 loc) · 2.66 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
#1 chech if the script is run as root
if [[ $UID -ne 0 ]];
then
echo "This command must be run as root"
exit 1
fi
#2 chich if the functions script is exist
FUNCSCRIPT="manage_functions.sh"
if [[ ! -f $FUNCSCRIPT ]];
then
echo "cant find the main file"
exit 1
fi
#3 load the functions
source $FUNCSCRIPT
#4 Start the display options
PS3=$'\nSelect an option: '
options=(
"Show System Information"
"List Users with /bin/bash Shell"
"Search for a User"
"Add User"
"Delete User (with Home Backup)"
"Show User Details"
"Change User Password"
"Lock User"
"Unlock User"
"Exit"
)
clear
echo "=============================================="
echo "|| Linux Users Manager ||"
echo "=============================================="
echo "|| ||"
echo "|| System: $(uname -s) "
echo "|| Hostname: $(hostname) "
echo "|| Date: $(date '+%Y-%m-%d %H:%M:%S') "
echo "|| ||"
echo "=============================================="
echo "Please select an operation from the menu below:"
echo "=============================================="
while true;
do
select option in "${options[@]}";
do
if [[ $REPLY -ne 10 ]]; then
clear
fi
echo "You selected option $REPLY: $option"
echo "============================================"
case $REPLY in
1)
show_system_info
break
;;
2)
list_bash_users
break
;;
3)
search_user
break
;;
4)
add_user
break
;;
5)
delete_user
break
;;
6)
show_user_details
break
;;
7)
change_user_password
break
;;
8)
lock_user
break
;;
9)
unlock_user
break
;;
10)
exit_program
;;
*)
echo "'${REPLY}' is Invalid input! Please choose a number between 1 and 10."
break
;;
esac
done
echo '============================================'
done