various fixes and mail improvements
[distro-setup] / vpn-client-connect
1 #!/bin/bash
2
3 set -eE -o pipefail
4 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
5
6 x="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*} # directory of this file
7
8 # see lan-dyn-dns-update. this is the corresponding script for on connect/disconnect from vpn
9
10 d=/p/ovpn-ssh
11 ssh_cmd="ssh -F$d/.config -i$d/home root@wrt.b8.nz cedit ovpn-$X509_0_CN /etc/hosts"
12 case $script_type in
13 client-connect) $ssh_cmd <<<"$ifconfig_pool_remote_ip $X509_0_CN"|| [[ $? == 1 ]]
14 ;;
15 client-disconnect)
16 $ssh_cmd <<<$(grep -F $X509_0_CN lan-dns) || [[ $? == 1 ]]
17 ;;
18 esac