-
Notifications
You must be signed in to change notification settings - Fork 9
/
02-users.sh
executable file
·37 lines (32 loc) · 1.06 KB
/
02-users.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
#!/bin/bash
# Add lecturers group
addgroup lecturers
# Add lecturer users
while IFS=, read NAME PW; do
echo "Creating lecturer $NAME"
if [ -z $PW ]; then
useradd -s "/bin/bash" -m -N -g users -G sudo,adm,lecturers $NAME
else
useradd -s "/bin/bash" -m -N -g users -G sudo,adm,lecturers -p "$PW" $NAME
fi
done < <(egrep -v '^#' lecturers.list)
# Add some admin users, add them to SSHD allowed list
ADMINS=`tr "\n" " " < admins.list`
echo "Administrators with SSH access: $ADMINS"
echo "AllowUsers $ADMINS" >> /etc/ssh/sshd_config
systemctl reload ssh.service
# Add regular users
while IFS=, read NAME PW; do
echo "Creating student $NAME"
if [ -z $PW ]; then
useradd -s "/bin/bash" -m -N -g users $NAME
else
useradd -s "/bin/bash" -m -N -g users -p "$PW" $NAME
fi
done < <(egrep -v '^#' students.list)
# Create fontconfig-cache so that the first execution of cells
# don't take time with some ugly warning messages.
echo "Creating fontconfig cache in HOME folders..."
for u in $(ls /home/); do
sudo -H -u $u fc-cache
done