/
010-tty
executable file
·56 lines (47 loc) · 1.51 KB
/
010-tty
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
#!/bin/bash
# Replace the screen with our bootscreen which shows some basic info to the user (like how to connect)
apt install -y dialog
# Disable TTY1
if [[ -d /etc/systemd/system/getty@tty1.service.d ]]; then
rm -rf /etc/systemd/system/getty@tty1.service.d
fi
systemctl disable getty@tty1.service
systemctl stop getty@tty1.service
# Use TTY7
if [[ ! -d /etc/systemd/system/getty@tty7.service.d ]]; then
mkdir /etc/systemd/system/getty@tty7.service.d
fi
systemctl disable getty@tty7.service
systemctl stop getty@tty7.service
echo "
[Service]
ExecStart=
ExecStart=-/usr/local/share/nems/nems-scripts/bootscreen.sh
StandardInput=tty
StandardOutput=tty
" > /etc/systemd/system/getty@tty7.service.d/override.conf
systemctl daemon-reload
systemctl enable getty@tty7.service
systemctl start getty@tty7.service
chvt 7
if [[ ! -f /etc/rc.local ]]; then
echo "#!/bin/sh -e
" > /etc/rc.local
chmod +x /etc/rc.local
fi
if grep -q '"exit 0"' /etc/rc.local; then
sed -i~ '/"exit 0"/d' /etc/rc.local
fi
if ! grep -q "NEMS00001" /etc/rc.local; then
addition="# NEMS00001 Use TTY7\nchvt 7\n\n"
if grep -q "exit" /etc/rc.local; then
# This file contains an exit command, so make sure our new command comes before it
/bin/sed -i -- 's,exit,'"$addition"'exit,g' /etc/rc.local
else
# No exit command within the file, so just add it
echo "PLACEHERE" >> /etc/rc.local
/bin/sed -i -- 's,PLACEHERE,'"$addition"'exit 0,g' /etc/rc.local
fi
/bin/systemctl stop rc-local.service
/bin/systemctl start rc-local.service
fi