forked from alanbjohnston/CubeSatSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update
executable file
·159 lines (102 loc) · 3.8 KB
/
update
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
#!/bin/bash
echo -e "\nupdate script for CubeSatSim v1.2\n"
sudo rm /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/id.txt /home/pi/CubeSatSim/cw.txt > /dev/null 2>&1
if [ "$1" = "u" ]; then
sudo apt-get update && sudo apt-get dist-upgrade -y
sudo apt-get install -y wiringpi git libasound2-dev i2c-tools build-essential libgd-dev libmagic-dev python3-pip minicom
fi
sudo apt-get install -y python3-smbus
sudo sed -i 's/update.sh/update /g' /etc/motd
sudo sed -i 's/installed and/installed\nand/g' /etc/motd
sudo sed -i 's/more information/more\ninformation/g' /etc/motd
sudo sed -i 's/update to/update\nto/g' /etc/motd
cd /home/pi/CubeSatSim
git pull > .updated
make debug
FLAG=0
if [[ $(diff systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service) ]]; then
echo "changed cubesatsim.service."
sudo cp /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service
FLAG=1
else
echo "no changes to cubesatsim.service."
fi
if [[ $(diff systemd/rpitx.service /etc/systemd/system/rpitx.service) ]]; then
echo "changed rpitx.service."
sudo cp /home/pi/CubeSatSim/systemd/rpitx.service /etc/systemd/system/rpitx.service
FLAG=1
else
echo "no changes to rpitx.service."
fi
FILE=/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg
if [ ! -f "$FILE" ]; then
echo "Copying SSTV image 1."
cp /home/pi/CubeSatSim/sstv/sstv_image_1_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg
fi
FILE=/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg
if [ ! -f "$FILE" ]; then
echo "Copying SSTV image 2."
cp /home/pi/CubeSatSim/sstv/sstv_image_2_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg
fi
grep 'update' /home/pi/CubeSatSim/.updated
if [[ $(grep 'update' /home/pi/CubeSatSim/.updated) ]]; then
echo "update script updated, running again"
/home/pi/CubeSatSim/update
fi
if [ $FLAG -eq 1 ]; then
echo "systemctl daemon-reload and restart"
sudo systemctl daemon-reload
sudo systemctl restart cubesatsim
else
grep 'changed' /home/pi/CubeSatSim/.updated
if [[ $(grep 'changed' /home/pi/CubeSatSim/.updated) ]]; then
echo "systemctl restart cubesatsim"
sudo systemctl restart cubesatsim
else
echo "nothing to do."
fi
fi
if [ ! -d "/home/pi/PiSSTVpp" ]; then
sudo apt-get update && sudo apt-get dist-upgrade -y
sudo apt-get install -y python-picamera python3-picamera build-essential libgd-dev libmagic-dev
cd
git clone https://github.com/alanbjohnston/PiSSTVpp.git
cd PiSSTVpp
make pisstvpp
cd
sudo raspi-config nonint do_camera 0
FILE=/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg
if [ ! -f "$FILE" ]; then
echo "Copying SSTV image 1."
cp /home/pi/CubeSatSim/sstv/sstv_image_1_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg
fi
FILE=/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg
if [ ! -f "$FILE" ]; then
echo "Copying SSTV image 2."
cp /home/pi/CubeSatSim/sstv/sstv_image_2_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg
fi
# echo "You need to reboot to complete this update. Reboot now (y/n)?"
# read -r ANS
# if [ "$ANS" = "y" ]; then
# sudo reboot now
# else
# echo "The CubeSatSim software may not work correctly until you reboot."
# fi
fi
cd /home/pi/pi-power-button
git pull > .updated_p
grep 'changed' /home/pi/pi-power-button/.updated_p
if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then
echo "updating pi-power-button."
script/install
echo "You need to reboot to complete this update. Reboot now (y/n)?"
read -r ANS
if [ "$ANS" = "y" ]; then
sudo reboot now
else
echo "The CubeSatSim software may not work correctly until you reboot."
fi
else
echo "nothing to do for pi-power-button."
fi
echo "CubeSatSim update complete."