]>
Commit | Line | Data |
---|---|---|
44a8700b | 1 | #!/bin/sh |
2 | # | |
3 | # stunnel stunnel (Universal SSL tunnel) | |
4 | # | |
bc74d409 | 5 | # chkconfig: 345 14 91 |
44a8700b | 6 | # |
7 | # description: stunnel (Universal SSL tunnel) | |
8 | # | |
9 | # id: $Id$ | |
10 | # | |
11 | ||
12 | # Source function library | |
13 | . /etc/rc.d/init.d/functions | |
14 | ||
15 | # Get network config | |
16 | . /etc/sysconfig/network | |
17 | ||
18 | # Get service config | |
19 | [ -f /etc/sysconfig/stunnel ] && . /etc/sysconfig/stunnel | |
20 | ||
21 | # Check that networking is up. | |
8fe6017e | 22 | if is_yes "${NETWORKING}"; then |
bcc1e58c | 23 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then |
8fe6017e | 24 | msg_network_down stunnel |
25 | exit 1 | |
26 | fi | |
27 | else | |
28 | exit 0 | |
44a8700b | 29 | fi |
30 | ||
31 | # Daemon doesn't die if config doesn't exist | |
8fe6017e | 32 | if [ ! -f "$STUNNEL_CONFIG" ]; then |
33 | nls "%s config %s does not exist." Stunnel "$STUNNEL_CONFIG" | |
44a8700b | 34 | exit 1 |
35 | fi | |
36 | ||
04b8715c | 37 | start() { |
44a8700b | 38 | # Check if the service is already running? |
39 | if [ ! -f /var/lock/subsys/stunnel ]; then | |
40 | msg_starting stunnel; busy | |
41 | daemon stunnel $STUNNEL_CONFIG | |
42 | RETVAL=$? | |
8fe6017e | 43 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/stunnel |
44a8700b | 44 | else |
45 | msg_already_running stunnel | |
44a8700b | 46 | fi |
04b8715c ER |
47 | } |
48 | ||
49 | stop() { | |
8fe6017e | 50 | if [ -f /var/lock/subsys/stunnel ]; then |
44a8700b | 51 | msg_stopping stunnel |
52 | killproc stunnel | |
53 | rm -f /var/run/stunnel/stunnel.pid /var/lock/subsys/stunnel >/dev/null 2>&1 | |
54 | else | |
55 | msg_not_running stunnel | |
bc74d409 | 56 | fi |
04b8715c ER |
57 | } |
58 | ||
e7fc9f07 JB |
59 | condrestart() { |
60 | if [ -f /var/lock/subsys/stunnel ]; then | |
61 | stop | |
62 | start | |
63 | else | |
64 | msg_not_running stunnel | |
65 | RETVAL=$1 | |
66 | fi | |
67 | } | |
68 | ||
04b8715c ER |
69 | RETVAL=0 |
70 | # See how we were called. | |
71 | case "$1" in | |
72 | start) | |
73 | start | |
74 | ;; | |
75 | stop) | |
76 | stop | |
44a8700b | 77 | ;; |
e7fc9f07 | 78 | restart) |
04b8715c ER |
79 | stop |
80 | start | |
8fe6017e | 81 | ;; |
e7fc9f07 JB |
82 | try-restart) |
83 | condrestart 0 | |
84 | ;; | |
85 | force-reload) | |
86 | condrestart 7 | |
87 | ;; | |
44a8700b | 88 | status) |
89 | status stunnel | |
90 | exit $? | |
91 | ;; | |
92 | *) | |
e7fc9f07 | 93 | msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" |
efeb3841 | 94 | exit 3 |
44a8700b | 95 | esac |
96 | ||
97 | exit $RETVAL |