#! /bin/bash action=$1 ; shift config=$1 ; shift retcode=0 if test -n "$config" ; then systemctl "${action}" "openvpn@${config}.service" || retcode=$? else case $action in status) n=0 l=`systemctl show -p ConsistsOf openvpn.target 2>/dev/null` for s in ${l#ConsistsOf=} ; do case $s in openvpn@*.service) systemctl status "$s" || retcode=$? ((++n)) ;; esac done if test $n -eq 0 ; then echo 'unused' >&2 exit 3 fi ;; *) systemctl "${action}" "openvpn.target" ;; esac fi exit $retcode