-
Notifications
You must be signed in to change notification settings - Fork 102
/
pi-timolo-install.sh
executable file
·342 lines (299 loc) · 12.9 KB
/
pi-timolo-install.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
#!/bin/bash
# Convenient pi-timolo-install.sh script written by Claude Pageau 1-Jul-2016
ver="12.05"
progName=$(basename -- "$0")
TIMOLO_DIR='pi-timolo' # Default folder install location
# Make sure ver below matches latest rclone ver on https://downloads.rclone.org/rclone-current-linux-arm.zip
rclone_cur_ver="rclone v1.65.0"
cd ~
is_upgrade=false
if [ -d "$TIMOLO_DIR" ] ; then
STATUS="Upgrade"
echo "INFO : Upgrade pi-timolo files"
is_upgrade=true
else
echo "INFO : New pi-timolo Install"
STATUS="New Install"
mkdir -p $TIMOLO_DIR
mkdir -p $TIMOLO_DIR/media
echo "INFO : $TIMOLO_DIR Folder Created"
fi
cd $TIMOLO_DIR
INSTALL_PATH=$( pwd )
# Remember where this script was launched from
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "
-------------------------------------------------------------
INFO : $progName $ver written by Claude Pageau
$STATUS from https://github.com/pageauc/pi-timolo
-------------------------------------------------------------
"
# check if this is an upgrade and bypass update of configuration files
if $is_upgrade ; then
timoloFiles=("menubox.sh" "pi-timolo.py" "pi-timolo.sh" "image-stitching" "config.cfg" \
"webserver.py" "webserver2.py" "webserver3.py" "webserver.sh" "pantilthat.py" \
"convid.sh" "makevideo.sh" "mvleavelast.sh" "remote-run.sh" "install-py3exiv2.sh")
if [ ! -f config.cfg ]; then
mv plugins plugins.bak
mkdir -p data
mv *dat data
fi
else # New Install
timoloFiles=("config.py" "menubox.sh" "pi-timolo.py" "pi-timolo.sh" "image-stitching" "config.cfg" \
"webserver.py" "webserver2.py" "webserver3.py" "webserver.sh" "watch-app.sh" "shutdown.py" "pantilthat.py" \
"convid.sh" "makevideo.sh" "video.conf" "mvleavelast.sh" "remote-run.sh" "install-py3exiv2.sh")
fi
for fname in "${timoloFiles[@]}" ; do
wget_output=$(wget -O $fname -q --show-progress https://raw.github.com/pageauc/pi-timolo/master/source/$fname)
if [ $? -ne 0 ]; then
wget_output=$(wget -O $fname -q https://raw.github.com/pageauc/pi-timolo/master/source/$fname)
if [ $? -ne 0 ]; then
echo "ERROR : $fname wget Download Failed. Possible Cause Internet Problem."
else
wget -O $fname https://raw.github.com/pageauc/pi-timolo/master/source/$fname
fi
fi
done
wget -O config.py.new -q --show-progress https://raw.github.com/pageauc/pi-timolo/master/source/config.py
if [ $? -ne 0 ] ; then
wget -O config.py.new https://raw.github.com/pageauc/pi-timolo/master/source/config.py
wget -O watch-app-new.sh https://raw.github.com/pageauc/pi-timolo/master/source/watch-app.sh
wget -O video.conf.new https://raw.github.com/pageauc/pi-timolo/master/source/video.conf
wget -O Readme.md https://raw.github.com/pageauc/pi-timolo/master/Readme.md
wget -O media/webserver.txt https://raw.github.com/pageauc/pi-timolo/master/source/webserver.txt
wget -O rclone-test.sh https://raw.github.com/pageauc/pi-timolo/master/source/rclone-samples/rclone-master.sh
else
wget -O watch-app-new.sh -q --show-progress https://raw.github.com/pageauc/pi-timolo/master/source/watch-app.sh
wget -O video.conf.new -q --show-progress https://raw.github.com/pageauc/pi-timolo/master/source/video.conf
wget -O Readme.md -q --show-progress https://raw.github.com/pageauc/pi-timolo/master/Readme.md
wget -O media/webserver.txt -q --show-progress https://raw.github.com/pageauc/pi-timolo/master/source/webserver.txt
wget -O rclone-test.sh -q --show-progress https://raw.github.com/pageauc/pi-timolo/master/source/rclone-samples/rclone-master.sh
fi
# create python library module folders for python2 and python3
echo "Setup Waveshare pantilt python library files"
sudo mkdir -p /usr/local/lib/python2.7/dist-packages/waveshare
sudo cp pantilthat.py /usr/local/lib/python2.7/dist-packages/waveshare
sudo touch /usr/local/lib/python2.7/dist-packages/waveshare/__init__.py
sudo mkdir -p /usr/local/lib/python3.7/dist-packages/waveshare
sudo cp pantilthat.py /usr/local/lib/python3.7/dist-packages/waveshare
sudo touch /usr/local/lib/python3.7/dist-packages/waveshare/__init__.py
rm pantilthat.py
chmod +x *py
chmod -x config*py
chmod +x *sh
chmod +x rclone-samples/*sh
echo "copy image-stitching to /usr/local/bin"
chmod +x image-stitching
sudo cp ./image-stitching /usr/local/bin
rm ./image-stitching
if [ ! -f user_motion_code.py ] ; then # wget user_motion_code.py file if it does not exist
wget -O user_motion_code.py -q --show-progress https://raw.github.com/pageauc/pi-timolo/master/source/user_motion_code.py
if [ $? -ne 0 ] ; then
wget -O user_motion_code.py https://raw.github.com/pageauc/pi-timolo/master/source/user_motion_code.py
fi
fi
if [ ! -f video.conf ] ; then
cp video.conf.new video.conf
fi
if [ ! -f config.py ] ; then
cp config.py.new config.py
fi
cp config.py config.py.prev # make copy of previous configuration
if [ ! -f watch-app.sh ] ; then
cp watch-app-new.sh watch-app.sh
fi
# Install plugins if not already installed. You must delete a plugin file to force reinstall.
echo "INFO : $STATUS Check/Install pi-timolo/plugins Wait ..."
PLUGINS_DIR='plugins' # Default folder install location
# List of plugin Files to Check
pluginFiles=("__init__.py" "dashcam.py" "secfast.py" "secQTL.py" "secstill.py" \
"secvid.py" "strmvid.py" "shopcam.py" "slowmo.py" "TLlong.py" "TLshort.py" "TLpan.py" "pano.py")
mkdir -p $PLUGINS_DIR
cd $PLUGINS_DIR
for fname in "${pluginFiles[@]}" ; do
if [ -f $fname ]; then # check if local file exists.
echo "INFO : $fname plugin Found. Skip Download ..."
else
wget_output=$(wget -O $fname -q --show-progress https://raw.github.com/pageauc/pi-timolo/master/source/plugins/$fname)
if [ $? -ne 0 ]; then
wget_output=$(wget -O $fname -q https://raw.github.com/pageauc/pi-timolo/master/source/plugins/$fname)
if [ $? -ne 0 ]; then
echo "ERROR : $fname wget Download Failed. Possible Cause Internet Problem."
else
wget -O $fname "https://raw.github.com/pageauc/pi-timolo/master/source/plugins/$fname"
fi
fi
fi
done
cd ..
# Install rclone samples
echo "INFO : $STATUS Check/Install pi-timolo/rclone-samples Wait ..."
RCLONE_DIR='rclone-samples' # Default folder install location
# List of plugin Files to Check
rcloneFiles=("Readme.md" "rclone-master.sh" "rclone-mo-copy-videos.sh" "rclone-mo-sync.sh" \
"rclone-mo-sync-lockfile.sh" "rclone-mo-sync-recent.sh" "rclone-tl-copy.sh" "rclone-tl-sync-recent.sh" "rclone-cleanup.sh")
mkdir -p $RCLONE_DIR
cd $RCLONE_DIR
for fname in "${rcloneFiles[@]}" ; do
wget_output=$(wget -O $fname -q --show-progress https://raw.github.com/pageauc/pi-timolo/master/source/rclone-samples/$fname)
if [ $? -ne 0 ]; then
wget_output=$(wget -O $fname -q https://raw.github.com/pageauc/pi-timolo/master/source/rclone-samples/$fname)
if [ $? -ne 0 ]; then
echo "ERROR : $fname wget Download Failed. Possible Cause Internet Problem."
else
wget -O $fname "https://raw.github.com/pageauc/pi-timolo/master/source/rclone-samples/$fname"
fi
fi
done
chmod +x *sh
cd ..
rclone_install=true
if [ -f /usr/bin/rclone ]; then
/usr/bin/rclone version
rclone_ins_ver=$( /usr/bin/rclone version | grep rclone )
if [ "$rclone_ins_ver" == "$rclone_cur_ver" ]; then
rclone_install=false
fi
fi
if "$rclone_install" == true ; then
# Install rclone with latest version
echo "INFO : Install Latest Rclone from https://downloads.rclone.org/rclone-current-linux-arm.zip"
wget -O rclone.zip -q --show-progress https://downloads.rclone.org/rclone-current-linux-arm.zip
if [ $? -ne 0 ]; then
wget -O rclone.zip https://downloads.rclone.org/rclone-current-linux-arm.zip
fi
echo "INFO : unzip rclone.zip to folder rclone-tmp"
unzip -o -j -d rclone-tmp rclone.zip
echo "INFO : Install files and man pages"
cd rclone-tmp
sudo cp rclone /usr/bin/
sudo chown root:root /usr/bin/rclone
sudo chmod 755 /usr/bin/rclone
sudo mkdir -p /usr/local/share/man/man1
sudo cp rclone.1 /usr/local/share/man/man1/
sudo mandb
cd ..
echo "INFO : Deleting rclone.zip and Folder rclone-tmp"
rm rclone.zip
rm -r rclone-tmp
echo "INFO : /usr/bin/rclone Install Complete"
else
echo "INFO : /usr/bin/rclone is Up-To-Date"
fi
echo "INFO : $STATUS Install pi-timolo Dependencies Wait ..."
sudo apt-get install -yq python-picamera
sudo apt-get install -yq python3-picamera
sudo apt-get install -yq python-pil
sudo apt-get install -yq python3-pil
sudo apt-get install -yq python-imaging # depricated in Buster
sudo apt-get install -yq dos2unix
sudo apt-get install -yq python-pyexiv2
sudo apt-get install -yq ffmpeg # required for Buster.
sudo apt-get install -yq libav-tools # backward compatible, replaced by ffmpeg in Buster
sudo apt-get install -yq pandoc # convert markdown to plain text for Readme.md
sudo apt-get install -yq gpac # required for MP4Box video converter
sudo apt-get install -yq fonts-freefont-ttf # Required for Jessie Lite Only
sudo apt-get install -yq python-opencv
sudo apt-get install -yq python3-opencv # Raspbian Buster Installs opencv 3.2 (won't change existing)
sudo apt-get install -yq python-pip
sudo apt-get install -yq python3-dateutil
sudo apt-get install -yq python-dateutil
sudo apt-get install -yq python-pantilthat
sudo apt-get install -yq python3-pantilthat
sudo apt-get install -yq python-rpi.gpio
sudo apt-get install -yq python3-rpi.gpio
bcm_ver='68'
cd ~
echo "$0 Install bcm2835-1.$bcm_ver Please wait ..."
echo "$0 Downloading http://www.airspayce.com/mikem/bcm2835/bcm2835-1.$bcm_ver.tar.gz"
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.$bcm_ver.tar.gz
tar -zxvf bcm2835-1.$bcm_ver.tar.gz
cd bcm2835-1.$bcm_ver
sudo ./configure
echo "$0 Compiling ..... One Moment Please"
sudo make
sudo make check
echo "$0 Running make install"
sudo make install
echo "$0 Performing Cleanup"
cd ~
rm bcm2835-1.$bcm_ver.tar.gz
sudo rm -r bcm2835-1.$bcm_ver
echo "$0 Completed Install of bcm2835-1.$bcm_ver"
echo ""
if [ $? -ne 0 ] ; then
sudo apt-get install -yq python3-pip
sudo pip install python-dateutil # used for scheduled date/time feature
if [ $? -ne 0 ] ; then
# Upgrade version of pip on Raspbian Wheezy to add ssl support
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python get-pip.py
rm get-pip.py
fi
fi
cd $TIMOLO_DIR
sudo pip install python-dateutil
sudo pip3 install py3exiv2
dos2unix -q *py
dos2unix -q *sh
echo "INFO : $STATUS Done Dependencies Install"
# Check if pi-timolo-install.sh was launched from pi-timolo folder
if [ "$DIR" != "$INSTALL_PATH" ]; then
if [ -f 'pi-timolo-install.sh' ]; then
echo "INFO : $STATUS Cleanup pi-timolo-install.sh"
rm pi-timolo-install.sh
fi
fi
# cleanup old files from previous versions of install
cleanup_files=("get-pip.py" "gdrive" "install.sh" "makemovie.sh" "makedailymovie.sh" "pancam.py" "pancam.pyc" \
"convid.conf" "convid.conf.orig" "convid.conf.prev" "convid.conf.1" "convid.conf.new" \
"makevideo.conf" "makevideo.conf.orig" "makevideo.conf.prev" "makevideo.conf.1" \
"makevideo.conf.new" "sync.sh" "pi-timolo-install.sh" "rclone-sync-new.sh" "rclone-videos-new.sh")
for fname in "${cleanup_files[@]}" ; do
if [ -f $fname ] ; then
echo "INFO : Delete $fname"
rm -f $fname
fi
done
if [ -f /usr/bin/rclone ]; then
echo "INFO : $STATUS rclone is installed at /usr/bin/rclone"
rclone version
else
echo "ERROR : $STATUS Problem Installing rclone. Please Investigate"
fi
echo "
-----------------------------------------------
INFO : $STATUS Complete ver 12.0
-----------------------------------------------
Minimal Instructions:
1 - Run sudo raspi-config Interfacing Options and enable I2C and Pi Camera
2 - It is suggested you run sudo apt-get update and sudo apt-get upgrade
Reboot RPI if there are significant Raspbian system updates.
3 - If config.py already exists then latest file is config.py.new
4 - To Test Run pi-timolo execute the following commands in RPI SSH
or terminal session. Default is Motion Track On and TimeLapse On
cd ~/pi-timolo
./pi-timolo.py
5 - To manage pi-timolo, Run menubox.sh Execute commands below
cd ~/pi-timolo
./menubox.sh"
if $is_upgrade ; then
echo "
IMPORTANT: pi-timolo.py ver 10.x Adds a Sched StartAt Feature.
If pi-timolo.py gives error messages on start
then the latest config.py may not be configured.
Install per commands below if Required.
pi-timolo.py ver 12.0 Adds pantilt panoramic image stitching option
See config.py for variable comments.
cd ~/pi-timolo
cp config.py config.py.bak
cp config.py.new config.py
nano config.py
Use nano to Restore Custom Settings from config.py.bak then ctrl-x y to Save and Exit
For Details See Wiki at
https://github.com/pageauc/pi-timolo/wiki/How-to-Schedule-Motion,-Timelapse-or-VideoRepeat"
fi
echo "
For Full Instructions See Wiki at https://github.com/pageauc/pi-timolo/wiki
Good Luck Claude ...
Bye"