summaryrefslogtreecommitdiff
path: root/net/openconnect/files/openconnect-wrapper
blob: 744e5a5cd00ee22a24ea10623a07757abbd15f86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/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
}

trap cleanup 1 2 3 6 15

rm -f "$pidfile"
/usr/sbin/openconnect $* <$pwfile &
pid=$!

wait $pid