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
|
2013-12-05 09:41:13 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
2011-06-24 16:21:51 +00:00
|
|
|
|
|
|
|
# Read options from /etc/default
|
|
|
|
|
|
|
|
. /etc/default/tinc
|
|
|
|
|
2014-05-11 19:17:13 +00:00
|
|
|
# Set process limits
|
|
|
|
|
|
|
|
setlimits() {
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
parm=$1 ; shift
|
|
|
|
if [ -n "$1" -a "${1#-}" = "$1" ]; then
|
|
|
|
value=$1 ; shift
|
|
|
|
ulimit $parm $value
|
|
|
|
else
|
|
|
|
ulimit $parm
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
test -n "$LIMITS" && setlimits $LIMITS
|
|
|
|
|
2011-06-24 16:21:51 +00:00
|
|
|
# Read options from /etc/network/interfaces
|
|
|
|
|
|
|
|
[ -n "$IF_TINC_CONFIG" ] && EXTRA="$EXTRA -c $IF_TINC_CONFIG"
|
|
|
|
[ -n "$IF_TINC_DEBUG" ] && EXTRA="$EXTRA -d$IF_TINC_DEBUG"
|
|
|
|
[ -n "$IF_TINC_MLOCK" ] && EXTRA="$EXTRA --mlock"
|
|
|
|
[ -n "$IF_TINC_LOGFILE" ] && EXTRA="$EXTRA --logfile=$IF_TINC_LOGFILE"
|
2012-12-28 19:49:04 +00:00
|
|
|
[ -n "$IF_TINC_PIDFILE" ] && EXTRA="$EXTRA --pidfile=$IF_TINC_PIDFILE" || IF_TINC_PIDFILE=/var/run/tinc.$IF_TINC_NET.pid
|
2011-06-24 16:21:51 +00:00
|
|
|
[ -n "$IF_TINC_CHROOT" ] && EXTRA="$EXTRA --chroot"
|
|
|
|
[ -n "$IF_TINC_USER" ] && EXTRA="$EXTRA --user=$IF_TINC_USER"
|
|
|
|
|
2012-12-28 19:49:04 +00:00
|
|
|
|
2011-06-24 16:21:51 +00:00
|
|
|
# Start tinc daemon
|
|
|
|
|
|
|
|
/usr/sbin/tincd -n "$IF_TINC_NET" -o "Interface=$IFACE" $EXTRA
|
|
|
|
|
|
|
|
# Wait for it to come up properly
|
|
|
|
|
|
|
|
sleep 0.1
|
|
|
|
i=0;
|
2015-07-05 15:23:08 +00:00
|
|
|
while [ ! -f $IF_TINC_PIDFILE ] ; do
|
|
|
|
if [ $i = '30' ] ; then
|
|
|
|
echo 'Failed to start tinc daemon!'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
sleep 0.1
|
|
|
|
i=$(($i+1))
|
|
|
|
done
|
|
|
|
|
|
|
|
while read pid rest < $IF_TINC_PIDFILE ; do
|
|
|
|
if [ -e "/proc/$pid" ] ; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2011-06-24 16:21:51 +00:00
|
|
|
if [ $i = '30' ] ; then
|
|
|
|
echo 'Failed to start tinc daemon!'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
sleep 0.1
|
|
|
|
i=$(($i+1))
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 0
|