From bd5c92a6491ccf6814f4000898b6792a270e19dd Mon Sep 17 00:00:00 2001 From: Eduard Toloza Date: Sat, 23 Feb 2019 22:05:40 -0500 Subject: [PATCH] Make test before trying to stop the openvpn service --- system-bin/randomvpn | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/system-bin/randomvpn b/system-bin/randomvpn index b45215a..0128bf2 100755 --- a/system-bin/randomvpn +++ b/system-bin/randomvpn @@ -4,18 +4,20 @@ # Example: hk-04.conf workdir="/etc/openvpn/client/" +isopenvpn=$(command -v openvpn > /dev/null) +issystemd=$(command -v systemctl > /dev/null) if [ $UID -ne 0 ]; then echo "You need root privileges." exit fi -if [ "$1" == "stop" ]; then +if $isopenvpn && $issystemd && [ "$1" == "stop" ]; then systemctl stop openvpn-client@* exit fi -if command -v openvpn > /dev/null && command -v systemctl > /dev/null; then +if $isopenvpn && $issystemd; then if [ -d "$workdir" ]; then cd "$workdir" vpn=$(shuf -ezn 1 * | xargs -0 -n1)