Fedora Creation of Services

# Source function library.

# chkconfig: 345 105 15
# description:
# The above two lines are imp to put it in chkconfig

PID=`pidof service`

start() {

echo There is a service process already running: $PID
else
/Path to service/service > /dev/null &
echo `pidof service` > /usr/local/bin/servicepid
echo Starting : service `pidof service`
return
fi
}

stop() {
if [ $PID -le 0 ] ; then
echo -n "Shutting down : service "
kill -15 $PID
rm -rf /usr/local/bin/servicepid
sleep 5;
return

else
echo There is no service running.
fi
}

restart(){
stop()
start()
}

status(){
if [ $PID -le 0 ] ; then
echo There is no service running.
else
echo There is a service process already running: $PID
fi
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
retstatus
;;
*)
echo "Usage: {start|stop|restart|status}"
exit 1
;;
esac
exit 0

#Save this file in /etc/init.d/service_name and make executable
#Do a
# chkconfig --add servicename
# chkconfig --level 345 servicename on