forked from peterkvt80/vbit2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getvbit2
150 lines (118 loc) · 3.44 KB
/
getvbit2
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/sh
# getteletext creates several script files required by VBIT.
# If you run this more than once you may lose pages or configuration.
# Instead use updatesystem to load the latest VBIT/raspi-teletext
cd ~
echo "Installing version control packages"
# install version control packages for VBIT
sudo apt-get update
sudo apt-get -y install git subversion
echo "Installing vbit2"
#install vbit2
git clone https://github.com/peterkvt80/vbit2.git ~/vbit2
cd ~/vbit2
make
echo "Installing raspi-teletext"
#install raspi-teletext
git clone https://github.com/ali1234/raspi-teletext/ ~/raspi-teletext-master/
cd ~/raspi-teletext-master/
make clean
make
echo "Installing teletext pages"
mkdir ~/Pages
mkdir ~/teletext
cd ~/Pages
rm -f pages.zip
wget -O pages.zip https://www.dropbox.com/sh/ue14zczs71zemuh/AAC_8OPbgZQCLb9HT4XwtEC7a?dl=1
unzip -o pages.zip
#teefax pages
svn checkout http://teastop.plus.com/svn/teletext/ ~/teletext
# install default config files
cp ~/vbit2/example-vbit.conf ~/Pages/vbit.conf
cp ~/vbit2/example-vbit.conf ~/teletext/vbit.conf
#TODO make the updater scripts
#cd ~/vbit
#chmod +x updatesystem
#chmod +x updatepages
# System sets SD video on bootup
sudo sed -i s/#sdtv_mode/sdtv_mode/ /boot/config.txt
echo "Installing scripts"
#install scripts
cd ~
cat > ~/vb2 << EOF
#!/bin/bash
# "vb2" Autogenerated by getvbit2
# This runs the VBIT2 teletext system
# to change the install directory of vbit2 and raspi-teletext, edit the line below
export HOME=/home/pi
# to change the directory in which vbit2 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 "vb2"\`
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 vbit2 or raspi.
until \$HOME/vbit2/vbit2 2> /dev/null --dir \$PAGESDIRECTORY | \$HOME/raspi-teletext-master/teletext -; do
trap 'exit' INT HUP TERM
echo "VBIT2 Server crashed with exit code 0. Respawning.." >&2
sleep 1
done
EOF
chmod +x vb2
cat > ~/vbit2.sh << EOF
#!/bin/sh
# /etc/init.d/vbit2.sh
# "vbit2.sh" Autogenerated by getvbit2
# Startup script to go in /etc/init.d
# Some things that run always
#
# Carry out specific functions when asked to by the system
case "\$1" in
start)
cd /home/pi
./vb2 &
echo "Starting script vbit2.sh"
echo "Could do more here"
;;
stop)
if [ -f /var/tmp/vbit2-go.pid ]; then
PID=\`cat /var/tmp/vbit2-go.pid\`
RESULT=\`ps -ef | grep \$PID | grep "vb2"\`
if [ "\${RESULT}" ]; then
kill \$PID
fi
fi
echo "Stopping script vbit2"
echo "Could do more here"
;;
*)
echo "Usage: /etc/init.d/vbit2.sh {start|stop}"
exit 1
;;
esac
exit 0
EOF
chmod +x vbit2.sh
cat > ~/updatePages.sh << EOF
#!/bin/sh
# "updatePages.sh" Autogenerated by getvbit2
# Script to fetch text pages
# As this is run by root, you will need to change /home/pi below to your own home directory.
# I expect there is a system export that could take care of this problem automatically
svn update /home/pi/teletext
EOF
chmod +x updatePages.sh