File openswan_30_rcscript.dif of Package openswan

--- programs/setup/setup.in
+++ programs/setup/setup.in	2008/09/04 18:55:27
@@ -30,6 +30,24 @@
 # description: IPsec provides encrypted and authenticated communications; \
 # KLIPS is the kernel half of it, Pluto is the user-level management daemon.
 
+### BEGIN INIT INFO
+# Provides: ipsec
+# Required-Start: $network $syslog $remote_fs $named
+# Required-Stop:  $network $syslog $remote_fs
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 2 6
+# Short-Description: Start openswan IPSec
+# Description: IPSEC provides encrypted and authenticated communications
+#       via a unsafe network, such as the internet (VPN).
+#       This scripts loads the kernel module and starts the
+#       user-space setup (pluto).
+### END INIT INFO
+
+. /etc/rc.status
+rc_reset
+return=$rc_done
+export rc_failed rc_done rc_running rc_unused rc_dead
+
 me='ipsec setup'		# for messages
 
 # where the private directory and the config files are
@@ -62,7 +80,7 @@ if ! test "$found"
 then
 	echo "cannot find ipsec command -- \`$1' aborted" |
 		logger -s -p daemon.error -t ipsec_setup
-	exit 1
+	test "$1" == "stop" && exit 0 || exit 5 # not installed
 fi
 
 # accept a few flags
@@ -90,7 +108,7 @@ variables=`ipsec addconn $config --varpr
 if [ $? != 0 ]
 then
     echo "Failed to parse config setup portion of ipsec.conf"
-    exit $?
+    test "$1" == "stop" && exit 0 || exit 6 # not configured
 fi
 eval $variables
 
@@ -99,11 +117,13 @@ then
     case $1 in 
     stop|--stop|_autostop) 
 	echo "$IPSEC_confreadstatus -- \`$1' may not work" |
-		logger -s -p daemon.error -t ipsec_setup;;
-		
+		logger -s -p daemon.error -t ipsec_setup
+	exit 0
+    ;;		
     *) echo "$IPSEC_confreadstatus -- \`$1' aborted" |
 	    logger -s -p daemon.error -t ipsec_setup;
-	exit 1;;
+	exit 1 # generic error
+    ;;
     esac
 fi
 
@@ -148,39 +168,55 @@ case "$1" in
 		cat ${outtmp} | logger -s -p $IPSECsyslog -t ipsec_setup 2>&1
 		rm -f ${outtmp}
 	fi
-	exit $st
+	rc_failed $st
+	rc_status -v
 	;;
 
   restart|--restart|force-reload)
 	$0 $IPSEC_setupflags stop
 	$0 $IPSEC_setupflags start
+	rc_status
+	;;
+
+  reload|--reload)
+  	rc_failed 3
+	rc_status -v
+	;;
+
+  try-restart|condrestart|force-reload)
+  	$0 status
+	if test $? = 0; then
+		$0 restart
+	else
+		rc_reset        # Not running is not a failure.
+	fi
+	rc_status
 	;;
 
   _autorestart)			# for internal use only
 	$0 $IPSEC_setupflags _autostop
 	$0 $IPSEC_setupflags _autostart
+	rc_status
 	;;
 
   status|--status)
 	ipsec _realsetup $1
-	exit
+	rc_status -v
 	;;
 
   --version)
 	echo "$me $IPSEC_VERSION"
-	exit 0
 	;;
 
   --help)
 	echo "Usage: $me [ --showonly ] {--start|--stop|--restart}"
 	echo "       $me --status"
-	exit 0
 	;;
 
   *)
 	echo "Usage: $me [ --showonly ] {--start|--stop|--restart}"
 	echo "       $me --status"
-	exit 2
+	rc_failed 2
 esac
 
-exit 0
+rc_exit
openSUSE Build Service is sponsored by