1
0
Fork 0
This commit is contained in:
Arthur K. 2025-06-16 11:04:16 +03:00
parent ce19d6a62c
commit 624ab42f73
Signed by: wzray
GPG key ID: B97F30FDC4636357
26 changed files with 493 additions and 163 deletions

View file

@ -2,7 +2,7 @@
# shellcheck disable=SC2034
die() {
[ -n "$oc_pid" ] && kill -s TERM $oc_pid
[ -n "$oc_pid" ] && kill -s TERM "$oc_pid"
echo "exitting..."
rm -f $PIPE
exit 0
@ -25,6 +25,13 @@ done
COMMANDS=("up" "down" "status")
is_really_up() {
[ -n "$oc_pid" ] && if ! kill -0 "$oc_pid"; then
oc_pid=
up_name=
fi
}
in_arr() {
declare -n arr="$2"
@ -35,14 +42,16 @@ in_arr() {
}
down() {
is_really_up
[ -z "$oc_pid" ] && return
kill -s TERM $oc_pid
wait $oc_pid
kill -s TERM "$oc_pid"
wait "$oc_pid"
oc_pid=
up_name=
}
up() {
is_really_up
[ -n "$oc_pid" ] && down
openconnect --config "/etc/openconnect/config_$1" &
oc_pid="$!"
@ -50,11 +59,8 @@ up() {
}
status() {
# if [ -z "$up_name" ]; then
# echo "DOWN" > $PIPE
# else
# fi
echo "$up_name" > $PIPE
is_really_up
echo "$up_name" > $PIPE
}
main() {