-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpers-laptp-setup.sh
More file actions
executable file
·45 lines (35 loc) · 1.16 KB
/
pers-laptp-setup.sh
File metadata and controls
executable file
·45 lines (35 loc) · 1.16 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
#!/bin/bash
### prepare server-side
# Have a file with the keys
# assign server accounts to the keys
# provide means to make more server accounts
# copy keys to .ssh/authorized_keys
### prepare client side
# make available skrip on website
# script contains instructor-home, key - server account-mapping, startup-template.txt
# script (on laptop) finds server username (base on key), and makes startup.sh
instructor=$(head -n1 clients.txt)
instructor=${instructor%%@*}
insthome=$(cat /etc/passwd |grep $instructor |cut -d: -f6)
no_keys=$(cat laptop-keys.txt |wc -l)
no_serv_accs=$(grep "personal_laptop" clients.txt |wc -l)
if [ "$no_keys" -gt "$no_serv_accs" ]; then
echo -e "More laptop-users' keys then server-accounts\nFix manually, add accounts in clients.txt"
exit 1
fi
count=0
while read key; do
keys[$count]="$key"
count=$((count + 1))
done <<< "$(cat laptop-keys.txt)"
clients=$(cat clients.txt |grep personal_laptop |cut -d" " -f3)
count=0
while read ac; do
acc[$count]="\"${ac%%@*}\""
count=$((count + 1))
done <<<"$clients"
count=0
for key in "${keys[@]}"; do
line[$count]="\"${acc[$count]}\" \"$key\""
count=$((count + 1))
done