This repository has been archived by the owner on Feb 10, 2024. It is now read-only.
/
init.sh
executable file
·98 lines (82 loc) · 1.9 KB
/
init.sh
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
#!/bin/bash
# Manage: Add User
# Manage Common Functions
module-manage-common
# Attended Mode
if [ $UNATTENDED = 0 ]; then
# User Check Loop
while true; do
# Take User Input
read -p "Please enter a user name: " USER
# Add User
subheader "Adding User..."
useradd -m -s /bin/bash $USER
# Check If Addition Successful
if [ -d /home/$USER ]; then
break
else
echo "User addition failed, please try again."
fi
done
# Set Password
subheader "Setting Password..."
passwd $USER
# Clean Cron Entry
clean-cron
# Check Package
if check_package "nginx"; then
# User HTTP Folder Question
if question --default yes "Do you want to add a HTTP folder for this user? (Y/n)"; then
manage-folder
fi
fi
# Reset User Permissions Question
if question --default yes "Do you want to change file permissions for this user to enable privacy? (Y/n)"; then
manage-reset-permissions
fi
# Unattended Mode
else
# Define Arrays
USERLIST=$(read_var_module user),
PASSLIST=$(read_var_module pass),
HTTPLIST=$(read_var_module http),
PERMLIST=$(read_var_module perm),
# Loop Through Users
while echo $USERLIST | grep -q \,; do
# Define Current
USER=${USERLIST%%\,*}
PASS=${PASSLIST%%\,*}
HTTP=${HTTPLIST%%\,*}
PERM=${PERMLIST%%\,*}
# Remove Current User From List
USERLIST=${USERLIST#*\,}
PASSLIST=${PASSLIST#*\,}
HTTPLIST=${HTTPLIST#*\,}
PERMLIST=${PERMLIST#*\,}
# Check If Array Empty
manage-check-array
# Add User
subheader "Adding User ($USER)..."
useradd -m -s /bin/bash $USER
# Check User
manage-check-user
# Set Password
subheader "Setting Password..."
echo "$USER:$PASS" | chpasswd
# Clean Cron Entry
clean-cron
# User HTTP Folder
if [ $HTTP = 1 ]; then
manage-folder
fi
# Reset User Permissions
if [ $PERM = 1 ]; then
manage-reset-permissions
fi
done
# Unset Arrays
unset USERLIST
unset PASSLIST
unset HTTPLIST
unset PERMLIST
fi