openconnect: forward SIGINT to app
[feed/packages.git] / net / openconnect / files / openconnect-wrapper
1 #!/bin/sh
2
3 # This script wraps openconnect in order to obtain the password
4 # file from cmd.
5
6 # $1 password file
7 # $2... are passed to openconnect
8
9 test -z "$1" && exit 1
10
11 pwfile=$1
12 shift
13
14 pidfile=/var/run/ocwrap-$$.pid
15
16 cleanup()
17 {
18 if ! test -z "$pid";then
19 kill $pid
20 wait $pid
21 fi
22 exit 0
23 }
24
25 cleanup2()
26 {
27 if ! test -z "$pid";then
28 kill -2 $pid
29 wait $pid
30 fi
31 exit 0
32 }
33
34 trap cleanup2 2
35 trap cleanup 1 3 6 15
36
37 rm -f "$pidfile"
38 /usr/sbin/openconnect $* <$pwfile &
39 pid=$!
40
41 wait $pid