-# Creates firewall configuration. However, since this functionality is now
-# taken over by pbx-advanced.lua, this function is unused.
-create_firewall_config()
-{
- local bindport
- local rtpstart
- local rtpend
- local externhost
-
- config_get bindport advanced bindport
- config_get externhost advanced externhost
- config_get rtpstart advanced rtpstart
- config_get rtpend advanced rtpend
-
- # We need all of these parameters to be set in order to consider inserting firewall rules.
- if [ -z "$externhost" -o -z "$bindport" -o -z "$rtpstart" -o -z "$rtpend" ] ; then
- rm -f $FIREWALL_PATH
- return
- fi
-
- sed "s/|SIPPORT|/$bindport/g" $TMPL_FIREWALL |\
- sed "s/|RTPRANGE|/$rtpstart:$rtpend/g" > $WORKDIR/firewall.$MODULENAME
-
- # Make sure there is an include section in the firewall configuration
- # to include the file we just created.
- i=0 ; found_path=0
- while p=`uci get firewall.@include[$i].path 2>/dev/null` ; do
- if [ "$p" = "$FIREWALL_PATH" ] ; then
- found_path=1
- break
- fi
- i=`expr $i + 1`
- done
-
- # If no include section was found which mentions $FIREWALL_PATH, add one.
- if [ $found_path -eq 0 ] ; then
- uci add firewall include 1>/dev/null 2>/dev/null
- uci set firewall.@include[-1].path="$FIREWALL_PATH"
- uci commit firewall
- fi
-}