blob: 69860de9c11ccc80d6e878246d2988442730e557 (
plain)
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
|
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
PROGNAME="$0"
die() {
>&2 echo "error: $@"
exit 1
}
vkos() {
$PROGNAME "$@"
}
usage() {
cat <<EOF
usage: $PROGNAME [OPTIONS] COMMAND
Options:
-b use backup server
-d don't delete files after merge
Supported commands:
list NODE
fetch NODE PREFIX
merge
auto DATE
EOF
exit
}
[ -z "$1" ] && usage
COMMAND=
NODE=
PREFIX=
FROM_BACKUP=0
DONT_DELETE=0
DATE=
while [[ $# -gt 0 ]]; do
case "$1" in
list)
COMMAND="$1"
NODE="$2"
shift
;;
fetch)
COMMAND="$1"
NODE="$2"
PREFIX="$3"
shift; shift
;;
merge)
COMMAND="$1"
;;
auto)
COMMAND="$1"
DATE="$2"
shift
;;
-b)
FROM_BACKUP=1
;;
-d)
DONT_DELETE=1
;;
*)
die "unrecognized argument: $1"
;;
esac
shift
done
[ -z "$COMMAND" ] && usage
if [ "$FROM_BACKUP" = "0" ]; then
SRV_HOST=solarmon.ru
SRV_PORT=60681
SRV_USER=user
SRV_DIR=/var/recordings
else
SRV_HOST=srv_nas4
SRV_PORT=22
SRV_USER=root
SRV_DIR=/var/storage1/solarmon/recordings
fi
case "$COMMAND" in
list)
[ -z "$NODE" ] && usage
ssh -p${SRV_PORT} ${SRV_USER}@${SRV_HOST} "ls -rt --time creation \"${SRV_DIR}/${NODE}\""
;;
fetch)
[ -z "$NODE" ] && usage
[ -z "$PREFIX" ] && usage
rsync -azPv -e "ssh -p${SRV_PORT}" ${SRV_USER}@${SRV_HOST}:"${SRV_DIR}/${NODE}/${PREFIX}*" .
;;
merge)
args=
if [ "$DONT_DELETE" = "0" ]; then args="-D"; fi
$DIR/merge-recordings.py $args
;;
auto)
[ -z "$DATE" ] && usage
DATE_WO_DOTS=${DATE//./}
cd ~/vkos
mkdir $DATE
cd $DATE
for node in bh1 room; do
mkdir $node
cd $node
vkos fetch $node $DATE_WO_DOTS
vkos merge -d
cd ..
done
;;
esac
|