From e4bd13efcfc4cdd1f056ad085b867fd9a2a99b38 Mon Sep 17 00:00:00 2001 From: Eduard Toloza Date: Sat, 23 Feb 2019 22:16:26 -0500 Subject: [PATCH] Avoid lazy arguments, multiple OpenVPN clients running at time and optimize syntax. --- system-bin/randomvpn | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/system-bin/randomvpn b/system-bin/randomvpn index 0128bf2..73abfe5 100755 --- a/system-bin/randomvpn +++ b/system-bin/randomvpn @@ -12,12 +12,17 @@ if [ $UID -ne 0 ]; then exit fi -if $isopenvpn && $issystemd && [ "$1" == "stop" ]; then - systemctl stop openvpn-client@* +if [ ! -z $isopenvpn ] || [ ! -z $issystemd ]; then + echo "OpenVPN or systemd not installed, exiting." exit fi -if $isopenvpn && $issystemd; then +if [ "$1" == "stop" ]; then + systemctl stop openvpn-client@* + exit + +elif [ "$1" == "start" ]; then + systemctl stop openvpn-client@* if [ -d "$workdir" ]; then cd "$workdir" vpn=$(shuf -ezn 1 * | xargs -0 -n1) @@ -34,6 +39,6 @@ if $isopenvpn && $issystemd; then exit fi else - echo "OpenVPN or systemd not installed, exiting." + echo -e "Usage:\n $0 start - start a random OpenVPN client. \n $0 stop - stop the initialized OpenVPN client." exit fi