Fedora Linux Support Community & Resources Center
  #1  
Old 10th December 2007, 01:45 AM
gkk Offline
Registered User
 
Join Date: Apr 2007
Posts: 24
Thumbs up chkconfig wokrs but service start says unknow service

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

Last edited by gkk; 10th December 2007 at 02:15 AM.
Reply With Quote
  #2  
Old 10th December 2007, 02:12 AM
PhillyFloyd Offline
Registered User
 
Join Date: Jun 2007
Location: Washington DC
Posts: 338
did you do a chkconfig --add for the service ;-)
__________________
"You're as useless as a jiffy in a tickless kernel."
Reply With Quote
  #3  
Old 10th December 2007, 02:13 AM
gkk Offline
Registered User
 
Join Date: Apr 2007
Posts: 24
I have solved the problem. The script was not as runnable. I've changed and now it works fine.
Reply With Quote
  #4  
Old 10th December 2007, 02:55 AM
marko Offline
Registered User
 
Join Date: Jun 2004
Location: Laurel, MD USA
Posts: 6,120
Notice that the service script you quoted will not work right with
chkconfig if the user does a:

chkconfig serviciogk on

because the top of the script didn't have the right formatting for
the runlevels (see the man page for chkconfig in the section
called RUNLEVEL FILES ). The start of the file should have something
like:

# chkconfig: 2345 20 80

So that if chkconfig serviciogk on is run, it will create the linkages in the
right places. In my example "on" would be runlevels 2,3,4,5 and start
priority index 20 and stop order index 80.

That might be ok if that's never going to
happen (ie chkconfig serviciogk on or chkconfig serviciogk off will
never be used) but it's a good idea in general.

Mark
Reply With Quote
  #5  
Old 10th December 2007, 03:45 AM
gkk Offline
Registered User
 
Join Date: Apr 2007
Posts: 24
Goog Information

Thank you Marko

I will check the man pages, and correct my script.
Reply With Quote
Reply

Tags
chkconfig, service, start, unknow, wokrs

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A service not in chkconfig neogranas Servers & Networking 3 16th July 2009 10:31 PM
chkconfig and service bghayad Using Fedora 4 19th June 2009 02:26 AM
service X does not support chkconfig arnieAustin Servers & Networking 9 10th January 2009 09:32 PM
The difference between service start and chkconfig kurtshi Servers & Networking 6 6th April 2008 05:11 AM
chkconfig and service RustyJuggler Using Fedora 10 3rd January 2006 04:00 PM


Current GMT-time: 09:59 (Sunday, 21-12-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
...Spider House, Diniwid Boracay Island Travel Photos - Sagi Travel Photos - Octane Coffee At Westin Travel Photos