File: firehol.init

package info (click to toggle)
firehol 3.1.7%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,768 kB
  • sloc: sh: 20,852; makefile: 827; perl: 554; sed: 12
file content (120 lines) | stat: -rw-r--r-- 2,896 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#! /bin/sh
### BEGIN INIT INFO
# Provides:          firehol
# Required-Start:    $network $remote_fs $syslog
# Required-Stop:     $network $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Description: Starts firehol firewall configuration
# short-description: firehol firewall configuration
### END INIT INFO

PATH=/bin:/usr/bin:/sbin:/usr/sbin
NAME=firehol
DESC="firewall"
SCRIPTNAME=/etc/init.d/$NAME

test -x /usr/sbin/firehol || exit 0

[ -r /etc/default/firehol ] && set -a && . /etc/default/firehol

# load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# include lsb functions
. /lib/lsb/init-functions

case "$START_FIREHOL" in
  NO|no)
    START_FIREHOL=NO
  ;;
  *)
    START_FIREHOL=YES
  ;;
esac

do_start () {
	# return
	#  0 000 if firewall has been handled
	#  1 001 if firewall could not be activated
	#  4 100 if FireHOL is disabled via /etc/default/firehol
	[ "$START_FIREHOL" = "NO"  ] && return 4
	/usr/sbin/firehol start "$@" > /dev/null 2>&1 || return 1
}

do_stop () {
	# return
	#  0 000 if firewall has been cleaned up properly
	#  1 001 otherwise
	/usr/sbin/firehol stop > /dev/null 2>&1 || return 1
}

do_condrestart () {
	# return
	#  0 000 if firewall has been handled
	#  1 001 if firewall could not be activated
	#  4 100 if FireHOL is disabled via /etc/default/firehol
	[ "$START_FIREHOL" = "NO"  ] && return 4
	/usr/sbin/firehol condrestart "$@" > /dev/null 2>&1 || return 1
}

COMMAND="$1"
[ "$COMMAND" ] && shift

case "$COMMAND" in
	start)
		[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
		do_start "$@"
		case "$?" in
			0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
			1) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
			4) [ "$VERBOSE" != no ] && { log_progress_msg "disabled, see /etc/default/firehol" ; log_end_msg 255 ; } ;;
		esac
	;;

	stop)
		[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
		do_stop
		case "$?" in
			0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
			1) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
		esac
	;;

	condrestart)
		log_daemon_msg "Conditionally restarting $DESC" "$NAME"
		do_condrestart "$@"
		case "$?" in
			0) log_end_msg 0 ;;
			1) log_end_msg 1 ; exit 1 ;;
			4) log_progress_msg "disabled, see /etc/default/firehol" ; log_end_msg 255 ; ;;
		esac
	;;

	restart|force-reload)
		log_daemon_msg "Restarting $DESC" "$NAME"
		do_start "$@"
		case "$?" in
			0) log_end_msg 0 ;;
			1) log_end_msg 1 ; exit 1 ;;
			4) log_progress_msg "disabled, see /etc/default/firehol" ; log_end_msg 255 ; ;;
		esac
	;;

	status)
		if [ "$START_FIREHOL" = "NO" ]; then
			log_warning_msg "$DESC $NAME disabled via /etc/default/firehol"
			exit 0
		else
			log_success_msg "$DESC $NAME enabled via /etc/default/firehol"
			exit 4
		fi
	;;

	*)
	echo "Usage: $SCRIPTNAME {start|stop|condrestart|restart|force-reload|status|helpme|wizard} [<args>]" >&2
	exit 3
	;;
esac

: