LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-17-2005, 11:55 PM   #1
Notwerk
Member
 
Registered: Apr 2005
Location: Jordan
Distribution: Debian (Sarge), Ubuntu (6.06)
Posts: 271

Rep: Reputation: 31
Debian "Start-Stop-Daemon"


Hi,

I'm trying to edit a script i got at http://www.zmonkey.org/blog/node/28 which was written for debian to run on my fedora box. The script uses start-stop-daemon which is not available in fedora.

I check /etc/init.d/functions which defines a "daemon" but am still not sure how to change the script.

Any help would be appreciated since i need to get this done rather quickly.
 
Old 12-18-2005, 01:33 AM   #2
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
Typically you would put the daemon somewhere like /sbin. Then you have a script to launch it in /etc/rc.d/init.d. In the launcher script you will source the functions file and that way you just make a function call to launch your daemon. You can find templates for a launcher script with most distros, it might be called skeleton. Here is what a typical launcher script might look like, you will probably need to tweek it some.
NOTE: The functions status daemon and killproc are loaded from the /etc/rc.d/init.d/functions script.

Code:
#!/bin/bash
#
# Init file for mydaemon
#
#            
#        Run-Level Start Stop
#             vvvv   vv   vv
# chkconfig:  2345   99   25
#
# description: My daemon
#
# processname: mydaemon
# config: /etc/mydaemon.conf
# pidfile: /var/run/mydaemon.pid

# source function library
. /etc/rc.d/init.d/functions

# you may keep some variables in an external file 
# for easy access so pull in sysconfig settings
[ -f /etc/sysconfig/mydaemon ] && . /etc/sysconfig/mydaemon

# Some more variables to make the script readable
MYDAEMON=/sbin/mydaemon
PID_FILE=/var/run/mydaemon.pid
RETVAL=0
prog="mydaemon"


start()
{
	echo -n $"Starting $prog:"
	daemon $MYDAEMON && success || failure
	RETVAL=$?
	[ "$RETVAL" = 0 ] && touch /var/lock/subsys/mydaemon
	echo
}

stop()
{
	echo -n $"Stopping $prog:"
	killproc $MYDAEMON -TERM
	RETVAL=$?
	[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/mydaemon
	echo
}

reload()
{
	echo -n $"Reloading $prog:"
	killproc $MYDAEMON -HUP
	RETVAL=$?
	echo
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		stop
		start
		;;
	reload)
		reload
		;;
	status)
		status $MYDAEMON
		RETVAL=$?
		;;
	*)
		echo $"Usage: $0 {start|stop|restart|reload|status}"
		RETVAL=1
esac
exit $RETVAL
To make the launcher script run each time you boot do this:
chkconfig add mydaemon

HTH

Last edited by /bin/bash; 12-19-2005 at 03:15 AM.
 
Old 12-18-2005, 04:43 AM   #3
Notwerk
Member
 
Registered: Apr 2005
Location: Jordan
Distribution: Debian (Sarge), Ubuntu (6.06)
Posts: 271

Original Poster
Rep: Reputation: 31
Thanx /bin/bash

that example is great.
I got everything working now.

Last edited by Notwerk; 12-18-2005 at 05:00 AM.
 
Old 12-19-2005, 03:16 AM   #4
/bin/bash
Senior Member
 
Registered: Jul 2003
Location: Indiana
Distribution: Mandrake Slackware-current QNX4.25
Posts: 1,802

Rep: Reputation: 47
Glad to hear that.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
X Server broken. start w/ "INIT: ld "x" respawning too fast: disabled for 5 minutes&q tektone Linux - Hardware 5 07-25-2007 07:18 PM
Debian Boot Up Problem - stuck at "BR" & "I" jc70417 Debian 2 08-30-2005 04:36 PM
"mysqld ended" when trying to start mysql daemon guarriman Linux - General 1 01-19-2005 07:35 AM
How to start KDE automaticlly without typing "startx" then "startkde" Jonescity Slackware 8 10-29-2004 09:32 PM
"sar" and "iostat" equivalents on Debian? aditya_shah Debian 8 08-01-2004 11:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration