#!/bin/sh ### BEGIN INIT INFO # Provides: ufw # Required-Start: $local_fs # Required-Stop: $local_fs # Default-Start: S # Default-Stop: 1 # Short-Description: start firewall ### END INIT INFO set -e setvar PATH = ""/sbin:/bin"" test -d /lib/ufw || exit 0 source /lib/lsb/init-functions for s in ["/lib/ufw/ufw-init-functions" "/etc/ufw/ufw.conf" "/etc/default/ufw]" { if test -s $s { source "$s" } else { log_failure_msg "Could not find $s (aborting)" exit 1 } } setvar error = '0' match $1 { with start if test $ENABLED = "yes" || test $ENABLED = "YES" { log_action_begin_msg "Starting firewall:" "ufw" setvar output = $(ufw_start) || setvar error = ""$Status"" if test $error = "0" { log_action_cont_msg "Setting kernel variables ($IPT_SYSCTL)" } if test ! -z $output { echo $output | while read line { log_action_cont_msg $line } } } else { log_action_begin_msg "Skip starting firewall:" "ufw (not enabled)" } log_action_end_msg $error exit $error with stop if test $ENABLED = "yes" || test $ENABLED = "YES" { log_action_begin_msg "Stopping firewall:" "ufw" setvar output = $(ufw_stop) || setvar error = ""$Status"" if test ! -z $output { log_action_cont_msg $output } } else { log_action_begin_msg "Skip stopping firewall:" "ufw (not enabled)" } log_action_end_msg $error exit $error with restart|force-reload log_action_begin_msg "Reloading firewall:" "ufw" setvar output = $(ufw_reload) || setvar error = ""$Status"" if test ! -z $output { log_action_cont_msg $output } log_action_end_msg $error exit $error with status setvar output = $(ufw_status) || setvar error = ""$Status"" if test ! -z $output { log_action_cont_msg $output } log_action_end_msg $error exit $error with * echo "Usage: /etc/init.d/ufw {start|stop|restart|force-reload|status}" exit 1 } exit 0