forked from davecrump/portsdown4
-
Notifications
You must be signed in to change notification settings - Fork 6
/
update_ryde.sh
executable file
·234 lines (183 loc) · 6.79 KB
/
update_ryde.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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/bin/bash
# Updates an existing Ryde installation on Portsdown
echo
echo "----------------------------------------"
echo "----- Updating Ryde Receiver System-----"
echo "----------------------------------------"
echo
# Stop the receiver to allow the update
sudo killall python3 >/dev/null 2>/dev/null
sleep 0.3
if pgrep -x "python3" >/dev/null
then
sudo killall -9 python3 >/dev/null 2>/dev/null
fi
## Check which update to load
GIT_SRC_FILE=".ryde_gitsrc"
if [ -e ${GIT_SRC_FILE} ]; then
GIT_SRC=$(</home/pi/${GIT_SRC_FILE})
else
GIT_SRC="BritishAmateurTelevisionClub"
fi
## If previous version was Dev (davecrump), load production by default
if [ "$GIT_SRC" == "davecrump" ]; then
GIT_SRC="BritishAmateurTelevisionClub"
fi
if [ "$1" == "-d" ]; then
echo "Overriding to update to latest development version"
GIT_SRC="davecrump"
fi
if [ "$GIT_SRC" == "BritishAmateurTelevisionClub" ]; then
echo "Updating to the latest Production Ryde build";
elif [ "$GIT_SRC" == "davecrump" ]; then
echo "Updating to the latest development Ryde build";
else
echo "Updating to the latest ${GIT_SRC} development Ryde build";
fi
echo
echo "-----------------------------------------"
echo "----- Noting Previous Configuration -----"
echo "-----------------------------------------"
echo
cd /home/pi
PATHUBACKUP="/home/pi/user_backups"
mkdir "$PATHUBACKUP" >/dev/null 2>/dev/null
# Note previous version number
cp -f -r /home/pi/ryde-build/installed_version.txt "$PATHUBACKUP"/prev_installed_version.txt
# Make a safe copy of the Config file in "$PATHUBACKUP" to restore at the end
cp -f -r /home/pi/ryde/config.yaml "$PATHUBACKUP"/config.yaml >/dev/null 2>/dev/null
# Capture the RC protocol in the rx.sh file:
cp -f -r /home/pi/ryde-build/rx.sh "$PATHUBACKUP"/rx.sh
# And the dvb-t config
cp -f -r /home/pi/dvbt/dvb-t_config.txt "$PATHUBACKUP"/dvb-t_config.txt >/dev/null 2>/dev/null
# Check the user's audio output to re-apply it after the update. HDMI is default.
AUDIO_JACK=HDMI
grep -q "^ vlcArgs += '--gain 4 --alsa-audio-device hw:CARD=Headphones,DEV=0 '" \
/home/pi/ryde/rydeplayer/player.py
if [ $? -eq 0 ]; then # RPi Jack currently selected
AUDIO_JACK="RPi Jack"
else
grep -q "^ vlcArgs += '--gain 4 --alsa-audio-device hw:CARD=Device,DEV=0 '" \
/home/pi/ryde/rydeplayer/player.py
if [ $? -eq 0 ]; then # USB Dongle currently selected
AUDIO_JACK=USB
fi
fi
echo
echo "-------------------------------------------------"
echo "----- Updating the System Software Packages -----"
echo "-------------------------------------------------"
echo
sudo dpkg --configure -a # Make sure that all the packages are properly configured
sudo apt-get clean # Clean up the old archived packages
sudo apt-get update --allow-releaseinfo-change # Update the package list
sudo apt-get -y dist-upgrade # Upgrade all the installed packages to their latest version
echo
echo "Checking for EEPROM Update"
echo
sudo rpi-eeprom-update -a # Update will be installed on reboot if required
# --------- Overwrite and compile all the software components -----
# Download the previously selected version of Ryde Build
echo
echo "----------------------------------------"
echo "----- Updating Ryde Build Utilities-----"
echo "----------------------------------------"
echo
rm -rf /home/pi/ryde-build
wget https://github.com/${GIT_SRC}/ryde-build/archive/master.zip
unzip -o master.zip
mv ryde-build-master ryde-build
rm master.zip
cd /home/pi
# Build the LongMynd version packaged with ryde-build
#echo
#echo "------------------------------------------"
#echo "----- Updating the LongMynd Receiver -----"
#echo "------------------------------------------"
#echo
#rm -rf /home/pi/longmynd
#cp -r ryde-build/longmynd/ longmynd/
#cd longmynd
#make
# Download and compile pyDispmanx
echo
echo "--------------------------------"
echo "----- Updating pyDispmanx -----"
echo "--------------------------------"
echo
wget https://github.com/eclispe/pyDispmanx/archive/master.zip
unzip -o master.zip
rm -rf pydispmanx
mv pyDispmanx-master pydispmanx
rm master.zip
cd pydispmanx
python3 setup.py build_ext --inplace
cd /home/pi
# Download the previously selected version of Ryde Player
echo
echo "--------------------------------"
echo "----- Updating Ryde Player -----"
echo "--------------------------------"
echo
rm -rf /home/pi/ryde
wget https://github.com/${GIT_SRC}/rydeplayer/archive/master.zip
unzip -o master.zip
mv rydeplayer-master ryde
rm master.zip
cd /home/pi/ryde
cp /home/pi/pydispmanx/pydispmanx.cpython-37m-arm-linux-gnueabihf.so pydispmanx.cpython-37m-arm-linux-gnueabihf.so
cd /home/pi
# Download and overwrite the latest remote control definitions and images
echo
echo "----------------------------------------------"
echo "----- Downloading Remote Control Configs -----"
echo "----------------------------------------------"
echo
rm -rf /home/pi/RydeHandsets/definitions
rm -rf /home/pi/RydeHandsets/images
git clone -b definitions https://github.com/${GIT_SRC}/RydeHandsets.git RydeHandsets/definitions
git clone -b images https://github.com/${GIT_SRC}/RydeHandsets.git RydeHandsets/images
cd /home/pi
echo
echo "-----------------------------------"
echo "----- Updating the Ryde Utils -----"
echo "-----------------------------------"
echo
wget https://github.com/eclispe/ryde-utils/archive/master.zip
unzip -o master.zip
rm -rf ryde-utils
mv ryde-utils-master ryde-utils
rm master.zip
echo
echo "---------------------------------------------"
echo "----- Restoring the User's Config Files -----"
echo "---------------------------------------------"
grep -q "CombiTunerExpress" "$PATHUBACKUP"/config.yaml
if [ $? == 0 ]; then # User's config file is latest version, so simply copy back
cp -f -r "$PATHUBACKUP"/config.yaml /home/pi/ryde/config.yaml >/dev/null 2>/dev/null
# Restore the user's original audio output (Default is HDMI)
case "$AUDIO_JACK" in
"RPi Jack")
sed -i "/--alsa-audio-device/c\ vlcArgs += '--gain 4 --alsa-audio-device hw:CARD=Headphones,DEV=0 '" \
/home/pi/ryde/rydeplayer/player.py
;;
"USB")
sed -i "/--alsa-audio-device/c\ vlcArgs += '--gain 4 --alsa-audio-device hw:CARD=Device,DEV=0 '" \
/home/pi/ryde/rydeplayer/player.py
;;
esac
# Add new alias if needed for the update
if ! grep -q "alias dryde" /home/pi/.bash_aliases; then
echo "alias dryde='/home/pi/ryde-build/debug_rx.sh'" >> /home/pi/.bash_aliases
fi
# Record the version numbers
cp /home/pi/ryde-build/latest_version.txt /home/pi/ryde-build/installed_version.txt
cp -f -r "$PATHUBACKUP"/prev_installed_version.txt /home/pi/ryde-build/prev_installed_version.txt
rm -rf "$PATHUBACKUP"
echo
echo "-------------------------------"
echo "----- Rebooting Portsdown -----"
echo "-------------------------------"
echo
sudo shutdown -r now
exit