[Gluster-devel] Init script
Christopher Hawkins
chawkins at veracitynetworks.com
Tue Aug 28 19:22:26 UTC 2007
cat /etc/redhat-release
CentOS release 4.5 (Final)
Yeah, no /lib/lsb on this one. Ahhh, I see it in yum, though. So it is
available, but not installed. What a PITA. :-0
Sadly, I think different scripts per distro would be best. You are correct
about debian's default files and redhat's sysconfig dir. Though many init
scripts check for all that, just as many don't... But hey, at least we now
have RHEL and Debian covered.
-----Original Message-----
From: chris.atlee at gmail.com [mailto:chris.atlee at gmail.com] On Behalf Of
Chris AtLee
Sent: Tuesday, August 28, 2007 2:53 PM
To: Christopher Hawkins
Cc: gluster-devel at nongnu.org
Subject: Re: [Gluster-devel] Init script
Weird, which version of RHEL? My RHEL4/5 machines have it (the
redhat-lsb package).
Maybe we need separate scripts per distribution anyway? Many debian
scripts of this sort have a corresponding file in /etc/default that
would indicate if the program was configured and allow you to specify
non-default command line arguments without editing the init.d script.
shorewall for example uses a variable in /etc/default/shorewall to
prevent it from starting up with the default configuration.
RedHat seems to prefer files in /etc/sysconfig for this sort of thing?
On 8/28/07, Christopher Hawkins <chawkins at bplinux.com> wrote:
> Hm. <scratching head> RHEL / Centos doesn't have
/lib/lsb/init-functions...
> It has /etc/init.d/functions, but the functions are all different anyway.
>
> Could modify the original script to test for /etc/debian_version file and
if
> found, use the "logger" command instead of initlog. Or I suppose the dev
> team (does the installation routine already already test to figure out
what
> distro is running?) could just have the install script install one or the
> other based on distro, but then you have two scripts to maintain. What do
> you think? Also, what issues do you have with the way kill is implemented?
I
> ask because I would like to fix that too, if possible, so I can use this
> script on all my boxes.
>
> Chris
>
> -----Original Message-----
> From: chris.atlee at gmail.com [mailto:chris.atlee at gmail.com] On Behalf Of
> Chris AtLee
> Sent: Tuesday, August 28, 2007 2:08 PM
> To: Anand Avati
> Cc: Christopher Hawkins; gluster-devel at nongnu.org
> Subject: Re: [Gluster-devel] Init script
>
> On my (debian) system, the 'initlog' command doesn't exist, so this
> script prints out a lot of errors, and there are some issues with how
> 'kill' works.
>
> init.d scripts are pretty hard to get working across multiple
> distributions. The best way I know of is to only rely on commands in
> /lib/lsb/init-functions.
>
> The attached script runs cleanly on my system.
>
> On 8/7/07, Anand Avati <avati at zresearch.com> wrote:
> > committed the script under extras/init.d/glusterfsd. Thanks a bunch!
> >
> > avati
> >
> > 2007/8/3, Christopher Hawkins <chawkins at veracitynetworks.com>:
> > >
> > > > Subject: Re: [Gluster-devel] Updated debian patch
> > > >
> > > >
> > > > > Chris,
> > > > > any patches you would want us to apply to the codebase (init.d
> > > > > script?) which might make your life easier?
> > > >
> > > > Absolutly. A well maintained init.d script in the code base
> > > > would be fantastic, and then usable on any system, not just debian.
> > > >
> > > >
> > > >
> > > > Thanx Matt.
> > >
> > > Hi guys,
> > >
> > > Here's an init script I put together that should work on any system,
> > > though
> > > I have only tried it so far on Centos. It's self contained... doesn't
> use
> > > any init functions in the hope that it will portable across distro's.
So
> > > far
> > > it's been good to me and I was going to post it anyway, so I guess now
> is
> > > the time! It's not fancy, doesn't check mounts or anything like that,
> but
> > > it
> > > seems to work well and reliably.
> > >
> > > PS - I am not a developer by any stretch of the imagination, so in the
> > > event
> > > that my scripting is ugly in the eyes of a real coder, have a laugh at
> my
> > > expense but please fix it and re-post. ;-) And thanks from all of us
> to
> > > the gluster team for all the great work. This is a fantastic project!
> > >
> > > #!/bin/bash
> > > #
> > > # chkconfig: 35 90 12
> > > # description: Glusterfsd server
> > > #
> > >
> > > # Get function from functions library
> > > # . /etc/rc.d/init.d/functions
> > >
> > > BASE=glusterfsd
> > > GSERVER="/sbin/$BASE -f /etc/glusterfs/glusterfs-server.vol"
> > >
> > > # A function to stop gluster
> > > killgluster()
> > > {
> > > killlevel="-9"
> > > # Find pid.
> > > pid=
> > > if [ -f /var/run/$BASE.pid ]; then
> > > local line p
> > > read line < /var/run/$BASE.pid
> > > for p in $line ; do
> > > [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] &&
> > > pid="$pid
> > > $p"
> > > done
> > > fi
> > > if [ -z "$pid" ]; then
> > > pid=`pidof -o $$ -o $PPID -o %PPID -x $1 || \
> > > pidof -o $$ -o $PPID -o %PPID -x $BASE`
> > > fi
> > > # Kill it.
> > > kill $killlevel $pid
> > > if [ "$?" = 0 ]
> > > then
> > > echo "Gluster process $pid has been killed"
> > > initlog -n "Kill gluster" -e 1
> > > else
> > > echo "Failed: Gluster process $pid has not been killed"
> > > initlog -n "Kill gluster" -e 2
> > > fi
> > >
> > > # Remove pid and lock file if any.
> > > if [ -f /var/run/$BASE.pid ]
> > > then
> > > rm -f /var/run/$BASE.pid && initlog -n "Remove
$BASE.pid:"
> > > -e
> > > 1
> > > else echo "$BASE.pid not found" && initlog -n "Remove
> > > $BASE.pid:" -e 2
> > > fi
> > >
> > > if [ -f /var/lock/subsys/$BASE ]
> > > then
> > > rm -f /var/lock/subsys/$BASE && initlog -n "Remove $BASE
> > > lock
> > > file:" -e 1
> > > else echo "$BASE lock file not found" && initlog -n
"Remove
> > > $BASE lock file:" -e 2
> > > fi
> > > }
> > >
> > > # Start the service $BASE
> > > start()
> > > {
> > > initlog -c "echo -n Starting $BASE:"
> > > $GSERVER
> > > if [ $? = 0 ]
> > > then
> > > touch /var/lock/subsys/$BASE
> > > initlog -n "Starting $BASE" -e 1
> > > echo " [OK]"
> > > else
> > > echo "$BASE start failed."
> > > initlog -n "$BASE start" -e 2
> > > fi
> > > }
> > >
> > > # Stop the service $BASE
> > > stop()
> > > {
> > > echo "Stopping $BASE:"
> > > killgluster
> > > }
> > > status()
> > > {
> > > if test "`lsof |grep -c /sbin/$BASE`" = "0"
> > > then echo "$BASE is stopped."
> > > else echo "$BASE is running..."
> > > fi
> > > }
> > >
> > > ### service arguments ###
> > > case $1 in
> > > start)
> > > start
> > > ;;
> > > stop)
> > > stop
> > > ;;
> > > status)
> > > status
> > > ;;
> > > restart|reload|condrestart)
> > > stop
> > > start
> > > ;;
> > > *)
> > > echo $.Usage: $0 {start|stop|restart|reload|status}.
> > > exit 1
> > > esac
> > >
> > > exit 0
> > >
> > >
> > >
> > > _______________________________________________
> > > Gluster-devel mailing list
> > > Gluster-devel at nongnu.org
> > > http://lists.nongnu.org/mailman/listinfo/gluster-devel
> > >
> >
> >
> >
> > --
> > It always takes longer than you expect, even when you take into account
> > Hofstadter's Law.
> >
> > -- Hofstadter's Law
> > _______________________________________________
> > Gluster-devel mailing list
> > Gluster-devel at nongnu.org
> > http://lists.nongnu.org/mailman/listinfo/gluster-devel
> >
>
>
More information about the Gluster-devel
mailing list