diff --git a/Shorewall-init/init.debian.sh b/Shorewall-init/init.debian.sh index 429d825dd..3bf0afcde 100755 --- a/Shorewall-init/init.debian.sh +++ b/Shorewall-init/init.debian.sh @@ -67,6 +67,8 @@ not_configured () { # . /usr/share/shorewall/shorewallrc +vardir=$VARDIR + # check if shorewall-init is configured or not if [ -f "$SYSCONFDIR/shorewall-init" ] then @@ -81,24 +83,27 @@ fi # Initialize the firewall shorewall_start () { - local product + local PRODUCT + local VARDIR echo -n "Initializing \"Shorewall-based firewalls\": " - for product in $PRODUCTS; do + for PRODUCT in $PRODUCTS; do + [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir + [ -n ${VARDIR:=${vardir}/$PRODUCT} ] - if [ ! -x ${VARDIR}/$product/firewall ]; then - if [ $product = shorewall -o $product = shorewall6 ]; then - ${SBINDIR}/$product compile + if [ ! -x ${VARDIR}/$PRODUCT/firewall ]; then + if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then + ${SBINDIR}/$PRODUCT compile fi fi - if [ -x ${VARDIR}/$product/firewall ]; then + if [ -x ${VARDIR}/$PRODUCT/firewall ]; then # # Run in a sub-shell to avoid name collisions # ( - if ! ${VARDIR}/$product/firewall status > /dev/null 2>&1; then - ${VARDIR}/$product/firewall stop || echo_notdone + if ! ${VARDIR}/$PRODUCT/firewall status > /dev/null 2>&1; then + ${VARDIR}/$PRODUCT/firewall stop || echo_notdone fi ) fi @@ -111,18 +116,22 @@ shorewall_start () { # Clear the firewall shorewall_stop () { - local product + local PRODUCT + local VARDIR echo -n "Clearing \"Shorewall-based firewalls\": " - for product in $PRODUCTS; do - if [ ! -x ${VARDIR}/$product/firewall ]; then - if [ $product = shorewall -o $product = shorewall6 ]; then - ${SBINDIR}/$product compile + for PRODUCT in $PRODUCTS; do + [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir + [ -n ${VARDIR:=${vardir}/$PRODUCT} ] + + if [ ! -x ${VARDIR}/$PRODUCT/firewall ]; then + if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then + ${SBINDIR}/$PRODUCT compile fi fi - if [ -x ${VARDIR}/$product/firewall ]; then - ${VARDIR}/$product/firewall clear || echo_notdone + if [ -x ${VARDIR}/$PRODUCT/firewall ]; then + ${VARDIR}/$PRODUCT/firewall clear || echo_notdone fi done diff --git a/Shorewall-init/init.fedora.sh b/Shorewall-init/init.fedora.sh index 70dffa638..dea92fecc 100755 --- a/Shorewall-init/init.fedora.sh +++ b/Shorewall-init/init.fedora.sh @@ -24,6 +24,8 @@ lockfile="/var/lock/subsys/shorewall-init" # Source function library. . /etc/rc.d/init.d/functions +vardir=$VARDIR + # Get startup options (override default) OPTIONS= @@ -37,7 +39,7 @@ fi # Initialize the firewall start () { - local product + local PRODUCT local vardir if [ -z "$PRODUCTS" ]; then @@ -47,15 +49,18 @@ start () { fi echo -n "Initializing \"Shorewall-based firewalls\": " - for product in $PRODUCTS; do + for PRODUCT in $PRODUCTS; do + [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir + [ -n ${VARDIR:=${vardir}/$PRODUCT} ] + if [ ! -x ${VARDIR}/firewall ]; then - if [ $product = shorewall -o $product = shorewall6 ]; then - ${SBINDIR}/$product compile + if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then + ${SBINDIR}/$PRODUCT compile fi fi - if [ -x ${VARDIR}/$product/firewall ]; then - ${VARDIR}/$product/firewall stop 2>&1 | $logger + if [ -x ${VARDIR}/$PRODUCT/firewall ]; then + ${VARDIR}/$PRODUCT/firewall stop 2>&1 | $logger retval=${PIPESTATUS[0]} [ $retval -ne 0 ] && break fi @@ -73,19 +78,22 @@ start () { # Clear the firewall stop () { - local product + local PRODUCT local vardir echo -n "Clearing \"Shorewall-based firewalls\": " - for product in $PRODUCTS; do + for PRODUCT in $PRODUCTS; do + [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir + [ -n ${VARDIR:=${vardir}/$PRODUCT} ] + if [ ! -x ${VARDIR}/firewall ]; then - if [ $product = shorewall -o $product = shorewall6 ]; then - ${SBINDIR}/$product compile + if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then + ${SBINDIR}/$PRODUCT compile fi fi - if [ -x ${VARDIR}/$product/firewall ]; then - ${VARDIR}/$product/firewall clear 2>&1 | $logger + if [ -x ${VARDIR}/$PRODUCT/firewall ]; then + ${VARDIR}/$PRODUCT/firewall clear 2>&1 | $logger retval=${PIPESTATUS[0]} [ $retval -ne 0 ] && break fi diff --git a/Shorewall-init/init.sh b/Shorewall-init/init.sh index 5298eb3d4..c48d70294 100755 --- a/Shorewall-init/init.sh +++ b/Shorewall-init/init.sh @@ -58,6 +58,8 @@ fi # . /usr/share/shorewall/shorewallrc +vardir=${VARDIR} + # Initialize the firewall shorewall_start () { local PRODUCT @@ -65,6 +67,9 @@ shorewall_start () { echo -n "Initializing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do + [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir + [ -n ${VARDIR:=${vardir}/$PRODUCT} ] + if [ ! -x ${VARDIR}/firewall ]; then if [ $PRODUCT = shorewall -o $product = shorewall6 ]; then ${SBINDIR}/$PRODUCT compile @@ -92,6 +97,9 @@ shorewall_stop () { echo -n "Clearing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do + [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir + [ -n ${VARDIR:=${vardir}/$PRODUCT} ] + if [ ! -x ${VARDIR}/firewall ]; then if [ $PRODUCT = shorewall -o $product = shorewall6 ]; then ${SBINDIR}/$PRODUCT compile diff --git a/Shorewall-init/init.suse.sh b/Shorewall-init/init.suse.sh index d4c724d74..82f754f74 100755 --- a/Shorewall-init/init.suse.sh +++ b/Shorewall-init/init.suse.sh @@ -57,12 +57,18 @@ fi # . /usr/share/shorewall/shorewallrc +vardir=$VARDIR + # Initialize the firewall shorewall_start () { local PRODUCT + local VARDIR echo -n "Initializing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do + [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir + [ -n ${VARDIR:=${vardir}/$PRODUCT} ] + if [ ! -x ${VARDIR}/$PRODUCT/firewall ]; then if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then ${SBINDIR}/$PRODUCT compile @@ -86,9 +92,13 @@ shorewall_start () { # Clear the firewall shorewall_stop () { local PRODUCT + local VARDIR echo -n "Clearing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do + [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir + [ -n ${VARDIR:=${vardir}/$PRODUCT} ] + if [ ! -x ${VARDIR}/$PRODUCT/firewall ]; then if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then ${SBINDIR}/$PRODUCT compile