-
Notifications
You must be signed in to change notification settings - Fork 0
/
timelapse
executable file
·133 lines (115 loc) · 2.62 KB
/
timelapse
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
#!/bin/bash
# starts a timelapse process in the background
# first parameter has to be start or stop
# the following parameter will be appended to the raspistill command
function help {
SCRIPT=${0##*/}
echo
if [ ! -z "$PID" ]; then
echo " raspistill is running on host $(hostname)"
echo " PID: $PID"
echo " output to $(cat ~/tmp/timelapse.dir)"
echo
echo " type '$SCRIPT stop' to end timelapse recording"
else
echo " raspistill is not running on host $(hostname)"
echo
echo " type '$SCRIPT start' to begin timelapse"
fi
exit
}
# check if the nfs mount is available
function mounted () {
MAXTRIES=10
COUNTER=0
until mountpoint /nfs
do
/bin/sleep 5
COUNTER=$((COUNTER+1))
if [ $COUNTER -gt 10 ]; then
echo "/nfs is not a mountpoint, exiting ..."
exit 1
fi
done
}
# default parameter
EX=night
TL=60000
WIDTH=1920
HEIGHT=1080
FLIP=
while getopts ":nut:w:h:" opt; do
case $opt in
n)
echo "night start"
EX="night"
;;
t)
echo "interval $OPTARG"
TL=$OPTARG
;;
w)
echo "width $OPTARG"
WIDTH=$OPTARG
;;
h)
echo "height $OPTARG"
HEIGHT=$OPTARG
;;
u)
echo "upside down mode"
FLIP="-vf -hf"
;;
\?)
echo "invalid option: -$OPTARG"
;;
esac
done
shift $((OPTIND-1))
CMD=$1
shift
echo raspistill -w $WIDTH -h $HEIGHT -ex $EX -tl $TL $CMD
PID=$(pgrep raspistill)
if [ "$CMD" = "start" ] || [ "$CMD" = "stop" ]
then
case "$CMD" in
stop)
if [ -z "$PID" ]
then
echo raspistill is not running
else
kill $PID
echo we stopped raspistill with pid: $PID
echo
echo "go to $(cat ~/tmp/timelapse.dir) for the output"
fi
;;
start)
if [ ! -z "$PID" ]
then
echo "found running raspistill, pid $PID"
else
mounted "~/timelapse"
DAYDIR=~/timelapse/`date +%Y%m%d`
mkdir -p $DAYDIR
DIR=$DAYDIR/`date +%Y%m%d-%H%M`
mkdir -p ~/tmp
echo $DAYDIR > ~/tmp/timelapse.dir
FOTOS=~/pictures
mkdir -p $DIR
echo raspistill -w $WIDTH -h $HEIGHT -tl $TL $FLIP --thumb none -ex $EX -n -t 0 -l $FOTOS/last.jpg -o $DIR/tl%06d.jpg $* &
raspistill -w $WIDTH -h $HEIGHT -tl $TL $FLIP --thumb none -ex $EX -n -t 0 -l $FOTOS/last.jpg -o $DIR/tl%06d.jpg $* &
ln -s ~steffenr/www/jq-galerie/galerie.html $DIR
echo raspistill started
echo stop with: timelapse stop
echo output directory: $DIR
fi
;;
*)
SCRIPTNAME=${0##*/}
echo "$SCRIPTNAME start|stop"
;;
esac
else
help
fi