diff --git a/firestarter b/firestarter index e4f80b5..8438f3d 100755 --- a/firestarter +++ b/firestarter @@ -227,6 +227,34 @@ fsstatus() { printf "$errorline\n" fi fi + # Service information + if [ -d "$_optrundir" ]; then + for pidfile in "$_optrundir"/*.pid; do + local name="$(basename -- "$pidfile" .pid)" + local pid="$(< "$pidfile")" + local len=16 + local status + local description + if [ -z "$pid" ]; then + # PID is empty + status="\e[31m○\e[0m" + description="No PID" + elif ! [ "$pid" -gt 0 ] 2> /dev/null; then + # PID is not a number greater than 0 + status="\e[31m○\e[0m" + description="Invalid PID ($pid)" + elif ! [ -d "/proc/$pid" ]; then + # PID is valid, but does not exist in /proc (i.e. is dead) + status="\e[31m●\e[0m" + description="Dead (PID $pid)" + else + # PID is good, time for secondary validation + status="\e[32m●\e[0m" + description="Running (PID $pid)" + fi + printf "\t$status %-${len}.${len}s $description\n" "$name" + done + fi } step_preexecute() { # Special things that can't use simple configuration files