-
Notifications
You must be signed in to change notification settings - Fork 0
/
testupnppermissions.sh
executable file
·56 lines (51 loc) · 1.18 KB
/
testupnppermissions.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
#!/bin/bash
# $Id: testupnppermissions.sh,v 1.2 2015/09/22 15:12:14 nanard Exp $
# Array are not available with POSIX sh
# bash / ksh
RULE[1]="allow 1-20000 11.12.13.14/22 1234"
RULEA[1]="allow 1-20000 0b0c0d0e/fffffc00 1234-1234"
RULEB[1]="allow 1-20000 11.12.13.14/255.255.252.0 1234-1234"
RULE[2]="deny 55 21.22.23.24/17 555-559"
RULEA[2]="deny 55-55 15161718/ffff8000 555-559"
RULEB[2]="deny 55-55 21.22.23.24/255.255.128.0 555-559"
i=1
s=1
./testupnppermissions "${RULE[@]}" | while read l;
do
if [ -z "$l" ]; then i=$(($i+1)); s=1; else
#echo "$i $s : checking '$l'"
case $s in
1)
if [ "$i '${RULE[$i]}'" != "$l" ] ; then
exit $s
fi;;
2)
if [ "Permission read successfully" = "$l" ] ; then
s=$(($s+1))
elif [ "perm rule added : ${RULEA[$i]}" != "$l" ] ; then
exit $s
fi;;
3)
if [ "Permission read successfully" != "$l" ] ; then
exit $s
fi;;
4)
if [ "${RULEB[$i]}" != "$l" ] ; then
exit $s
fi;;
*)
echo "$i $s : $l"
exit $s
;;
esac
s=$(($s+1))
fi
done
# retrieve return status from subshell
r=$?
if [ $r -eq 0 ] ; then
echo "testupnppermissions tests OK"
else
echo "testupnppermissions tests FAILED"
fi
exit $r