-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsurfcampi.sh
executable file
·60 lines (45 loc) · 1.17 KB
/
surfcampi.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
#!/bin/bash
echo " "
# connect to 3G
#echo "connecting to 3G"
#sudo ./sakis3g connect
# set RTC time to internet time if connection
#./setTime.sh
# print current date time
date +"%a %b %d %T %Y %Z"
hwclock -r
# update scripts from github repo
git pull
# define hours for when surfcampi is working
workingHours=(`cat ./workingHours.txt`)
hour=`date +%H`
# find out whether surfcampi should be working or not
isWorkingHour=0
for wHour in "${workingHours[@]}"
do
if [ $wHour = $hour ]; then
isWorkingHour=1
fi
done
if [ $isWorkingHour = 1 ]; then
# surfcampi is working
# run script to collect pictures
./collectPictures.sh
# run script to create an animated gif from the collected pictures
echo "creating animated gif"
animatedFile=`./createAnimatedGif.sh $hour`
# upload animated gif to FTP
./uploadToFTP.sh $animatedFile
# print current date time
date +"%a %b %d %T %Y %Z"
else
# surfcampi does nothing for 2min in case we want to ssh it
echo "surfcampi does not have anything to do. Waiting doing nothing for a 2min."
sleep 120
fi
# disconnect from 3G
#echo "disconnecting from 3G"
#sudo ./sakis3g disconnect
# shutdown surfcampi
sudo halt
exit 0