2008-12-09 17:50:17 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
### BEGIN INIT INFO
|
2008-12-10 01:33:55 +01:00
|
|
|
# Provides: shorewall6-lite
|
2010-02-15 17:39:50 +01:00
|
|
|
# Required-Start: $network $remote_fs
|
|
|
|
# Required-Stop: $network $remote_fs
|
2008-12-09 17:50:17 +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
|
2008-12-10 01:33:55 +01:00
|
|
|
# /etc/shorewall6-lite
|
2008-12-09 17:50:17 +01:00
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-10 01:33:55 +01:00
|
|
|
SRWL=/sbin/shorewall6-lite
|
2008-12-09 17:50:17 +01:00
|
|
|
SRWL_OPTS="-tvv"
|
2009-10-03 17:29:45 +02:00
|
|
|
test -n ${INITLOG:=/var/log/shorewall6-lite-init.log}
|
2008-12-09 17:50:17 +01:00
|
|
|
|
2010-10-01 22:56:06 +02:00
|
|
|
[ "$INITLOG" = "/dev/null" ] && SHOREWALL_INIT_SCRIPT=1 || SHOREWALL_INIT_SCRIPT=0
|
2009-06-05 22:49:23 +02:00
|
|
|
|
|
|
|
export SHOREWALL_INIT_SCRIPT
|
|
|
|
|
2008-12-09 17:50:17 +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" || {
|
2008-12-09 17:50:17 +01:00
|
|
|
echo "INITLOG cannot be empty, please configure $0" ;
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$(id -u)" != "0" ]
|
|
|
|
then
|
2009-03-09 02:05:53 +01:00
|
|
|
echo "You must be root to start, stop or restart \"Shorewall6 Lite firewall\"."
|
2008-12-09 17:50:17 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo_notdone () {
|
|
|
|
|
|
|
|
if [ "$INITLOG" = "/dev/null" ] ; then
|
|
|
|
echo "not done."
|
|
|
|
else
|
|
|
|
echo "not done (check $INITLOG)."
|
|
|
|
fi
|
|
|
|
|
2010-02-22 01:35:21 +01:00
|
|
|
exit 1
|
2008-12-09 17:50:17 +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"
|
2008-12-10 01:33:55 +01:00
|
|
|
echo "/usr/share/doc/shorewall6-lite/README.Debian.gz."
|
2008-12-09 17:50:17 +01:00
|
|
|
fi
|
|
|
|
echo "#################"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2009-03-09 02:05:53 +01:00
|
|
|
# parse the shorewall6 params file in order to use params in
|
|
|
|
# /etc/default/shorewall6
|
2008-12-31 19:08:36 +01:00
|
|
|
if [ -f "/etc/shorewall6-lite/params" ]
|
2008-12-09 17:50:17 +01:00
|
|
|
then
|
2008-12-31 19:08:36 +01:00
|
|
|
. /etc/shorewall6-lite/params
|
2008-12-09 17:50:17 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# check if shorewall is configured or not
|
2008-12-10 01:33:55 +01:00
|
|
|
if [ -f "/etc/default/shorewall6-lite" ]
|
2008-12-09 17:50:17 +01:00
|
|
|
then
|
2008-12-31 19:08:36 +01:00
|
|
|
. /etc/default/shorewall6-lite
|
2008-12-09 17:50:17 +01:00
|
|
|
SRWL_OPTS="$SRWL_OPTS $OPTIONS"
|
|
|
|
if [ "$startup" != "1" ]
|
|
|
|
then
|
|
|
|
not_configured
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
not_configured
|
|
|
|
fi
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
#determine where the files were installed
|
|
|
|
if [ -f ~/.shorewallrc ]; then
|
|
|
|
. ~/.shorewallrc || exit 1
|
|
|
|
[ -n "$SBIN" ] && SRWL=${SBIN}/shorewall6-lite
|
|
|
|
fi
|
|
|
|
|
2008-12-09 17:50:17 +01:00
|
|
|
# start the firewall
|
2009-03-09 02:05:53 +01:00
|
|
|
shorewall6_start () {
|
2008-12-10 01:33:55 +01:00
|
|
|
echo -n "Starting \"Shorewall6 Lite firewall\": "
|
2012-01-16 19:03:13 +01:00
|
|
|
$SRWL $SRWL_OPTS start $STARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
2008-12-09 17:50:17 +01:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# stop the firewall
|
2009-03-09 02:05:53 +01:00
|
|
|
shorewall6_stop () {
|
|
|
|
echo -n "Stopping \"Shorewall6 Lite 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-09 17:50:17 +01:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# restart the firewall
|
2009-03-09 02:05:53 +01:00
|
|
|
shorewall6_restart () {
|
2008-12-10 01:33:55 +01:00
|
|
|
echo -n "Restarting \"Shorewall6 Lite firewall\": "
|
2012-01-16 19:03:13 +01:00
|
|
|
$SRWL $SRWL_OPTS restart $RESTARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
2008-12-09 17:50:17 +01:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# refresh the firewall
|
2009-03-09 02:05:53 +01:00
|
|
|
shorewall6_refresh () {
|
2008-12-10 01:33:55 +01:00
|
|
|
echo -n "Refreshing \"Shorewall6 Lite firewall\": "
|
2008-12-09 17:50:17 +01:00
|
|
|
$SRWL $SRWL_OPTS refresh >> $INITLOG 2>&1 && echo "done." || echo_notdone
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2011-11-02 00:55:02 +01:00
|
|
|
# status of the firewall
|
|
|
|
shorewall6_status () {
|
|
|
|
$SRWL $SRWL_OPTS status && exit 0 || exit $?
|
|
|
|
}
|
|
|
|
|
2008-12-09 17:50:17 +01:00
|
|
|
case "$1" in
|
|
|
|
start)
|
2009-03-09 02:05:53 +01:00
|
|
|
shorewall6_start
|
2008-12-09 17:50:17 +01:00
|
|
|
;;
|
|
|
|
stop)
|
2009-03-09 02:05:53 +01:00
|
|
|
shorewall6_stop
|
2008-12-09 17:50:17 +01:00
|
|
|
;;
|
|
|
|
refresh)
|
2009-03-09 02:05:53 +01:00
|
|
|
shorewall6_refresh
|
2008-12-09 17:50:17 +01:00
|
|
|
;;
|
|
|
|
force-reload|restart)
|
2009-03-09 02:05:53 +01:00
|
|
|
shorewall6_restart
|
2008-12-09 17:50:17 +01:00
|
|
|
;;
|
2011-11-02 00:55:02 +01:00
|
|
|
status)
|
|
|
|
shorewall6_status
|
|
|
|
;;
|
2008-12-09 17:50:17 +01:00
|
|
|
*)
|
2011-11-02 00:55:02 +01:00
|
|
|
echo "Usage: /etc/init.d/shorewall6-lite {start|stop|refresh|restart|force-reload|status}"
|
2008-12-09 17:50:17 +01:00
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|