Avoid unnecessary recompilation by Shorewall-init

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2017-12-18 10:25:56 -08:00
parent dec3cacb2a
commit 6c018f478c
No known key found for this signature in database
GPG Key ID: 96E6B3F2423A4D10
6 changed files with 61 additions and 75 deletions

View File

@ -73,12 +73,14 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ -x ${STATEDIR}/firewall ]; then
return 0;
if [ $PRODUCT = shorewall ]; then if [ $PRODUCT = shorewall ]; then
${SBINDIR}/shorewall compile ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile ${SBINDIR}/shorewall -6 compile
else else
return 0 return 1
fi fi
} }
@ -108,16 +110,14 @@ shorewall_start () {
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then #
# # Run in a sub-shell to avoid name collisions
# Run in a sub-shell to avoid name collisions #
# (
( if ! ${STATEDIR}/firewall status > /dev/null 2>&1; then
if ! ${STATEDIR}/firewall status > /dev/null 2>&1; then ${STATEDIR}/firewall ${OPTIONS} stop
${STATEDIR}/firewall ${OPTIONS} stop fi
fi )
)
fi
fi fi
done done
@ -145,9 +145,7 @@ shorewall_stop () {
printf "Clearing \"Shorewall-based firewalls\": " printf "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then ${STATEDIR}/firewall ${OPTIONS} clear
${STATEDIR}/firewall ${OPTIONS} clear
fi
fi fi
done done

View File

@ -44,12 +44,14 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall ]; then if [ -x ${STATEDIR}/firewall ]; then
return 0
elif [ $PRODUCT = shorewall ]; then
${SBINDIR}/shorewall compile ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile ${SBINDIR}/shorewall -6 compile
else else
return 0 return 1;
fi fi
} }
@ -75,15 +77,11 @@ start () {
retval=$? retval=$?
if [ $retval -eq 0 ]; then if [ $retval -eq 0 ]; then
if [ -x "${STATEDIR}/firewall" ]; then ${STATEDIR}/firewall ${OPTIONS} stop 2>&1 | $logger
${STATEDIR}/firewall ${OPTIONS} stop 2>&1 | $logger retval=${PIPESTATUS[0]}
retval=${PIPESTATUS[0]} [ $retval -ne 0 ] && break
[ $retval -ne 0 ] && break
else
retval=6 #Product not configured
break
fi
else else
retval=6 #Product not configured
break break
fi fi
done done
@ -110,15 +108,11 @@ stop () {
retval=$? retval=$?
if [ $retval -eq 0 ]; then if [ $retval -eq 0 ]; then
if [ -x "${STATEDIR}/firewall" ]; then ${STATEDIR}/firewall ${OPTIONS} clear 2>&1 | $logger
${STATEDIR}/firewall ${OPTIONS} clear 2>&1 | $logger retval=${PIPESTATUS[0]}
retval=${PIPESTATUS[0]} [ $retval -ne 0 ] && break
[ $retval -ne 0 ] && break
else
retval=6 #Product not configured
break
fi
else else
retval=6 #Product not configured
break break
fi fi
done done

20
Shorewall-init/init.openwrt.sh Normal file → Executable file
View File

@ -75,12 +75,14 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall ]; then if [ -x ${STATEDIR}/firewall ]; then
return 0
elif [ $PRODUCT = shorewall ]; then
${SBINDIR}/shorewall compile ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile ${SBINDIR}/shorewall -6 compile
else else
return 0 return 1
fi fi
} }
@ -92,10 +94,8 @@ start () {
printf "Initializing \"Shorewall-based firewalls\": " printf "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then ${STATEDIR}/firewall ${OPTIONS} stop
${STATEDIR}/firewall ${OPTIONS} stop
fi
fi fi
fi fi
done done
@ -103,6 +103,8 @@ start () {
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
ipset -R < "$SAVE_IPSETS" ipset -R < "$SAVE_IPSETS"
fi fi
return 0
} }
boot () { boot () {
@ -117,9 +119,7 @@ stop () {
printf "Clearing \"Shorewall-based firewalls\": " printf "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then ${STATEDIR}/firewall ${OPTIONS} clear
${STATEDIR}/firewall ${OPTIONS} clear
fi
fi fi
done done
@ -131,5 +131,7 @@ stop () {
rm -f "${SAVE_IPSETS}.tmp" rm -f "${SAVE_IPSETS}.tmp"
fi fi
fi fi
return 0
} }

View File

@ -69,10 +69,12 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ -x ${STATEDIR}/firewall ]; then
return 0
elif [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
${SBINDIR}/$PRODUCT ${OPTIONS} compile $STATEDIR/firewall ${SBINDIR}/$PRODUCT ${OPTIONS} compile $STATEDIR/firewall
else else
return 0 return 1
fi fi
} }
@ -84,10 +86,8 @@ shorewall_start () {
printf "Initializing \"Shorewall-based firewalls\": " printf "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then ${STATEDIR}/firewall ${OPTIONS} stop
${STATEDIR}/firewall ${OPTIONS} stop
fi
fi fi
fi fi
done done
@ -107,9 +107,7 @@ shorewall_stop () {
printf "Clearing \"Shorewall-based firewalls\": " printf "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then ${STATEDIR}/firewall ${OPTIONS} clear
${STATEDIR}/firewall ${OPTIONS} clear
fi
fi fi
done done

View File

@ -79,12 +79,14 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall ]; then if [ -x ${STATEDIR}/firewall ]; then
return 0
elif [ $PRODUCT = shorewall ]; then
${SBINDIR}/shorewall compile ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile ${SBINDIR}/shorewall -6 compile
else else
return 0 return 6
fi fi
} }
@ -96,10 +98,8 @@ shorewall_start () {
printf "Initializing \"Shorewall-based firewalls\": " printf "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; then
if [ -x $STATEDIR/firewall ]; then if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then $STATEDIR/$PRODUCT/firewall ${OPTIONS} stop
$STATEDIR/$PRODUCT/firewall ${OPTIONS} stop
fi
fi fi
fi fi
done done
@ -117,9 +117,7 @@ shorewall_stop () {
printf "Clearing \"Shorewall-based firewalls\": " printf "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then ${STATEDIR}/firewall ${OPTIONS} clear
${STATEDIR}/firewall ${OPTIONS} clear
fi
fi fi
done done

View File

@ -33,12 +33,12 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall ]; then if [ -x ${STATEDIR}/firewall ]; then
return 0
elif [ $PRODUCT = shorewall ]; then
${SBINDIR}/shorewall compile ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile ${SBINDIR}/shorewall -6 compile
else
return 0
fi fi
} }
@ -67,16 +67,14 @@ shorewall_start () {
printf "Initializing \"Shorewall-based firewalls\": " printf "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then #
# # Run in a sub-shell to avoid name collisions
# Run in a sub-shell to avoid name collisions #
# (
( if ! ${STATEDIR}/firewall status > /dev/null 2>&1; then
if ! ${STATEDIR}/firewall status > /dev/null 2>&1; then ${STATEDIR}/firewall ${OPTIONS} stop
${STATEDIR}/firewall ${OPTIONS} stop fi
fi )
)
fi
fi fi
done done
@ -95,9 +93,7 @@ shorewall_stop () {
printf "Clearing \"Shorewall-based firewalls\": " printf "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then ${STATEDIR}/firewall ${OPTIONS} clear
${STATEDIR}/firewall ${OPTIONS} clear
fi
fi fi
done done