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,7 +110,6 @@ 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
# #
@ -118,7 +119,6 @@ shorewall_start () {
fi fi
) )
fi fi
fi
done done
echo "done." echo "done."
@ -145,10 +145,8 @@ 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
echo "done." echo "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,7 +77,6 @@ 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
@ -83,9 +84,6 @@ start () {
retval=6 #Product not configured retval=6 #Product not configured
break break
fi fi
else
break
fi
done done
if [ $retval -eq 0 ]; then if [ $retval -eq 0 ]; then
@ -110,7 +108,6 @@ 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
@ -118,9 +115,6 @@ stop () {
retval=6 #Product not configured retval=6 #Product not configured
break break
fi fi
else
break
fi
done done
if [ $retval -eq 0 ]; then if [ $retval -eq 0 ]; then

14
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,17 +94,17 @@ 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
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,10 +119,8 @@ 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
if [ -n "$SAVE_IPSETS" ]; then if [ -n "$SAVE_IPSETS" ]; then
@ -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,12 +86,10 @@ 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
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
@ -107,10 +107,8 @@ 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
if [ -n "$SAVE_IPSETS" ]; then if [ -n "$SAVE_IPSETS" ]; then

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,12 +98,10 @@ 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
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
@ -117,10 +117,8 @@ 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
if [ -n "$SAVE_IPSETS" ]; then if [ -n "$SAVE_IPSETS" ]; then

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,7 +67,6 @@ 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
# #
@ -77,7 +76,6 @@ shorewall_start () {
fi fi
) )
fi fi
fi
done done
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
@ -95,10 +93,8 @@ 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
if [ -n "$SAVE_IPSETS" ]; then if [ -n "$SAVE_IPSETS" ]; then