-
Notifications
You must be signed in to change notification settings - Fork 5
/
contest-config
executable file
·56 lines (44 loc) · 1.83 KB
/
contest-config
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
#!/bin/bash
set -e
IFS= read -r -s -p "Enter lioadmin password for GRUB: " ADMIN_PASS
# printf "'%s'\n" "${ADMIN_PASS}"
echo
IFS= read -r -s -p "Repeat: " ADMIN_PASS_REPEAT
# printf "'%s'\n" "${ADMIN_PASS_REPEAT}"
echo
if [ "${ADMIN_PASS}" != "${ADMIN_PASS_REPEAT}" ]; then
echo "ERROR: Passwords don't match."
exit 1
fi
GRUB_PWD_HASH=$(printf "%s\n%s" "${ADMIN_PASS}" "${ADMIN_PASS}" | grub-mkpasswd-pbkdf2 | awk '/grub.pbkdf/{print$NF}')
mkdir -p config/includes.chroot/boot/grub
cat > config/includes.chroot/boot/grub/custom.cfg <<EOF
set superusers="lioadmin"
password_pbkdf2 lioadmin ${GRUB_PWD_HASH}
EOF
PRESEED=config/includes.binary/preseed/auto.cfg
cat >> ${PRESEED} <<EOF
d-i preseed/late_command string in-target /usr/share/liox-config/d-i_hooks
EOF
echo -n "Enter lioadmin user "
ADM_PWD_HASH=$(mkpasswd -m sha-512 | sed -e 's/\//\\\//g')
sed -i -e '/^d-i passwd\/username/ s/user$/lioadmin/' ${PRESEED}
sed -i -e '/^d-i passwd\/user-password/ s/^d-i/#d-i/' ${PRESEED}
sed -i -e "/^#d-i passwd\\/user-password-crypted/ { s/^#d-i/d-i/; s/\\[.*$/${ADM_PWD_HASH}/ }" ${PRESEED}
echo -n "Enter d0 user "
D0_PWD_HASH=$(mkpasswd -m sha-512)
echo -n "Enter d1 user "
D1_PWD_HASH=$(mkpasswd -m sha-512)
echo -n "Enter d2 user "
D2_PWD_HASH=$(mkpasswd -m sha-512)
printf "%s" "${D0_PWD_HASH}" > config/includes.chroot/usr/share/liox-config/d0-shadow
printf "%s" "${D1_PWD_HASH}" > config/includes.chroot/usr/share/liox-config/d1-shadow
printf "%s" "${D2_PWD_HASH}" > config/includes.chroot/usr/share/liox-config/d2-shadow
read -p "Path to olimp-control keyfile: " OLIMP_CONTROL_KEY
if [ ! -f ${OLIMP_CONTROL_KEY} ]; then
echo "ERROR: path not found / not a file."
exit 1
fi
mkdir -p config/includes.chroot/etc/olimp-control
cp ${OLIMP_CONTROL_KEY} config/includes.chroot/etc/olimp-control/key
chmod 400 config/includes.chroot/etc/olimp-control/key