Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 - 1
#!/bin/sh
2
#
3
# Shorewall init script
4
#
5
# chkconfig: - 28 90
6
# description: Packet filtering firewall
7
 
8
### BEGIN INIT INFO
9
# Provides: shorewall
10
# Required-Start: $local_fs $remote_fs $syslog $network
11
# Should-Start: VMware $time $named
12
# Required-Stop:
13
# Default-Start:
14
# Default-Stop:	  0 1 2 3 4 5 6
15
# Short-Description: Packet filtering firewall
16
# Description: The Shoreline Firewall, more commonly known as "Shorewall", is a
17
#              Netfilter (iptables) based firewall
18
### END INIT INFO
19
 
20
# Source function library.
21
. /etc/rc.d/init.d/functions
22
 
23
#
24
# The installer may alter this
25
#
26
. /usr/share/shorewall/shorewallrc
27
 
28
prog="shorewall"
29
shorewall="${SBINDIR}/$prog"
30
logger="logger -i -t $prog"
31
lockfile="/var/lock/subsys/$prog"
32
 
33
# Get startup options (override default)
34
OPTIONS=
35
 
36
if [ -f ${SYSCONFDIR}/$prog ]; then
37
    . ${SYSCONFDIR}/$prog
38
fi
39
 
40
start() {
41
    echo -n $"Starting Shorewall: "
42
    $shorewall $OPTIONS start 2>&1 | $logger
43
    retval=${PIPESTATUS[0]}
44
    if [[ $retval == 0 ]]; then
45
	touch $lockfile
46
	success
47
    else
48
	failure
49
    fi
50
    echo
51
    return $retval
52
}
53
 
54
stop() {
55
    echo -n $"Stopping Shorewall: "
56
    $shorewall $OPTIONS stop 2>&1 | $logger
57
    retval=${PIPESTATUS[0]}
58
    if [[ $retval == 0 ]]; then
59
	rm -f $lockfile
60
	success
61
    else
62
	failure
63
    fi
64
    echo
65
    return $retval
66
}
67
 
68
restart() {
69
# Note that we don't simply stop and start since shorewall has a built in
70
# restart which stops the firewall if running and then starts it.
71
    echo -n $"Restarting Shorewall: "
72
    $shorewall $OPTIONS restart 2>&1 | $logger
73
    retval=${PIPESTATUS[0]}
74
    if [[ $retval == 0 ]]; then
75
	touch $lockfile
76
	success
77
    else # Failed to start, clean up lock file if present
78
	rm -f $lockfile
79
	failure
80
    fi
81
    echo
82
    return $retval
83
}
84
 
85
status(){
86
    $shorewall status
87
    return $?
88
}
89
 
90
status_q() {
91
    status > /dev/null 2>&1
92
}
93
 
94
case "$1" in
95
    start)
96
	status_q && exit 0
97
	$1
98
	;;
99
    stop)
100
	status_q || exit 0
101
	$1
102
	;;
103
    restart|reload|force-reload)
104
	restart
105
	;;
106
    condrestart|try-restart)
107
        status_q || exit 0
108
        restart
109
        ;;
110
    status)
111
	$1
112
	;;
113
    *)
114
	echo "Usage: $0 start|stop|reload|restart|force-reload|status"
115
	exit 1
116
	;;
117
esac