1#!/vendor/bin/sh
2
3DIR=/data/vendor/dump_touch
4SCRIPT_DIR=/vendor/bin/dump_touch
5LOCKFILE="$DIR"/dumping
6LOGFILE="$DIR"/dump.log
7
8if [ ! -f $LOCKFILE ]
9then
10#Init Setup
11  echo 0 > $LOCKFILE
12  echo "" > $LOGFILE
13  chmod 660 $LOCKFILE
14  chmod 660 $LOGFILE
15fi
16
17echo $(date) >> $LOGFILE
18
19state=$(cat $LOCKFILE)
20if [ "$state" != 0 ]
21then
22  echo "Unexpected state! Expected 0 but found ${state}" >> $LOGFILE
23fi
24
25echo 1 > $LOCKFILE
26
27for entry in "$SCRIPT_DIR"/*.sh
28do
29  echo "----------------------------------" >> $LOGFILE
30  echo "$entry" >> $LOGFILE
31  echo "----------------------------------" >> $LOGFILE
32  sh $entry >> $LOGFILE
33  echo "----------------------------------" >> $LOGFILE
34done
35
36state=$(cat $LOCKFILE)
37if [ "$state" != 1 ]
38then
39  echo "Unexpected state! Expected 1 but found ${state}" >> $LOGFILE
40fi
41
42echo 2 > $LOCKFILE
43
44
45