packages/net/openconnect/files/openconnect-wrapper
Nikos Mavrogiannopoulos a412f2cc46 openconnect: forward SIGINT to app
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
2014-10-28 11:58:52 +01:00

41 lines
488 B
Bash
Executable file

#!/bin/sh
# This script wraps openconnect in order to obtain the password
# file from cmd.
# $1 password file
# $2... are passed to openconnect
test -z "$1" && exit 1
pwfile=$1
shift
pidfile=/var/run/ocwrap-$$.pid
cleanup()
{
if ! test -z "$pid";then
kill $pid
wait $pid
fi
exit 0
}
cleanup2()
{
if ! test -z "$pid";then
kill -2 $pid
wait $pid
fi
exit 0
}
trap cleanup2 2
trap cleanup 1 3 6 15
rm -f "$pidfile"
/usr/sbin/openconnect $* <$pwfile &
pid=$!
wait $pid