I build a program that runs as a daemon, it works if I start it from command line.
But I want it to be running as a aservice.
I put binnarys in /usr/sbin
and a srcript to start it in /etc/init.d
chkconfig works, I can see my daemon in the list of services
but when I try service myservice start it says
service unknown
****************
I add this line here:
the problem was that the script was not an excecutable scripts.
****************
here is the script
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: serviciogk
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 4 5
# Short-Description: nothing
# Description: some_daemon is nothing.
# Really, nothing.
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
DAEMON_NAME=serviciogk
DAEMON_PROCESS=serviciogk
DAEMON_BINARY=/usr/sbin/serviciogk
LOCK_FILE=/var/lock/subsys/$DAEMON_NAME
RETVAL=0
# default option, they can be overriden in /etc/sysconfig/$DAEMON_NAME
# of course, you can place what you want.
#OPTIONS=
#PORT=2000
# this file should be commented, with proper pointer to the doc, and you should use
# more than one line of option, if possible.
#[ -f /etc/sysconfig/$DAEMON_NAME ] && . /etc/sysconfig/$DAEMON_NAME
# here, you can do what you want with the option
start() {
# place the test here
# if [ -z "$SOME_VAR" ]; then
# echo "You need to set $SOME_VAR in /etc/sysconfig/$DAEMON_NAME"
# RETVAL=1
# return
# fi
if [ ! -f $LOCK_FILE ]; then
echo "Starting $DAEMON_NAME"
# use --user to run the daemon under the specified uid
#daemon $DAEMON_BINARY $OPTIONS -p $PORT
daemon $DAEMON_BINARY $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
fi
}
stop() {
echo "Shutting down $DAEMON_NAME"
killproc $DAEMON_PROCESS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $LOCK_FILE
}
reload() {
echo "Reloading $DAEMON_NAME configuration"
killproc $DAEMON_PROCESS SIGHUP
RETVAL=$?
echo
}
status() {
status $DAEMON_PROCESS
RETVAL=$?
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
reload)
reload
;;
restart)
stop
start
;;
condrestart)
if [ -f $LOCK_FILE ]; then
stop
start
fi
;;
*)
echo "Usage: $0 {start|stop|restart|reload|condrestart|status}"
RETVAL=1
esac
exit $RETVAL