2011-04-27 16:03:46 +02:00
|
|
|
#! @shell@ -e
|
|
|
|
|
2011-04-27 16:10:03 +02:00
|
|
|
# !!! use a proper Upstart job.
|
|
|
|
|
2011-04-27 16:03:46 +02:00
|
|
|
# Make sure that the environment is deterministic.
|
|
|
|
export PATH=@coreutils@/bin
|
|
|
|
export PATH=@coreutils@/bin:@gnugrep@/bin:@gnused@/bin:@iputils@/bin:@iputils@/sbin:@procps@/bin:@seccure@/bin
|
|
|
|
export BASEDIR=$(dirname $(dirname $0))
|
|
|
|
|
|
|
|
mkdir /tmp/.gw6c || true
|
|
|
|
touch /tmp/.gw6c/gw6c.conf
|
|
|
|
chmod 0700 /tmp/.gw6c
|
|
|
|
chmod 0700 /tmp/.gw6c/gw6c.conf
|
|
|
|
seccure-decrypt -F @privkey@ -i $BASEDIR/conf/gw6c.conf > /tmp/.gw6c/gw6c.conf
|
|
|
|
|
|
|
|
stop ()
|
|
|
|
{
|
|
|
|
pkill gw6c
|
|
|
|
}
|
|
|
|
|
|
|
|
ln -s /dev/net/tun /dev/tun || true;
|
|
|
|
|
|
|
|
if test "$1" = "start"; then
|
|
|
|
trap 'stop ; exit ' 15
|
|
|
|
|
2012-01-18 21:34:04 +01:00
|
|
|
if test -n "@pingBefore@"; then while ! @iputils@/sbin/ping @gw6server@ -c1 -w1 ; do sleep 1; done; fi
|
2011-04-27 16:03:46 +02:00
|
|
|
cd /tmp/.gw6c
|
|
|
|
@coreutils@/bin/yes | \
|
|
|
|
env - HOME=/tmp/.gw6c $extraEnv \
|
|
|
|
@gw6c@/bin/gw6c -f /tmp/.gw6c/gw6c.conf 2>&1 >/var/log/gw6c.out
|
|
|
|
while @procps@/bin/pgrep gw6c; do
|
|
|
|
sleep @everPing@;
|
|
|
|
@iputils@/sbin/traceroute6 $( @coreutils@/bin/cat /var/log/gw6c.log |
|
|
|
|
@gnugrep@/bin/grep peer |
|
|
|
|
@gnused@/bin/sed -e 's/.*with //; s/ .*//' |
|
|
|
|
@coreutils@/bin/head -1) &
|
|
|
|
done;
|
|
|
|
pkill gw6c;
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$1" = "stop"; then
|
|
|
|
env - HOME=/homeless-shelter @procps@/bin/pkill gw6c;
|
|
|
|
fi;
|