Skip to content

Instantly share code, notes, and snippets.

@caasi
Created September 25, 2021 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caasi/d859edef6ed9912ac703a02210dc10e6 to your computer and use it in GitHub Desktop.
Save caasi/d859edef6ed9912ac703a02210dc10e6 to your computer and use it in GitHub Desktop.
#!/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