#!/bin/bash set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR x="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*} # directory of this file # see lan-dyn-dns-update. this is the corresponding script for on connect/disconnect from vpn d=/p/ovpn-ssh ssh_cmd="ssh -F$d/.config -i$d/home root@wrt.b8.nz cedit ovpn-$X509_0_CN /etc/hosts" case $script_type in client-connect) $ssh_cmd <<<"$ifconfig_pool_remote_ip $X509_0_CN"|| [[ $? == 1 ]] ;; client-disconnect) $ssh_cmd <<<$(grep -F $X509_0_CN lan-dns) || [[ $? == 1 ]] ;; esac