-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddcams.sh
executable file
·68 lines (63 loc) · 1.48 KB
/
addcams.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
#!/bin/bash
USER=admin
PASS="$1" #take in password on command line
C="curl --digest -u $USER:$PASS"
HOST="http://10.250.249.100/ISAPI/ContentMgmt/InputProxy/channels/"
NET="10.250.249.1"
makexml(){
USER=$1
PASS=$2
CID=$3
CIP=$4
cat <<EOF
<InputProxyChannel>
<id>$CID</id>
<sourceInputPortDescriptor>
<proxyProtocol>HIKVISION</proxyProtocol>
<addressingFormatType>ipaddress</addressingFormatType>
<ipAddress>$CIP</ipAddress>
<managePortNo>8000</managePortNo>
<srcInputPort>1</srcInputPort>
<userName>$USER</userName>
<password>$PASS</password>
</sourceInputPortDescriptor>
</InputProxyChannel>
EOF
}
delcams(){
for i in {1..32}; do
CID=$i
$C -X DELETE "${HOST}${CID}"
done
}
addcams(){
USER=$1
PASS=$2
for i in {1..32}; do
CID=0 #$i
CIP="$(printf '10.250.249.1%02d' $i)"
XML=$(makexml "$USER" "$PASS" "$CID" "$CIP")
$C -X POST --data-raw "$XML" "${HOST}"
done
}
delcams
addcams "$USER" "$PASS"
#DELETE deletes (natch)
#PUT modifies
#POST with id=0 adds a new channel
#/ISAPI/ContentMgmt/InputProxy/channels/$CID
#curl --basic
#xml PUT (modification)
#<InputProxyChannel>
#<id>$CID</id>
#<sourceInputPortDescriptor>
#<proxyProtocol>HIKVISION</proxyProtocol>
#<addressingFormatType>ipaddress</addressingFormatType>
#<ipAddress>$CIP</ipAddress>
#<managePortNo>8000</managePortNo>
#<srcInputPort>1</srcInputPort>
#<userName>$USER</userName>
#<password>$PASS</password>
#<streamType>auto</streamType>
#</sourceInputPortDescriptor>
#</InputProxyChannel>