aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2007-11-29 18:27:04 +0000
committerAndreas Steffen <andreas.steffen@strongswan.org>2007-11-29 18:27:04 +0000
commit89f112ff344cb1bbeab2fa8cf4dc1b9fb32553cb (patch)
treeb4d41f6d5c9c7897707a1ca762d71f52166fb113 /src
parent0b72091970d48a4b212e6f39a86044eaa6ffce80 (diff)
downloadstrongswan-89f112ff344cb1bbeab2fa8cf4dc1b9fb32553cb.tar.bz2
strongswan-89f112ff344cb1bbeab2fa8cf4dc1b9fb32553cb.tar.xz
some return code changes proposed by Marius Tomaschewski
Diffstat (limited to 'src')
-rwxr-xr-xsrc/ipsec/ipsec.in50
1 files changed, 35 insertions, 15 deletions
diff --git a/src/ipsec/ipsec.in b/src/ipsec/ipsec.in
index 3b7311651..54e40a465 100755
--- a/src/ipsec/ipsec.in
+++ b/src/ipsec/ipsec.in
@@ -160,23 +160,21 @@ ready)
fi
;;
reload)
+ rc=7
if [ -e $IPSEC_STARTER_PID ]
then
echo "Reloading strongSwan IPsec configuration..." >&2
- kill -s USR1 `cat $IPSEC_STARTER_PID`
- exit 0
+ kill -s USR1 `cat $IPSEC_STARTER_PID` 2>/dev/null && rc=0
else
echo "ipsec starter is not running" >&2
- exit 7
fi
- exit 0
+ exit "$rc"
;;
restart)
$IPSEC_SBINDIR/ipsec stop
sleep 2
shift
- $IPSEC_SBINDIR/ipsec start "$@"
- exit 0
+ exec $IPSEC_SBINDIR/ipsec start "$@"
;;
route|unroute)
op="$1"
@@ -230,44 +228,66 @@ start)
;;
status|statusall)
op="$1"
- rc=7
+ # Return value is slightly different for the status command:
+ # 0 - service up and running
+ # 1 - service dead, but /var/run/ pid file exists
+ # 2 - service dead, but /var/lock/ lock file exists
+ # 3 - service not running (unused)
+ # 4 - service status unknown :-(
+ # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
shift
if [ $# -eq 0 ]
then
if [ -e $IPSEC_PLUTO_PID ]
then
$IPSEC_WHACK "--$op"
- rc="$?"
fi
if [ -e $IPSEC_CHARON_PID ]
then
$IPSEC_STROKE "$op"
- rc="$?"
fi
else
if [ -e $IPSEC_PLUTO_PID ]
then
$IPSEC_WHACK --name "$1" "--$op"
- rc="$?"
fi
if [ -e $IPSEC_CHARON_PID ]
then
$IPSEC_STROKE "$op" "$1"
- rc="$?"
fi
fi
- exit "$rc"
+ if [ -e $IPSEC_STARTER_PID ]
+ then
+ kill -0 `cat $IPSEC_STARTER_PID` 2>/dev/null
+ exit $?
+ fi
+ exit 3
;;
stop)
+ # stopping a not-running service is considered as success
if [ -e $IPSEC_STARTER_PID ]
then
echo "Stopping strongSwan IPsec..." >&2
- kill `cat $IPSEC_STARTER_PID`
- exit 0
+ spid=`cat $IPSEC_STARTER_PID`
+ if [ -n "$spid" ]
+ then
+ kill $spid 2>/dev/null
+ loop=5
+ while [ $loop -gt 0 ] ; do
+ kill -s 0 $spid 2>/dev/null || break
+ sleep 1
+ loop=$(($loop - 1))
+ done
+ if [ $loop -eq 0 ]
+ then
+ kill -s KILL $spid 2>/dev/null
+ rm -f $IPSEC_STARTER_PID
+ fi
+ fi
else
echo "ipsec starter is not running" >&2
- exit 7
fi
+ exit 0
;;
up)
shift