2006-06-03 17:16:21 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2007-10-22 17:47:25 +02:00
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: shorewall-lite
|
2010-02-15 16:05:47 +01:00
|
|
|
# Required-Start: $network $remote_fs
|
|
|
|
# Required-Stop: $network $remote_fs
|
2007-10-22 17:47:25 +02: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-lite
|
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-06-12 19:48:20 +02:00
|
|
|
SRWL=/sbin/shorewall-lite
|
2007-10-22 17:47:25 +02:00
|
|
|
SRWL_OPTS="-tvv"
|
2009-10-03 17:29:45 +02:00
|
|
|
test -n ${INITLOG:=/var/log/shorewall-lite-init.log}
|
2006-06-03 17:16:21 +02:00
|
|
|
|
2009-06-05 22:49:23 +02:00
|
|
|
[ "$INITLOG" eq "/dev/null" && SHOREWALL_INIT_SCRIPT=1 || SHOREWALL_INIT_SCRIPT=0
|
|
|
|
|
|
|
|
export SHOREWALL_INIT_SCRIPT
|
|
|
|
|
2006-06-03 17:16:21 +02:00
|
|
|
test -x $SRWL || exit 0
|
2007-10-22 17:47:25 +02:00
|
|
|
test -x $WAIT_FOR_IFUP || exit 0
|
2009-10-09 00:57:25 +02:00
|
|
|
test -n "$INITLOG" || {
|
2007-10-22 17:47:25 +02:00
|
|
|
echo "INITLOG cannot be empty, please configure $0" ;
|
2006-06-03 17:16:21 +02:00
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$(id -u)" != "0" ]
|
|
|
|
then
|
|
|
|
echo "You must be root to start, stop or restart \"Shorewall firewall\"."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo_notdone () {
|
|
|
|
|
2007-10-22 17:47:25 +02:00
|
|
|
if [ "$INITLOG" = "/dev/null" ] ; then
|
|
|
|
echo "not done."
|
|
|
|
else
|
|
|
|
echo "not done (check $INITLOG)."
|
2006-06-03 17:16:21 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
not_configured () {
|
|
|
|
echo "#### WARNING ####"
|
|
|
|
echo "the firewall won't be started/stopped unless it is configured"
|
|
|
|
if [ "$1" != "stop" ]
|
|
|
|
then
|
|
|
|
echo ""
|
2007-10-22 17:47:25 +02:00
|
|
|
echo "Please read about Debian specific customization in"
|
|
|
|
echo "/usr/share/doc/shorewall/README.Debian.gz."
|
2006-06-03 17:16:21 +02:00
|
|
|
fi
|
|
|
|
echo "#################"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2007-10-22 17:47:25 +02:00
|
|
|
# parse the shorewall params file in order to use params in
|
|
|
|
# /etc/default/shorewall
|
|
|
|
if [ -f "/etc/shorewall-lite/params" ]
|
|
|
|
then
|
|
|
|
. /etc/shorewall-lite/params
|
|
|
|
fi
|
|
|
|
|
2006-06-03 17:16:21 +02:00
|
|
|
# check if shorewall is configured or not
|
2006-06-09 23:36:27 +02:00
|
|
|
if [ -f "/etc/default/shorewall-lite" ]
|
2006-06-03 17:16:21 +02:00
|
|
|
then
|
2006-06-09 23:36:27 +02:00
|
|
|
. /etc/default/shorewall-lite
|
2008-09-23 01:40:10 +02:00
|
|
|
SRWL_OPTS="$SRWL_OPTS $OPTIONS"
|
2006-06-03 17:16:21 +02:00
|
|
|
if [ "$startup" != "1" ]
|
|
|
|
then
|
|
|
|
not_configured
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
not_configured
|
|
|
|
fi
|
|
|
|
|
|
|
|
# start the firewall
|
|
|
|
shorewall_start () {
|
|
|
|
echo -n "Starting \"Shorewall firewall\": "
|
2007-10-22 17:47:25 +02:00
|
|
|
$SRWL $SRWL_OPTS start >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
2006-06-03 17:16:21 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# stop the firewall
|
|
|
|
shorewall_stop () {
|
|
|
|
echo -n "Stopping \"Shorewall firewall\": "
|
2007-10-22 17:47:25 +02:00
|
|
|
$SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
2006-06-03 17:16:21 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# restart the firewall
|
|
|
|
shorewall_restart () {
|
|
|
|
echo -n "Restarting \"Shorewall firewall\": "
|
2007-10-22 17:47:25 +02:00
|
|
|
$SRWL $SRWL_OPTS restart >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
2006-06-03 17:16:21 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# refresh the firewall
|
|
|
|
shorewall_refresh () {
|
|
|
|
echo -n "Refreshing \"Shorewall firewall\": "
|
2007-10-22 17:47:25 +02:00
|
|
|
$SRWL $SRWL_OPTS refresh >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
2006-06-03 17:16:21 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
shorewall_start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
shorewall_stop
|
|
|
|
;;
|
|
|
|
refresh)
|
|
|
|
shorewall_refresh
|
2007-10-22 17:47:25 +02:00
|
|
|
;;
|
2006-06-03 17:16:21 +02:00
|
|
|
force-reload|restart)
|
|
|
|
shorewall_restart
|
|
|
|
;;
|
|
|
|
*)
|
2006-06-11 18:05:21 +02:00
|
|
|
echo "Usage: /etc/init.d/shorewall-lite {start|stop|refresh|restart|force-reload}"
|
2006-06-03 17:16:21 +02:00
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|