-
Notifications
You must be signed in to change notification settings - Fork 0
/
gentoo-autologin.sh
executable file
·50 lines (44 loc) · 1.22 KB
/
gentoo-autologin.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
#!/bin/bash
AUTOLOGIN_USERNAME="$1"
ATUOLOGIN_COMMAND="$2"
if [[ "$ATUOLOGIN_COMMAND x" == " x" ]]; then
>&2 echo 'No login command specified, please check your gentoo-autologin.sh arguments'
exit
fi
if [[ "$AUTOLOGIN_USERNAME x" == " x" ]]; then
>&2 echo 'No username specified, please check your gentoo-autologin.sh arguments'
fi
function enable_autologin () {
cat <<EOFDOC > /etc/init.d/agetty-autologin
getty_options="--autologin $AUTOLOGIN_USERNAME --noclear"
EOFDOC
sed -i -e 's/^root:\*/root:/' /etc/shadow
rc-config delete agetty
cp /etc/init.d/agetty /root/agetty.backup
rc-update add agetty-autologin default
#- MAKE THE KICKER EXECUTABLE -#
# This script will not be made executable until reboot time.
cat <<INNERSCRIPT > /etc/profile.d/gentoo-bootkicker.sh
#!/bin/bash
/root/gentoo-bootstrap.sh
reboot
INNERSCRIPT
chmod +x /etc/profile.d/gentoo-bootkicker.sh
}
function disable_autologin () {
rc-config delete agetty-autologin
rm -f /etc/init.d/agetty-autologin
mv /root/agetty.backup /etc/init.d/agetty
rc-update add agetty default
}
case "$ATUOLOGIN_COMMAND" in
*enable*)
enable_autologin
;;
*disable*)
disable_autologin
;;
*)
>&2 echo "Invalid autologin command (${ATUOLOGIN_COMMAND}) specified"
;;
esac