diff --git a/Shorewall-init/init.debian.sh b/Shorewall-init/init.debian.sh index 3bf0afcde..dd4b10b17 100755 --- a/Shorewall-init/init.debian.sh +++ b/Shorewall-init/init.debian.sh @@ -62,6 +62,22 @@ not_configured () { exit 0 } +# set the STATEDIR variable +setstatedir() { + local statedir + if [ -f ${CONFDIR}/${g_program}/vardir ]; then + statedir=$( . /${CONFDIR}/${g_program}/vardir && echo $VARDIR ) + fi + + [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${g_program} + + if [ ! -x $STATEDIR/firewall ]; then + if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then + ${SBINDIR}/$PRODUCT compile + fi + fi +} + # # The installer may alter this # @@ -84,12 +100,11 @@ fi # Initialize the firewall shorewall_start () { local PRODUCT - local VARDIR + local STATEDIR echo -n "Initializing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do - [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir - [ -n ${VARDIR:=${vardir}/$PRODUCT} ] + setstatedir if [ ! -x ${VARDIR}/$PRODUCT/firewall ]; then if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then @@ -121,8 +136,7 @@ shorewall_stop () { echo -n "Clearing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do - [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir - [ -n ${VARDIR:=${vardir}/$PRODUCT} ] + setstatedir if [ ! -x ${VARDIR}/$PRODUCT/firewall ]; then if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then diff --git a/Shorewall-init/init.fedora.sh b/Shorewall-init/init.fedora.sh index dea92fecc..88fe81f71 100755 --- a/Shorewall-init/init.fedora.sh +++ b/Shorewall-init/init.fedora.sh @@ -37,6 +37,22 @@ else exit 6 fi +# set the STATEDIR variable +setstatedir() { + local statedir + if [ -f ${CONFDIR}/${g_program}/vardir ]; then + statedir=$( . /${CONFDIR}/${g_program}/vardir && echo $VARDIR ) + fi + + [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${g_program} + + if [ ! -x $STATEDIR/firewall ]; then + if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then + ${SBINDIR}/$PRODUCT compile + fi + fi +} + # Initialize the firewall start () { local PRODUCT @@ -50,8 +66,7 @@ start () { echo -n "Initializing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do - [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir - [ -n ${VARDIR:=${vardir}/$PRODUCT} ] + setstatedir if [ ! -x ${VARDIR}/firewall ]; then if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then @@ -83,8 +98,7 @@ stop () { echo -n "Clearing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do - [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir - [ -n ${VARDIR:=${vardir}/$PRODUCT} ] + setstatedir if [ ! -x ${VARDIR}/firewall ]; then if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then diff --git a/Shorewall-init/init.sh b/Shorewall-init/init.sh index c48d70294..12eeb15c2 100755 --- a/Shorewall-init/init.sh +++ b/Shorewall-init/init.sh @@ -35,6 +35,21 @@ # prior to bringing up the network. ### END INIT INFO +setstatedir() { + local statedir + if [ -f ${CONFDIR}/${g_program}/vardir ]; then + statedir=$( . /${CONFDIR}/${g_program}/vardir && echo $VARDIR ) + fi + + [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${g_program} + + if [ ! -x $STATEDIR/firewall ]; then + if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then + ${SBINDIR}/$PRODUCT compile + fi + fi +} + if [ "$(id -u)" != "0" ] then echo "You must be root to start, stop or restart \"Shorewall \"." @@ -63,22 +78,15 @@ vardir=${VARDIR} # Initialize the firewall shorewall_start () { local PRODUCT - local VARDIR + local STATEDIR echo -n "Initializing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do - [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir - [ -n ${VARDIR:=${vardir}/$PRODUCT} ] + setstatedir - if [ ! -x ${VARDIR}/firewall ]; then - if [ $PRODUCT = shorewall -o $product = shorewall6 ]; then - ${SBINDIR}/$PRODUCT compile - fi - fi - - if [ -x ${VARDIR}/firewall ]; then + if [ -x ${STATEDIR}/firewall ]; then if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then - ${VARDIR}/firewall stop || echo_notdone + ${STATEDIR}/firewall stop || echo_notdone fi fi done @@ -97,8 +105,7 @@ shorewall_stop () { echo -n "Clearing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do - [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir - [ -n ${VARDIR:=${vardir}/$PRODUCT} ] + setstatedir if [ ! -x ${VARDIR}/firewall ]; then if [ $PRODUCT = shorewall -o $product = shorewall6 ]; then diff --git a/Shorewall-init/init.suse.sh b/Shorewall-init/init.suse.sh index 82f754f74..bedf38c11 100755 --- a/Shorewall-init/init.suse.sh +++ b/Shorewall-init/init.suse.sh @@ -57,27 +57,34 @@ fi # . /usr/share/shorewall/shorewallrc -vardir=$VARDIR +# set the STATEDIR variable +setstatedir() { + local statedir + if [ -f ${CONFDIR}/${g_program}/vardir ]; then + statedir=$( . /${CONFDIR}/${g_program}/vardir && echo $VARDIR ) + fi + + [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${g_program} + + if [ ! -x $STATEDIR/firewall ]; then + if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then + ${SBINDIR}/$PRODUCT compile + fi + fi +} # Initialize the firewall shorewall_start () { local PRODUCT - local VARDIR + local STATEDIR echo -n "Initializing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do - [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir - [ -n ${VARDIR:=${vardir}/$PRODUCT} ] + setstatedir - 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 $STATEDIR/firewall ]; then if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then - ${VARDIR}/$PRODUCT/firewall stop || echo_notdone + $STATEDIR/$PRODUCT/firewall stop || echo_notdone fi fi done @@ -92,21 +99,14 @@ shorewall_start () { # Clear the firewall shorewall_stop () { local PRODUCT - local VARDIR + local STATEDIR echo -n "Clearing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do - [ -f ${CONFDIR}/$PRODUCT/vardir ] && . ${CONFDIR}/$PRODUCT/vardir - [ -n ${VARDIR:=${vardir}/$PRODUCT} ] + setstatedir - 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 || exit 1 + if [ -x ${STATEDIR}/firewall ]; then + ${STATEDIR}/firewall clear || exit 1 fi done