-
Notifications
You must be signed in to change notification settings - Fork 0
/
securitydvr.sh
41 lines (38 loc) · 1.01 KB
/
securitydvr.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
#!/bin/bash
PVR1_URL="http://user:[email protected]/tmpfs/snap.jpg"
PVR1_NAME="GarageCam"
PVR2_URL="http://192.168.2.102:8080/photo.jpg"
PVR2_NAME="RackCam"
STORAGE_PATH=~/pvr
function createpaths(){
PVRNAME=$1
YEAR="$(date +"%Y")"
MONTH="$(date +"%m")"
DAY="$(date +"%d")"
if [ ! -d "$STORAGE_PATH/$PVRNAME/$YEAR/$MONTH/$DAY" ]; then
mkdir "$STORAGE_PATH/$PVRNAME/$YEAR/$MONTH/$DAY" -p
fi
echo "$STORAGE_PATH/$PVRNAME/$YEAR/$MONTH/$DAY"
}
function getimage(){
#set -x
URL=$1
PVRPATH=$2
STAMP="$(date +"%H-%M-%S")"
wget $URL -O "$PVRPATH/$STAMP.jpg" --quiet -U "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.17 (KHTML, like Gecko) Ubuntu/11.04 Chromium/11.0.654.0 Chrome/11.0.654.0 Safari/534.17"
}
function processdvrs(){
PVR1PATH=$(createpaths $PVR1_NAME)
#PVR2PATH=$(createpaths $PVR2_NAME)
getimage $PVR1_URL $PVR1PATH
#getimage $PVR2_URL $PVR2PATH
}
TIMER=0
while true; do
TIMER=$(($TIMER + 1))
processdvrs
if [ "$TIMER" -gt "1000" ]; then
rclone move ~/pvr secret:pvr &
TIMER=0
fi
done