#!/bin/sh

# Check if process is running. If not start it
# Written by Georgi Chorbadzhiyski

PATH="/bin:/sbin:/usr/bin:/usr/sbin"

if [ $# -lt 2 ]; then
    echo "Usage: $0 process_name program_to_run"
    exit
fi

PRG="$1"
RUN="$2 $3 $4 $5 $6 $7 $8 $9"

if [ "0`pidof $PRG | cut -d' ' -f1`" -eq "0" ]; then
    echo "`cat /etc/HOSTNAME`: ${PRG} is dead! Running ${RUN}"
    exec ${RUN} &
fi

