Created
September 25, 2021 13:39
-
-
Save caasi/d859edef6ed9912ac703a02210dc10e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
for ARG in $@; do | |
# extract service name and pid file path | |
NAME=`echo $ARG | cut -d":" -f1` | |
PID_PATH=`echo $ARG | cut -d":" -f2` | |
if [ "$NAME" = "$PID_PATH" ]; then | |
PID_PATH="$PID_PATH.pid" | |
fi | |
# check service status | |
CMD="service $NAME start" | |
if [ -f "/var/run/$PID_PATH" ]; then | |
PID=`cat /var/run/$PID_PATH` | |
if [ ! -d "/proc/$PID" ]; then | |
echo $CMD | |
$CMD | |
fi | |
else | |
echo $CMD | |
$CMD | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment