From 9c6d4f90fb4794d0f6f060e5bb6d447a442a4632 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Sun, 2 Sep 2012 08:35:42 -0700 Subject: [PATCH] Compile the firewall script if it doesn't exist - Also cleaned up a number of defects in the init scripts Signed-off-by: Tom Eastep --- Shorewall-init/init.debian.sh | 39 ++++++++++++++++------------------- Shorewall-init/init.fedora.sh | 12 +++++++++++ Shorewall-init/init.sh | 12 +++++++++++ Shorewall-init/init.suse.sh | 22 ++++++++++++++------ 4 files changed, 58 insertions(+), 27 deletions(-) diff --git a/Shorewall-init/init.debian.sh b/Shorewall-init/init.debian.sh index 96437dfcd..429d825dd 100755 --- a/Shorewall-init/init.debian.sh +++ b/Shorewall-init/init.debian.sh @@ -82,26 +82,24 @@ fi # Initialize the firewall shorewall_start () { local product - local VARDIR echo -n "Initializing \"Shorewall-based firewalls\": " for product in $PRODUCTS; do - VARDIR=/var/lib/$product - [ -f /etc/$product/vardir ] && . /etc/$product/vardir - if [ -x ${VARDIR}/firewall ]; then + + if [ ! -x ${VARDIR}/$product/firewall ]; then + if [ $product = shorewall -o $product = shorewall6 ]; then + ${SBINDIR}/$product compile + fi + fi + + if [ -x ${VARDIR}/$product/firewall ]; then # # Run in a sub-shell to avoid name collisions # ( - . /usr/share/$product/lib.base - # - # Get mutex so the firewall state is stable - # - mutex_on - if ! ${VARDIR}/firewall status > /dev/null 2>&1; then - ${VARDIR}/firewall stop || echo_notdone + if ! ${VARDIR}/$product/firewall status > /dev/null 2>&1; then + ${VARDIR}/$product/firewall stop || echo_notdone fi - mutex_off ) fi done @@ -114,18 +112,17 @@ shorewall_start () { # Clear the firewall shorewall_stop () { local product - local VARDIR echo -n "Clearing \"Shorewall-based firewalls\": " for product in $PRODUCTS; do - VARDIR=/var/lib/$product - [ -f /etc/$product/vardir ] && . /etc/$product/vardir - if [ -x ${VARDIR}/firewall ]; then - ( . /usr/share/$product/lib.base - mutex_on - ${VARDIR}/firewall clear || echo_notdone - mutex_off - ) + 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 fi done diff --git a/Shorewall-init/init.fedora.sh b/Shorewall-init/init.fedora.sh index a2ee32d23..70dffa638 100755 --- a/Shorewall-init/init.fedora.sh +++ b/Shorewall-init/init.fedora.sh @@ -48,6 +48,12 @@ start () { echo -n "Initializing \"Shorewall-based firewalls\": " for product in $PRODUCTS; do + if [ ! -x ${VARDIR}/firewall ]; then + 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 retval=${PIPESTATUS[0]} @@ -72,6 +78,12 @@ stop () { echo -n "Clearing \"Shorewall-based firewalls\": " for product in $PRODUCTS; do + if [ ! -x ${VARDIR}/firewall ]; then + 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 retval=${PIPESTATUS[0]} diff --git a/Shorewall-init/init.sh b/Shorewall-init/init.sh index 581bbc287..5298eb3d4 100755 --- a/Shorewall-init/init.sh +++ b/Shorewall-init/init.sh @@ -65,6 +65,12 @@ shorewall_start () { echo -n "Initializing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do + if [ ! -x ${VARDIR}/firewall ]; then + if [ $PRODUCT = shorewall -o $product = shorewall6 ]; then + ${SBINDIR}/$PRODUCT compile + fi + fi + if [ -x ${VARDIR}/firewall ]; then if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then ${VARDIR}/firewall stop || echo_notdone @@ -86,6 +92,12 @@ shorewall_stop () { echo -n "Clearing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do + if [ ! -x ${VARDIR}/firewall ]; then + if [ $PRODUCT = shorewall -o $product = shorewall6 ]; then + ${SBINDIR}/$PRODUCT compile + fi + fi + if [ -x ${VARDIR}/firewall ]; then ${VARDIR}/firewall clear || exit 1 fi diff --git a/Shorewall-init/init.suse.sh b/Shorewall-init/init.suse.sh index 0afa523f2..d4c724d74 100755 --- a/Shorewall-init/init.suse.sh +++ b/Shorewall-init/init.suse.sh @@ -60,13 +60,18 @@ fi # Initialize the firewall shorewall_start () { local PRODUCT - local VARDIR echo -n "Initializing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do - if [ -x ${VARDIR}/firewall ]; then + 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 ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then - ${VARDIR}/firewall stop || echo_notdone + ${VARDIR}/$PRODUCT/firewall stop || echo_notdone fi fi done @@ -81,12 +86,17 @@ shorewall_start () { # Clear the firewall shorewall_stop () { local PRODUCT - local VARDIR echo -n "Clearing \"Shorewall-based firewalls\": " for PRODUCT in $PRODUCTS; do - if [ -x ${VARDIR}/firewall ]; then - ${VARDIR}/firewall clear || exit 1 + 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 fi done