diff --git a/check_vpn.sh b/check_vpn.sh index 8720c33..cad2980 100755 --- a/check_vpn.sh +++ b/check_vpn.sh @@ -2,9 +2,11 @@ check_string_ps="" if [[ -f "/usr/sbin/openvpn" ]] ; then - check_string_ps="/usr/sbin/openvpn --daemon" + check_string_ps="/usr/sbin/openvpn" fi +check_string_ps_plus="--daemon" + # - used, if systemd is NOT supported init_script="" @@ -123,7 +125,7 @@ if $LOGGING ; then echo -e " =====================================" fi -PID=$(ps -e f | grep -E "[[:digit:]]\ ${check_string_ps}"| grep -v grep | awk '{print$2}') +PID=$(ps -e f | grep -E "[[:digit:]]\ ${check_string_ps}" | grep "\ ${check_string_ps_plus}\ " | grep -v grep | awk '{print$2}') if [[ "X${PID}" = "X" ]]; then error "OpenVPN Service seems to be down! Trying to restart service now.." @@ -151,10 +153,10 @@ if [[ "X${PID}" = "X" ]]; then fi declare -i counter=0 - PID=$(ps -e f | grep -E "[[:digit:]]\ ${check_string_ps}"| grep -v grep | awk '{print$2}') + PID=$(ps -e f | grep -E "[[:digit:]]\ ${check_string_ps}" | grep "\ ${check_string_ps_plus}\ " | grep -v grep | awk '{print$2}') while [[ "X${PID}" = "X" ]]; do sleep 1 - PID=$(ps -e f | grep -E "[[:digit:]]\ ${check_string_ps}"| grep -v grep | awk '{print$2}') + PID=$(ps -e f | grep -E "[[:digit:]]\ ${check_string_ps}" | grep "\ ${check_string_ps_plus}\ " | grep -v grep | awk '{print$2}') if [[ $counter -gt 10 ]]; then break else