pr=`find /var/html/ -name portrule.js`
sed 's/return g_mldIpAdr0000/return null/' $pr > /var/tmp/portrule.js
mount -o bind /var/tmp/portrule.js $pr
cat > /var/tmp/unhiderules << 'EOF'
#! /bin/sh
# Die VOIP-Regel "ausblenden"
EXCLUDE="0\.0\.0\.0\:5060"
#PW extrahieren
local PWD=$(/bin/allcfgconv -C ar7 -c -o - | sed -ne '/^webui[[:space:]]*{/,/^}/{
/=/{s/[[:space:]]*=[[:space:]]*/=/;s/^[[:space:]]*//;p}
}' | grep '^password=' | cut -d '"' -f2)
ret=$?
if [ $ret != 0 ]; then
echo "ERROR: Unhide_local_PFWD (exit code $ret)" >&2
exit $ret
fi
QUERY=`find /usr/www/ -name query.txt`
# 0.0.0.0:xx 0.0.0.0:yy ersetzen durch 0.0.0.0:xx 127.0.0.1:yy
cat /var/flash/ar7.cfg | sed "/dslifaces/,/} {/ {/forward/,/}/ {/$EXCLUDE/! s/\(.*0\.0\.0\.0.*\)\(0\.0\.0\.0\)\(.*\)/\1127\.0\.0\.1\3/}}" > /var/tmp/tmpar7.cfg
cat /var/tmp/tmpar7.cfg > /var/flash/ar7.cfg
# Die "neuen" Regeln einlesen lassen, so dass sie per GUI erreichbar sind (die 0.0.0.0-er Regeln sind nicht "ansprechbar":
killall -9 ctlmgr && sleep 1 && /usr/bin/ctlmgr
sleep 5
# ... und nun das Aendern auf 0.0.0.0 per GUI "emulieren"
#
TESTSTRING="127.0.0.1"
NEUEIP="0.0.0.0"
# Erstmal POST_DATA String fuer PW "basteln" ...
PDATA="getpage=$QUERY&login:command/password=$PWD&id=uiPostForm&name=uiPostForm&var:pagename=home&var:menu=home"
# ... und PW setzen .
echo -n "$PDATA" | REQUEST_METHOD="POST" REMOTE_ADDR="127.0.0.1" CONTENT_TYPE="application/x-www-form-urlencoded" CONTENT_LENGTH=${#PDATA} /usr/www/html/cgi-bin/webcm > /dev/null
# Die Rules finden ...
rules="`wget -q -O - "http://127.0.0.1/cgi-bin/webcm?getpage=..%2Fhtml%2F$Language%2Fmenus%2Fmenu2.html&errorpage=..%2Fhtml%2F$Language%2Fmenus%2Fmenu2.html&var%3Alang=$Language&var%3Apagename=portfw&var%3Amenu=internet&var%3Apagemaster=" | grep -v $EXCLUDE |grep -A 6 $TESTSTRING |grep "uiDoEdit" | sed "s/.*uiDoEdit('\(.*\)').*/\1/"`"
if [ "$rules" != "" ]; then
# ... POST_DATA String "basteln"
PDATA="getpage=$QUERY&login:command/password=$PWD&id=uiPostForm&name=uiPostForm&var:pagename=portrule&var:menu=internet"
for myrule in `echo "$rules" | tr '\n' ' '`; do
PDATA="${PDATA}&var:rule=${myrule}&var:isnew=0&var:isexp=0&forwardrules:settings/${myrule}/fwip=$NEUEIP"
done
echo -n "$PDATA" | REQUEST_METHOD="POST" REMOTE_ADDR="127.0.0.1" CONTENT_TYPE="application/x-www-form-urlencoded" CONTENT_LENGTH=${#PDATA} /usr/www/html/cgi-bin/webcm > /dev/null
fi
# ... fertig
EOF
sh /var/tmp/unhiderules