2011-06-24 16:21:51 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2016-10-10 20:30:25 +00:00
|
|
|
if [ "$METHOD" = loopback -o -z "$IF_TINC_NET" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Determine location of the PID file
|
|
|
|
|
|
|
|
EXTRA=""
|
|
|
|
if [ -n "$IF_TINC_PIDFILE" ]; then
|
|
|
|
EXTRA="--pidfile=$IF_TINC_PIDFILE"
|
|
|
|
else
|
|
|
|
IF_TINC_PIDFILE=/var/run/tinc.$IF_TINC_NET.pid
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Stop the tinc daemon
|
|
|
|
|
2017-09-05 18:23:36 +00:00
|
|
|
read pid rest < $IF_TINC_PIDFILE 2>/dev/null
|
|
|
|
|
2016-10-10 20:30:25 +00:00
|
|
|
/usr/sbin/tincd -n "$IF_TINC_NET" -k $EXTRA
|
|
|
|
|
|
|
|
# Wait for it to shut down properly
|
|
|
|
|
2017-09-05 18:23:36 +00:00
|
|
|
/bin/sleep 0.1
|
2016-10-10 20:30:25 +00:00
|
|
|
i=0;
|
2017-09-05 18:23:36 +00:00
|
|
|
while [ -f $IF_TINC_PIDFILE ] ; do
|
2016-10-10 20:30:25 +00:00
|
|
|
if [ ! -e "/proc/$pid" ] ; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $i = '30' ] ; then
|
|
|
|
echo 'Failed to stop tinc daemon!'
|
|
|
|
exit 1
|
2013-12-05 09:41:13 +00:00
|
|
|
fi
|
2017-09-05 18:23:36 +00:00
|
|
|
/bin/sleep 0.1
|
2016-10-10 20:30:25 +00:00
|
|
|
i=$(($i+1))
|
|
|
|
done
|
2011-06-24 16:21:51 +00:00
|
|
|
|
|
|
|
exit 0
|