Repository navigation
Expand file tree
/
Copy pathcore.sh
More file actions
79 lines (71 loc) · 1.98 KB
/
Copy pathcore.sh
File metadata and controls
79 lines (71 loc) · 1.98 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
#!/bin/bash
# Bash sources
source ./user-creation.sh
source ./user-admin.sh
source ./user-deletion.sh
if [ $(id -u) -ne 0 ]; then
echo "Script failed. Super user required."
exit -1
fi
echo "1. Create User"
echo "2. Delete User"
echo "3. Administrate Users"
echo " - List Users"
echo " - Change User Password"
echo " - Backup User Home Dir"
echo "X. Exit"
read -p "Select an option: " option
# 0. Select functions
case $option in
1 | 1. | create | create\ user)
echo "Create User"
creation_prompt
create_user
echo "User sucessfully created. Exiting."
echo
exit 0
;;
2 | 2. | delete | delete\ user)
echo "You chose to delete a user."
delete_user
;;
3 | 3. | admin | admin\ user | administrate | administrate\ user)
echo "You chose to administrate users."
echo
echo "a. List Users"
echo "b. Change Password"
echo "c. Change Permissions"
read -p "Please choose suboption: " suboption
# call case switch for user admin
case "$suboption" in
a | a. | list | list\ users)
echo "Listing all (human) users:"
list_users
;;
b | b. | password | change\ password)
change_password
;;
c | c. | backup | backup\ user | perms)
# select user, then call backup
read -p "Select user to backup: " user
backup_user_home "$user"
;;
*)
echo "Invalid sub-option."
exit 1
;;
esac
;;
x | x.| exit)
echo "You chose to exit."
echo
echo "Closing process."
exit 0
;;
*)
echo "Invalid input. Exiting."
exit -1
;;
esac
# Once module exits, do clean up and exit
## Maybe provide another option to re-run module or select another one