forked from peterkvt80/vbit2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
go.sh
executable file
·41 lines (31 loc) · 1.05 KB
/
go.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
#!/bin/bash
# "go" (to be) Autogenerated by getteletext
# This runs the VBIT2 teletext system
# to change the directory where vbit and raspi-teletext, edit the line below
export HOME=/home/pi
# to change the directory in which vbit looks for pages edit the line below
PAGESDIRECTORY=$HOME/teletext
PID=$$
function exitgo {
kill `ps -o pid --no-headers --ppid $PID` >/dev/null 2>&1
rm /var/tmp/vbit2-go.pid
}
# create a pid file
if [ -f /var/tmp/vbit2-go.pid ]; then
OLDPID=`cat /var/tmp/vbit2-go.pid`
RESULT=`ps -ef | grep $OLDPID | grep "go"`
if [ -n "${RESULT}" ]; then
echo "Script already running"
exit 255
fi
fi
echo $PID > /var/tmp/vbit2-go.pid
trap exitgo EXIT
sudo ~/raspi-teletext-master/tvctl on
# This loop restarts the teletext server if it stops.
# To stop teletext you should kill this process and not vbit or raspi.
until $HOME/vbit2/vbit2 --dir $PAGESDIRECTORY 2> /dev/null | $HOME/raspi-teletext-master/teletext -; do
trap 'exit' INT HUP TERM
echo "VBIT2 Server crashed with exit code 0. Respawning.." >&2
sleep 1
done