2008-12-07 19:17:26 +01:00
|
|
|
#!/bin/sh
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: shorewall
|
2010-02-15 17:39:50 +01:00
|
|
|
# Required-Start: $network $remote_fs
|
|
|
|
# Required-Stop: $network $remote_fs
|
2008-12-07 19:17:26 +01:00
|
|
|
# Default-Start: S
|
|
|
|
# Default-Stop: 0 6
|
|
|
|
# Short-Description: Configure the firewall at boot time
|
|
|
|
# Description: Configure the firewall according to the rules specified in
|
|
|
|
# /etc/shorewall
|
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
|
|
|
|
SRWL=/sbin/shorewall
|
2009-06-06 00:12:59 +02:00
|
|
|
SRWL_OPTS="-tvv"
|
2008-12-07 19:17:26 +01:00
|
|
|
WAIT_FOR_IFUP=/usr/share/shorewall/wait4ifup
|
2009-10-03 01:10:14 +02:00
|
|
|
test -n ${INITLOG:=/var/log/shorewall-init.log}
|
2009-06-05 22:49:23 +02:00
|
|
|
|
2008-12-07 19:17:26 +01:00
|
|
|
test -x $SRWL || exit 0
|
|
|
|
test -x $WAIT_FOR_IFUP || exit 0
|
2009-10-09 00:57:25 +02:00
|
|
|
test -n "$INITLOG" || {
|
2010-06-07 18:16:56 +02:00
|
|
|
echo "INITLOG cannot be empty, please configure $0" ;
|
2009-06-05 22:05:17 +02:00
|
|
|
exit 1;
|
|
|
|
}
|
2008-12-07 19:17:26 +01:00
|
|
|
|
|
|
|
if [ "$(id -u)" != "0" ]
|
|
|
|
then
|
|
|
|
echo "You must be root to start, stop or restart \"Shorewall firewall\"."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo_notdone () {
|
2009-06-05 22:05:17 +02:00
|
|
|
|
2010-06-07 18:16:56 +02:00
|
|
|
if [ "$INITLOG" = "/dev/null" ] ; then
|
2009-06-05 22:05:17 +02:00
|
|
|
echo "not done."
|
2010-06-07 18:16:56 +02:00
|
|
|
else
|
2009-06-05 22:05:17 +02:00
|
|
|
echo "not done (check $INITLOG)."
|
|
|
|
fi
|
|
|
|
|
2010-02-20 17:10:13 +01:00
|
|
|
exit 1
|
2008-12-07 19:17:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
not_configured () {
|
|
|
|
echo "#### WARNING ####"
|
|
|
|
echo "The firewall won't be started/stopped unless it is configured"
|
|
|
|
if [ "$1" != "stop" ]
|
|
|
|
then
|
|
|
|
echo ""
|
|
|
|
echo "Please read about Debian specific customization in"
|
2009-10-02 20:13:44 +02:00
|
|
|
echo "/usr/share/doc/shorewall/README.Debian.gz."
|
2008-12-07 19:17:26 +01:00
|
|
|
fi
|
|
|
|
echo "#################"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
#determine where the files were installed
|
|
|
|
if [ -f ~/.shorewallrc ]; then
|
|
|
|
. ~/.shorewallrc || exit 1
|
|
|
|
SRWL=${SBIN}/shorewall
|
|
|
|
else
|
|
|
|
SYSCONFDIR=/etc/default
|
|
|
|
fi
|
|
|
|
|
2008-12-07 19:17:26 +01:00
|
|
|
# check if shorewall is configured or not
|
2012-03-24 21:05:39 +01:00
|
|
|
if [ -f "${SYSCONFDIR}/shorewall" ]
|
2008-12-07 19:17:26 +01:00
|
|
|
then
|
2012-03-24 21:05:39 +01:00
|
|
|
. ${SYSCONFDIR}/shorewall
|
2008-12-07 19:17:26 +01:00
|
|
|
SRWL_OPTS="$SRWL_OPTS $OPTIONS"
|
|
|
|
if [ "$startup" != "1" ]
|
|
|
|
then
|
|
|
|
not_configured
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
not_configured
|
|
|
|
fi
|
|
|
|
|
2009-06-07 17:36:37 +02:00
|
|
|
[ "$INITLOG" = "/dev/null" ] && SHOREWALL_INIT_SCRIPT=1 || SHOREWALL_INIT_SCRIPT=0
|
2009-06-07 17:07:56 +02:00
|
|
|
|
|
|
|
export SHOREWALL_INIT_SCRIPT
|
|
|
|
|
2010-06-07 18:16:56 +02:00
|
|
|
# wait for an unconfigured interface
|
2008-12-07 19:17:26 +01:00
|
|
|
wait_for_pppd () {
|
|
|
|
if [ "$wait_interface" != "" ]
|
|
|
|
then
|
|
|
|
for i in $wait_interface
|
|
|
|
do
|
|
|
|
$WAIT_FOR_IFUP $i 90
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# start the firewall
|
|
|
|
shorewall_start () {
|
|
|
|
echo -n "Starting \"Shorewall firewall\": "
|
|
|
|
wait_for_pppd
|
2012-01-16 19:03:13 +01:00
|
|
|
$SRWL $SRWL_OPTS start $STARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
2008-12-07 19:17:26 +01:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# stop the firewall
|
|
|
|
shorewall_stop () {
|
|
|
|
echo -n "Stopping \"Shorewall firewall\": "
|
2010-05-25 16:16:02 +02:00
|
|
|
if [ "$SAFESTOP" = 1 ]; then
|
|
|
|
$SRWL $SRWL_OPTS stop >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
|
|
|
else
|
|
|
|
$SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
|
|
|
fi
|
2008-12-07 19:17:26 +01:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# restart the firewall
|
|
|
|
shorewall_restart () {
|
|
|
|
echo -n "Restarting \"Shorewall firewall\": "
|
2012-01-16 19:03:13 +01:00
|
|
|
$SRWL $SRWL_OPTS restart $RESTARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
2008-12-07 19:17:26 +01:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# refresh the firewall
|
|
|
|
shorewall_refresh () {
|
|
|
|
echo -n "Refreshing \"Shorewall firewall\": "
|
2009-06-05 22:05:17 +02:00
|
|
|
$SRWL $SRWL_OPTS refresh >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
2008-12-07 19:17:26 +01:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2011-11-02 00:55:02 +01:00
|
|
|
# status of the firewall
|
|
|
|
shorewall_status () {
|
|
|
|
$SRWL $SRWL_OPTS status && exit 0 || exit $?
|
|
|
|
}
|
|
|
|
|
2008-12-07 19:17:26 +01:00
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
shorewall_start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
shorewall_stop
|
|
|
|
;;
|
|
|
|
refresh)
|
|
|
|
shorewall_refresh
|
2010-05-25 16:16:02 +02:00
|
|
|
;;
|
2008-12-07 19:17:26 +01:00
|
|
|
force-reload|restart)
|
|
|
|
shorewall_restart
|
|
|
|
;;
|
2011-11-02 00:55:02 +01:00
|
|
|
status)
|
|
|
|
shorewall_status
|
|
|
|
;;
|
2008-12-07 19:17:26 +01:00
|
|
|
*)
|
2011-11-02 00:55:02 +01:00
|
|
|
echo "Usage: /etc/init.d/shorewall {start|stop|refresh|restart|force-reload|status}"
|
2008-12-07 19:17:26 +01:00
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|