#!/bin/sh
#
# strongswan	An implementation of key management system for IPsec.
#
# chkconfig: - 55 10
# description: strongswan is an IPSEC implementation

### BEGIN INIT INFO
# Provides: ipsec
# Required-Start: $network $remote_fs $syslog $named
# Required-Stop: $syslog $remote_fs
# Default-Start:
# Default-Stop: 0 1 6
# Short-Description: Start Strongswan daemons at boot time
### END INIT INFO

WITHOUT_RC_COMPAT=1

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

# Source networking configuration.
SourceIfNotEmpty /etc/sysconfig/network

# Source service configuration.
IPSEC=/usr/sbin/strongswan
PIDFILE=/run/starter.pid
RETVAL=0

start()
{
	is_yes "$NETWORKING" || return 0

	$IPSEC start
	RETVAL=$?
	return $RETVAL
}

stop()
{
	$IPSEC stop
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart|reload)
		restart
		;;
	condstop)
		if [ -e "$PIDFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$PIDFILE" ]; then
			restart
		fi
		;;
	status)
		$IPSEC status 
		RETVAL=$?
		;;
	*)
		msg_usage "${0##*/} {start|stop|restart|condstop|condrestart|status}"
		RETVAL=1
esac

exit $RETVAL
