-
Notifications
You must be signed in to change notification settings - Fork 0
/
move.sh
77 lines (62 loc) · 2.02 KB
/
move.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
#!/bin/bash
echo Starting;
DIR="$(cd "$(dirname "$0")" && pwd)"
source $DIR/config.cfg
echo "Current path is $DIR"
temp=$DIR/temp
# Count number of checks
check=1;
# For longtime picture of the hour to move at least every hour a picture if enabled
last=-1;
# Store last day raffer was executed so it do not happens multiple times on day
raffer_last_executed_day=-1
while [ true ]; do
datedir=$(date --date='+0 hour' +'%Y/%m/%d')
if [[ ! -d $DIR/files/$datedir/ ]]
then
echo "Set ownership of $origin/files/$datedir to $samba_user"
mkdir -p $DIR/files/$datedir
if [ "$object_detection" == "true" ]; then
mkdir -p $DIR/files/$datedir/object-detection
fi
chown -R $samba_user $DIR/files/$datedir
fi
# Count number of pictures
num=0;
for f in $temp/*.jpg; do
if [ -f "$f" ] # does file exist?
then
# Check if the file has been modified in the last 5 seconds
current_time=$(date +%s)
file_modified_time=$(stat -c %Y "$f")
if [ $((current_time - file_modified_time)) -gt 5 ]; then
chown $samba_user $f
# Save pictures at least every new hour in longtime
if [ "$save_longtime_pictures" == "true" ]; then
if [ $(date +%H) -ne $last ]
then
echo "New longtime picture, now $(date +%H), last was $last"
cp $f $DIR/files/raffer/longtime/
last=$(date +%H);
fi
fi
num=$((num + 1));
echo $f
if [ "$object_detection" == "true" ]; then
python3 $DIR/object-detection/deep_learning_object_detection.py --prototxt $DIR/object-detection/MobileNetSSD_deploy.prototxt.txt --model $DIR/object-detection/MobileNetSSD_deploy.caffemodel --image $f --save $DIR/files/$datedir/object-detection/${f##*/}
fi
cp $f $DIR/latest.jpg
mv $f $DIR/files/$datedir;
fi
fi
done;
check=$((check + 1));
# Check for time to start raffer
if [ $(date +%H:%M) == "$raffer_execution" ] && [ $(date +%d) -ne "$raffer_last_executed_day" ];
then
raffer_last_executed_day=$(date +%d)
echo "Starting raffer in background..."
bash $DIR/raffer.sh &
fi
sleep 1;
done;