Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
init.d functions [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
digitalmasters
n00b
n00b


Joined: 04 Sep 2006
Posts: 30

PostPosted: Wed Dec 06, 2006 3:46 am    Post subject: init.d functions [SOLVED] Reply with quote

I'm trying to use a script someone wrote to start a service. They use Mandrake and have the script at the end of this message.

Searching the internet I came up with: Mandrake.../etc/init.d/functions General purpose functions used by every system script

Does Gentoo have anything like this? What do I need to do? How do I setup Gentoo to start a service?




#! /bin/bash
#
# freeb Start/Stop the freeb daemon.
#
# chkconfig: 345 92 8
# description: freeb is an insurance billing printing daemon that \
# works with the OpenEMR medical record software program
# processname: freeb
# pidfile: /var/run/freeb.pid
#
# Above pidfile will NOT be made
#
# Date: 3/23/2006
# Author: Brady Miller email:brady@sparmy.com
#
# This is a very alpha version. Use at your own risk.
# I am not responsible for any bad things that happen.

# Source function library.
. /etc/init.d/functions

# Source the /etc/default/freeb file if it exist.
#if [ -f /etc/default/freeb ]; then
# . /etc/default/freeb
# fi

# Some defaults
freeb="/usr/share/freeb/bin/FreeB_Server.pl"
prog="freeb"
RETVAL=0


start() {
gprintf "Starting %s: " "$prog"
#daemon command not working with '&', some binary error
#so will just run without daemon command, should be fine,
#A pid file will not be made
$freeb & < /dev/null
echo " [homemade OK]"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/freeb
return $RETVAL
}

stop() {
gprintf "Stopping %s: " "$prog"
killproc $freeb
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/freeb
return $RETVAL
}

rhstatus() {
status $freeb
}

restart() {
stop
start
}


case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
rhstatus
;;
*)
gprintf "Usage: %s {start|stop|restart}\n" "$0"
exit 1
esac

exit $?
_________________
The Ultimate Answer to Life, the Universe, and Everything is 42.
The computer said "I think the problem, to be quite honest with you, is that you've never actually known what the question is."


Last edited by digitalmasters on Sat Dec 09, 2006 9:36 am; edited 1 time in total
Back to top
View user's profile Send private message
desultory
Bodhisattva
Bodhisattva


Joined: 04 Nov 2005
Posts: 9410

PostPosted: Wed Dec 06, 2006 7:08 am    Post subject: Reply with quote

digitalmasters wrote:
I'm trying to use a script someone wrote to start a service. They use Mandrake and have the script at the end of this message.
Due to differing initialization models, Mandrake startup scripts are not to be expected to function as intended when executed under Gentoo.
digitalmasters wrote:
Searching the internet I came up with: Mandrake.../etc/init.d/functions General purpose functions used by every system script
Perhaps a link would be in order.
digitalmasters wrote:
Does Gentoo have anything like this?
It might be analogous to /etc/init.d/functions.sh.
digitalmasters wrote:
What do I need to do?
Insufficient data is provided to determine a complete answer to this query.
digitalmasters wrote:
How do I setup Gentoo to start a service?
Code:
rc-update add $service $runlevel


Try the following, untested, script at your own risk.
Code:
#!/sbin/runscript
#
# freeb          Start/Stop the freeb daemon.
#
# freeb is an insurance billing printing daemon that works with
# the OpenEMR medical record software program

FREEB="/usr/share/freeb/bin/FreeB_Server.pl"
PIDFILE="/var/run/freeb.pid"

start() {
   ebegin "Starting freeb: "
   start-stop-deamon --start --quiet --pidfile $PIDFILE -exec $FREEB
   RETVAL=$?
   [ $RETVAL -eq 0 ] && touch /var/lock/subsys/freeb
   eend $RETVAL
}

stop() {
   ebegin "Stopping freeb: "
   start-stop-deamon --start --quiet --pidfile $PIDFILE -exec $FREEB
   RETVAL=$?
   [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/freeb
   eend $RETVAL
}   

reload() {
   ebegin "Reloading freeb: "
   [ -f /var/lock/subsys/freeb ] && stop
   [ ! -f /var/lock/subsys/freeb ] && start
   eend $?
}


Perhaps you should consult the bbcode FAQ, regarding posting source code.

Note that, at some point, it would likely be advisable to produce an ebuild to install the package and allow portage to handle updates.

Edit: changed type of conditionals in the reload function.


Last edited by desultory on Thu Dec 07, 2006 12:56 am; edited 1 time in total
Back to top
View user's profile Send private message
thorpe
l33t
l33t


Joined: 09 May 2005
Posts: 618
Location: Sydney, Australia.

PostPosted: Wed Dec 06, 2006 10:39 am    Post subject: Reply with quote

The initscripts guide may be of interest to you.
_________________
Research before taking any advice from me. I'm still coming to grips with this myself.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum