-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd_users.sh
More file actions
executable file
·51 lines (37 loc) · 886 Bytes
/
add_users.sh
File metadata and controls
executable file
·51 lines (37 loc) · 886 Bytes
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
#!/bin/bash
# Script to add sudo-privileged Users
# Users added with same username & password
# Tested on CentOS/RHEL/Fedora
#
# TODO, read users from file if input exists else use the list-var
# TODO, make it a little interactive if you like
# Users list
Users=("makis" "takis" "giorgos")
test1="makis"
test2="makis2"
test3=$test1' '$test2
#echo $test3
add_users(){
# Print each user in new line
echo "Print each user in new line"
for user in ${Users[*]}; do
echo "Adding user $user"
useradd -mp $(openssl passwd -6 $user) $user
done
}
add_users_group(){
# Add users to group wheel
echo "Adding users to sudo group"
for user in ${Users[*]}; do
echo "Adding $user to wheel group"
usermod -aG wheel $user
done
}
#add_users
#add_users_group
if [ -n "$1" ]; then
echo $1
else
echo $Users
fi
echo "Cheers!"