Event-Handler

I have problems starting my event command from services, so the service that runs without any problems triggers the event command

Command:
#!/bin/bash

while getopts “s:t:a:S:” opt; do
case $opt in
s)
servicestate=$OPTARG
;;
t)
servicestatetype=$OPTARG
;;
a)
serviceattempt=$OPTARG
;;
S)
service=$OPTARG
;;
esac
done

if ( [ -z $servicestate ] || [ -z $servicestatetype ] || [ -z $serviceattempt ] || [ -z $service>
echo “USAGE: $0 -s servicestate -z servicestatetype -a serviceattempt -S service”
exit 3;
else

Only restart on the third attempt of a critical event

if ( [ $servicestate == “CRITICAL” ] && [ $servicestatetype == “SOFT” ] && [ $serviceattempt →
sudo systemctl restart apache2.service
fi
fi

Service:
The service is set up as specified and should start the bash file restart_apache2