File: init.fedora.sh

package info (click to toggle)
shorewall 5.0.15.6-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,716 kB
  • ctags: 961
  • sloc: perl: 26,144; sh: 2,043; makefile: 50
file content (135 lines) | stat: -rwxr-xr-x 2,545 bytes parent folder | download
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/sh
#
# Shorewall init script
#
# chkconfig: - 28 90
# description: Packet filtering firewall

### BEGIN INIT INFO
# Provides: shorewall
# Required-Start: $local_fs $remote_fs $syslog $network
# Should-Start: VMware $time $named
# Required-Stop:
# Default-Start:
# Default-Stop:	  0 1 2 3 4 5 6
# Short-Description: Packet filtering firewall
# Description: The Shoreline Firewall, more commonly known as "Shorewall", is a
#              Netfilter (iptables) based firewall
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

#
# The installer may alter this
#
. /usr/share/shorewall/shorewallrc

prog="shorewall"
shorewall="${SBINDIR}/$prog"
logger="logger -i -t $prog"
lockfile="/var/lock/subsys/$prog"

# Get startup options (override default)
OPTIONS=

if [ -f ${SYSCONFDIR}/$prog ]; then
    . ${SYSCONFDIR}/$prog
fi

start() {
    echo -n $"Starting Shorewall: "
    $shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
    retval=${PIPESTATUS[0]}
    if [[ $retval == 0 ]]; then
	touch $lockfile
	success
    else
	failure
    fi
    echo
    return $retval
}

stop() {
    echo -n $"Stopping Shorewall: "
    $shorewall $OPTIONS stop 2>&1 | $logger
    retval=${PIPESTATUS[0]}
    if [[ $retval == 0 ]]; then
	rm -f $lockfile
	success
    else
	failure
    fi
    echo
    return $retval
}

reload() {
    echo -n $"Reloading Shorewall: "
    $shorewall $OPTIONS reload $RELOADOPTIONS 2>&1 | $logger
    retval=${PIPESTATUS[0]}
    if [[ $retval == 0 ]]; then
	touch $lockfile
	success
    else # Failed to start, clean up lock file if present
	rm -f $lockfile
	failure
    fi
    echo
    return $retval
}

restart() {
# Note that we don't simply stop and start since shorewall has a built in
# restart which stops the firewall if running and then starts it.
    echo -n $"Restarting Shorewall: "
    $shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
    retval=${PIPESTATUS[0]}
    if [[ $retval == 0 ]]; then
	touch $lockfile
	success
    else # Failed to start, clean up lock file if present
	rm -f $lockfile
	failure
    fi
    echo
    return $retval
}

status(){
    $shorewall status
    return $?
}

status_q() {
    status > /dev/null 2>&1
}

case "$1" in
    start)
	status_q && exit 0
	$1
	;;
    stop)
	status_q || exit 0
	$1
	;;
    reload|force-reload)
	reload
	;;
    restart)
	restart
	;;
    condrestart|try-restart)
        status_q || exit 0
        restart
        ;;
    status)
	$1
	;;
    *)
	echo "Usage: $0 start|stop|reload|restart|force-reload|status"
	exit 1
	;;
esac