1 1.1 manu #! /bin/sh 2 1.1 manu # Copyright (c) 2001-2002 SuSE GmbH Nuernberg, Germany. 3 1.1 manu # 4 1.1 manu # Author: Michal Ludvig <feedback (at] suse.de>, 2004 5 1.1 manu # 6 1.1 manu # /etc/init.d/ipsec-tools 7 1.1 manu # and its symbolic link 8 1.1 manu # /usr/sbin/rcipsec-tools 9 1.1 manu # 10 1.1 manu # System startup script for the IPsec key management daemon 11 1.1 manu # 12 1.1 manu ### BEGIN INIT INFO 13 1.1 manu # Provides: racoon 14 1.1 manu # Required-Start: $remote_fs $named $syslog 15 1.1 manu # Required-Stop: $remote_fs $named $syslog 16 1.1 manu # Default-Start: 3 5 17 1.1 manu # Default-Stop: 0 1 2 6 18 1.1 manu # Description: IPsec key management daemon 19 1.1 manu ### END INIT INFO 20 1.1 manu 21 1.1 manu SETKEY="IPsec policies" 22 1.1 manu SETKEY_BIN=/usr/sbin/setkey 23 1.1 manu SETKEY_CONF=/etc/racoon/setkey.conf 24 1.1 manu 25 1.1 manu RACOON="IPsec IKE daemon (racoon)" 26 1.1 manu RACOON_BIN=/usr/sbin/racoon 27 1.1 manu RACOON_CONF=/etc/racoon/racoon.conf 28 1.1 manu RACOON_PIDFILE=/var/run/racoon.pid 29 1.1 manu 30 1.1 manu test -x $SETKEY_BIN || exit 5 31 1.1 manu test -x $RACOON_BIN || exit 5 32 1.1 manu 33 1.1 manu test -f /etc/sysconfig/racoon && . /etc/sysconfig/racoon 34 1.1 manu 35 1.1 manu # Shell functions sourced from /etc/rc.status: 36 1.1 manu # rc_check check and set local and overall rc status 37 1.1 manu # rc_status check and set local and overall rc status 38 1.1 manu # rc_status -v ditto but be verbose in local rc status 39 1.1 manu # rc_status -v -r ditto and clear the local rc status 40 1.1 manu # rc_failed set local and overall rc status to failed 41 1.1 manu # rc_failed <num> set local and overall rc status to <num><num> 42 1.1 manu # rc_reset clear local rc status (overall remains) 43 1.1 manu # rc_exit exit appropriate to overall rc status 44 1.1 manu . /etc/rc.status 45 1.1 manu 46 1.1 manu # First reset status of this service 47 1.1 manu rc_reset 48 1.1 manu 49 1.1 manu # Return values acc. to LSB for all commands but status: 50 1.1 manu # 0 - success 51 1.1 manu # 1 - generic or unspecified error 52 1.1 manu # 2 - invalid or excess argument(s) 53 1.1 manu # 3 - unimplemented feature (e.g. "reload") 54 1.1 manu # 4 - insufficient privilege 55 1.1 manu # 5 - program is not installed 56 1.1 manu # 6 - program is not configured 57 1.1 manu # 7 - program is not running 58 1.1 manu # 59 1.1 manu # Note that starting an already running service, stopping 60 1.1 manu # or restarting a not-running service as well as the restart 61 1.1 manu # with force-reload (in case signalling is not supported) are 62 1.1 manu # considered a success. 63 1.1 manu 64 1.1 manu case "$1" in 65 1.1 manu start) 66 1.1 manu # Setting up SPD policies is not required. 67 1.1 manu if [ -f $SETKEY_CONF ]; then 68 1.1 manu echo -n "Setting up $SETKEY" 69 1.1 manu $SETKEY_BIN $SETKEY_OPTIONS -f $SETKEY_CONF 70 1.1 manu rc_status -v 71 1.1 manu rc_reset 72 1.1 manu fi 73 1.1 manu 74 1.1 manu echo -n "Starting $RACOON " 75 1.1 manu ## If there is no conf file, skip starting of ddtd 76 1.1 manu ## and return with "program not configured" 77 1.1 manu if ! [ -f $RACOON_CONF ]; then 78 1.1 manu echo -e -n "... no configuration file found" 79 1.1 manu rc_status -s 80 1.1 manu # service is not configured 81 1.1 manu rc_failed 6 82 1.1 manu rc_exit 83 1.1 manu fi 84 1.1 manu 85 1.1 manu # startproc should return 0, even if service is 86 1.1 manu # already running to match LSB spec. 87 1.1 manu startproc $RACOON_BIN $RACOON_OPTIONS -f $RACOON_CONF 88 1.1 manu rc_status -v 89 1.1 manu ;; 90 1.1 manu 91 1.1 manu stop) 92 1.1 manu echo -n "Shutting down $RACOON" 93 1.1 manu ## Stop daemon with killproc(8) and if this fails 94 1.1 manu ## set echo the echo return value. 95 1.1 manu 96 1.1 manu killproc -p $RACOON_PIDFILE -TERM $RACOON_BIN 97 1.1 manu 98 1.1 manu # Remember status and be verbose 99 1.1 manu rc_status -v 100 1.1 manu rc_reset 101 1.1 manu 102 1.1 manu # Flush SPD policies if required 103 1.1 manu if [ -n "$SETKEY_FLUSH_OPTIONS" ]; then 104 1.1 manu echo -n "Flushing $SETKEY" 105 1.1 manu $SETKEY_BIN $SETKEY_FLUSH_OPTIONS 106 1.1 manu rc_status -v 107 1.1 manu fi 108 1.1 manu ;; 109 1.1 manu try-restart) 110 1.1 manu ## Stop the service and if this succeeds (i.e. the 111 1.1 manu ## service was running before), start it again. 112 1.1 manu $0 stop && $0 start 113 1.1 manu 114 1.1 manu # Remember status and be quiet 115 1.1 manu rc_status 116 1.1 manu ;; 117 1.1 manu restart) 118 1.1 manu ## Stop the service and regardless of whether it was 119 1.1 manu ## running or not, start it again. 120 1.1 manu $0 stop 121 1.1 manu $0 start 122 1.1 manu 123 1.1 manu # Remember status and be quiet 124 1.1 manu rc_status 125 1.1 manu ;; 126 1.1 manu force-reload) 127 1.1 manu ## Signal the daemon to reload its config. Most daemons 128 1.1 manu ## do this on signal 1 (SIGHUP). 129 1.1 manu ## If it does not support it, restart. 130 1.1 manu 131 1.1 manu echo -n "Reload service $RACOON" 132 1.1 manu killproc -p $RACOON_PIDFILE -HUP $RACOON_BIN 133 1.1 manu rc_status -v 134 1.1 manu ;; 135 1.1 manu reload) 136 1.1 manu ## Like force-reload, but if daemon does not support 137 1.1 manu ## signalling, do nothing (!) 138 1.1 manu 139 1.1 manu echo -n "Reload service $RACOON" 140 1.1 manu killproc -p $RACOON_PIDFILE -HUP $RACOON_BIN 141 1.1 manu rc_status -v 142 1.1 manu ;; 143 1.1 manu status) 144 1.1 manu echo -n "Checking for $RACOON: " 145 1.1 manu ## Check status with checkproc(8), if process is running 146 1.1 manu ## checkproc will return with exit status 0. 147 1.1 manu 148 1.1 manu # Status has a slightly different for the status command: 149 1.1 manu # 0 - service running 150 1.1 manu # 1 - service dead, but /var/run/ pid file exists 151 1.1 manu # 2 - service dead, but /var/lock/ lock file exists 152 1.1 manu # 3 - service not running 153 1.1 manu 154 1.1 manu checkproc -p $RACOON_PIDFILE $RACOON_BIN 155 1.1 manu rc_status -v 156 1.1 manu ;; 157 1.1 manu probe) 158 1.1 manu ## Optional: Probe for the necessity of a reload, 159 1.1 manu ## give out the argument which is required for a reload. 160 1.1 manu 161 1.1 manu test "$RACOON_CONF" -nt "$RACOON_PIDFILE" && echo reload 162 1.1 manu ;; 163 1.1 manu *) 164 1.1 manu echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}" 165 1.1 manu exit 1 166 1.1 manu ;; 167 1.1 manu esac 168 1.1 manu rc_exit 169