-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path7-run-with-getty.sh
executable file
·89 lines (69 loc) · 2.34 KB
/
7-run-with-getty.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
echo "--- getty setup script started ---"
# Note: systemd seems to care a lot about names, paths, links, etc.
# Run script on alternate tty and switch to that tty on boot via rc.local (assumes no X session running)
# TODO:
PROGRAM_PATH=/usr/local/opt/back-end
mkdir -p $PROGRAM_PATH
PROGRAM=$PROGRAM_PATH/run.sh
if [ ! -f $PROGRAM ]; then
cat <<- EOF > $PROGRAM
#!/bin/bash
echo "TODO: Put something here to run"
sleep 15m
EOF
chmod +x $PROGRAM
fi
cat <<- EOF > /lib/systemd/system/[email protected]
# Custom service to launch our program
[Unit]
Description=Ember RPi demo back-end (WebSocket server)
After=systemd-user-sessions.service plymouth-quit-wait.service
After=rc-local.service
# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes
# On systems without virtual consoles, don't start any getty. Note
# that serial gettys are covered by [email protected], not this
# unit.
ConditionPathExists=/dev/tty0
[Service]
# the VT is cleared by TTYVTDisallocate
ExecStart=-/sbin/agetty --autologin root --login-program $PROGRAM --login-options "" --noclear %I $TERM
Type=idle
Restart=always
RestartSec=1
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
KillMode=process
IgnoreSIGPIPE=no
SendSIGHUP=yes
# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=
[Install]
WantedBy=getty.target
DefaultInstance=tty2
EOF
ln -s /lib/systemd/system/[email protected] /etc/systemd/system/getty.target.wants/[email protected]
cp --backup=numbered /etc/rc.local /etc/rc.local.original 2> /dev/null
cat <<- EOF > /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution bits.
# Switch to virtual terminal 2 (where our script should be running on start-up)
chvt 2
EOF
chmod +x /etc/rc.local
echo "--- getty setup script finished ---"