diff options
Diffstat (limited to 'extras/init.d')
| -rw-r--r-- | extras/init.d/Makefile.am | 33 | ||||
| -rw-r--r-- | extras/init.d/glusterd-FreeBSD.in | 24 | ||||
| -rwxr-xr-x | extras/init.d/glusterd-Redhat.in | 130 | ||||
| -rwxr-xr-x | extras/init.d/glusterd-SuSE.in | 10 | ||||
| -rw-r--r-- | extras/init.d/glusterd.plist.in | 2 | ||||
| -rw-r--r-- | extras/init.d/glustereventsd-Debian.in | 91 | ||||
| -rw-r--r-- | extras/init.d/glustereventsd-FreeBSD.in | 19 | ||||
| -rw-r--r-- | extras/init.d/glustereventsd-Redhat.in | 129 |
8 files changed, 395 insertions, 43 deletions
diff --git a/extras/init.d/Makefile.am b/extras/init.d/Makefile.am index 66715f4314a..8d8cc69571a 100644 --- a/extras/init.d/Makefile.am +++ b/extras/init.d/Makefile.am @@ -1,19 +1,32 @@ -EXTRA_DIST = glusterd-Debian glusterd-Redhat glusterd-SuSE glusterd.plist +EXTRA_DIST = glusterd-Debian glusterd-FreeBSD glusterd-Redhat \ + glusterd-SuSE glusterd.plist glustereventsd-FreeBSD \ + glustereventsd-Redhat glustereventsd-Debian -CLEANFILES = +CLEANFILES = -initdir = @initdir@ -launchddir = @launchddir@ +INIT_DIR = @initdir@ +SYSTEMD_DIR = @systemddir@ +LAUNCHD_DIR = @launchddir@ -$(GF_DISTRIBUTION): - $(mkdir_p) $(DESTDIR)$(initdir) - $(INSTALL_PROGRAM) glusterd-$(GF_DISTRIBUTION) $(DESTDIR)$(initdir)/glusterd +$(GF_DISTRIBUTION): +if WITH_SERVER + @if [ ! -d $(SYSTEMD_DIR) ]; then \ + $(mkdir_p) $(DESTDIR)$(INIT_DIR); \ + $(INSTALL_PROGRAM) glusterd-$(GF_DISTRIBUTION) $(DESTDIR)$(INIT_DIR)/glusterd; \ + fi +endif +if BUILD_EVENTS + @if [ ! -d $(SYSTEMD_DIR) ]; then \ + $(mkdir_p) $(DESTDIR)$(INIT_DIR); \ + $(INSTALL_PROGRAM) glustereventsd-$(GF_DISTRIBUTION) $(DESTDIR)$(INIT_DIR)/glustereventsd; \ + fi +endif install-exec-local: $(GF_DISTRIBUTION) -install-data-local: +install-data-local: if GF_DARWIN_HOST_OS - $(mkdir_p) $(DESTDIR)$(launchddir) - $(INSTALL_PROGRAM) glusterd.plist $(DESTDIR)$(launchddir)/com.gluster.glusterd.plist + $(mkdir_p) $(DESTDIR)$(LAUNCHD_DIR) + $(INSTALL_PROGRAM) glusterd.plist $(DESTDIR)$(LAUNCHD_DIR)/org.gluster.glusterd.plist endif diff --git a/extras/init.d/glusterd-FreeBSD.in b/extras/init.d/glusterd-FreeBSD.in new file mode 100644 index 00000000000..21c3da72624 --- /dev/null +++ b/extras/init.d/glusterd-FreeBSD.in @@ -0,0 +1,24 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: glusterd + +. /etc/rc.subr + +name="glusterd" +rcvar=`set_rcvar` +command=@prefix@/sbin/${name} +pidfile="/var/run/${name}.pid" +glusterd_flags="-p /var/run/${name}.pid" +start_precmd="glusterd_prestart" + +glusterd_prestart() +{ + mkdir -p @GLUSTERD_WORKDIR@ /var/log/glusterfs + return 0 +} + +load_rc_config $name +run_rc_command "$1" diff --git a/extras/init.d/glusterd-Redhat.in b/extras/init.d/glusterd-Redhat.in index 01a3009470e..94801fe31a5 100755 --- a/extras/init.d/glusterd-Redhat.in +++ b/extras/init.d/glusterd-Redhat.in @@ -1,71 +1,143 @@ #!/bin/bash # -# chkconfig: 35 20 80 -# description: Gluster File System service for volume management +# glusterd Startup script for the glusterfs server # +# chkconfig: - 20 80 +# description: Clustered file-system server -# Get function from functions library +### BEGIN INIT INFO +# Provides: glusterd +# Required-Start: $local_fs $network +# Required-Stop: $local_fs $network +# Should-Start: +# Should-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: glusterfs server +# Description: Clustered file-system server +### END INIT INFO +# + +# Source function library. . /etc/rc.d/init.d/functions BASE=glusterd + +# Fedora File System Layout dictates /run +[ -e /run ] && RUNDIR="/run" +PIDFILE="${RUNDIR:-/var/run}/${BASE}.pid" + +PID=`test -f $PIDFILE && cat $PIDFILE` + +# Overwriteable from sysconfig +LOG_LEVEL='' +LOG_FILE='' +GLUSTERD_OPTIONS='' +GLUSTERD_NOFILE='65536' + +[ -f /etc/sysconfig/${BASE} ] && . /etc/sysconfig/${BASE} + +[ ! -z $LOG_LEVEL ] && GLUSTERD_OPTIONS="${GLUSTERD_OPTIONS} --log-level ${LOG_LEVEL}" +[ ! -z $LOG_FILE ] && GLUSTERD_OPTIONS="${GLUSTERD_OPTIONS} --log-file ${LOG_FILE}" + GLUSTERFSD=glusterfsd GLUSTERFS=glusterfs GLUSTERD_BIN=@prefix@/sbin/$BASE -GLUSTERD_OPTS="" +GLUSTERD_OPTS="--pid-file=$PIDFILE ${GLUSTERD_OPTIONS}" GLUSTERD="$GLUSTERD_BIN $GLUSTERD_OPTS" RETVAL=0 +LOCKFILE=/var/lock/subsys/${BASE} + # Start the service $BASE start() { - echo -n $"Starting $BASE:" - daemon $GLUSTERD - RETVAL=$? - echo - [ $RETVAL -ne 0 ] && exit $RETVAL + if pidofproc -p $PIDFILE $GLUSTERD_BIN &> /dev/null; then + echo "glusterd service is already running with pid $PID" + return 0 + else + ulimit -n $GLUSTERD_NOFILE + echo -n $"Starting $BASE:" + daemon $GLUSTERD + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && touch $LOCKFILE + return $RETVAL + fi } # Stop the service $BASE stop() { echo -n $"Stopping $BASE:" - killproc $BASE + if pidofproc -p $PIDFILE $GLUSTERD_BIN &> /dev/null; then + killproc -p $PIDFILE $BASE + else + killproc $BASE + fi + RETVAL=$? echo - pidof -c -o %PPID -x $GLUSTERFSD &> /dev/null - [ $? -eq 0 ] && killproc $GLUSTERFSD &> /dev/null + [ $RETVAL -eq 0 ] && rm -f $LOCKFILE + return $RETVAL +} - #pidof -c -o %PPID -x $GLUSTERFS &> /dev/null - #[ $? -eq 0 ] && killproc $GLUSTERFS &> /dev/null +restart() +{ + stop + start +} - if [ -f /etc/glusterd/nfs/run/nfs.pid ] ;then - pid=`cat /etc/glusterd/nfs/run/nfs.pid`; - cmd=`ps -p $pid -o comm=` +reload() +{ + restart +} - if [ $cmd == "glusterfs" ]; then - kill `cat /etc/glusterd/nfs/run/nfs.pid` - fi - fi +force_reload() +{ + restart +} + +rh_status() +{ + status $BASE +} + +rh_status_q() +{ + rh_status &>/dev/null } ### service arguments ### case $1 in start) - start + rh_status_q && exit 0 + $1 ;; stop) - stop + rh_status_q || exit 0 + $1 + ;; + restart) + $1 + ;; + reload) + rh_status_q || exit 7 + $1 + ;; + force-reload) + force_reload ;; status) - status $BASE + rh_status ;; - restart) - $0 stop - $0 start + condrestart|try-restart) + rh_status_q || exit 0 + restart ;; *) - echo $"Usage: $0 {start|stop|status|restart}." + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" exit 1 esac -exit 0 +exit $? diff --git a/extras/init.d/glusterd-SuSE.in b/extras/init.d/glusterd-SuSE.in index 16cf8de6a13..6259bab00b6 100755 --- a/extras/init.d/glusterd-SuSE.in +++ b/extras/init.d/glusterd-SuSE.in @@ -2,8 +2,8 @@ # ### BEGIN INIT INFO # Provides: glusterd -# Required-Start: $local_fs $network -# Required-Stop: +# Required-Start: $remote_fs $network +# Required-Stop: $remote_fs $network # Default-Start: 3 5 # Default-Stop: # Short-Description: Gluster File System service for volume management @@ -61,13 +61,17 @@ case $1 in fi rc_status -v ;; + reload) + rc_failed 3 + rc_status -v + ;; restart) $0 stop $0 start rc_status ;; *) - echo $"Usage: $0 {start|stop|status|restart}." + echo $"Usage: $0 {start|stop|status|reload|restart}." exit 1 esac diff --git a/extras/init.d/glusterd.plist.in b/extras/init.d/glusterd.plist.in index 7385fa486df..3ee9f60c5c5 100644 --- a/extras/init.d/glusterd.plist.in +++ b/extras/init.d/glusterd.plist.in @@ -3,7 +3,7 @@ <plist version="1.0"> <dict> <key>Label</key> - <string>com.gluster.glusterd</string> + <string>org.gluster.glusterd</string> <key>ProgramArguments</key> <array> <string>@prefix@/sbin/glusterd</string> diff --git a/extras/init.d/glustereventsd-Debian.in b/extras/init.d/glustereventsd-Debian.in new file mode 100644 index 00000000000..6eebdb2b8d8 --- /dev/null +++ b/extras/init.d/glustereventsd-Debian.in @@ -0,0 +1,91 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: glustereventsd +# Required-Start: $local_fs $network +# Required-Stop: $local_fs $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Gluster Events Server +# Description: Gluster Events Server +### END INIT INFO + +# Author: Chris AtLee <chris@atlee.ca> +# Patched by: Matthias Albert < matthias@linux4experts.de> + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +NAME=glustereventsd +SCRIPTNAME=/etc/init.d/$NAME +DAEMON=@prefix@/sbin/$NAME +PIDFILE=/var/run/$NAME.pid +GLUSTEREVENTSD_OPTS="" +PID=`test -f $PIDFILE && cat $PIDFILE` + + +# Gracefully exit if the package has been removed. +test -x $DAEMON || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +. /lib/lsb/init-functions + + +do_start() +{ + pidofproc -p $PIDFILE $DAEMON >/dev/null + status=$? + if [ $status -eq 0 ]; then + log_success_msg "glustereventsd service is already running with pid $PID" + else + log_daemon_msg "Starting glustereventsd service" "glustereventsd" + start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- -p $PIDFILE $GLUSTEREVENTSD_OPTS + log_end_msg $? + start_daemon -p $PIDFILE $DAEMON -f $CONFIGFILE + return $? + fi +} + +do_stop() +{ + log_daemon_msg "Stopping glustereventsd service" "glustereventsd" + start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE + log_end_msg $? + rm -f $PIDFILE + killproc -p $PIDFILE $DAEMON + return $? +} + +do_status() +{ + pidofproc -p $PIDFILE $DAEMON >/dev/null + status=$? + if [ $status -eq 0 ]; then + log_success_msg "glustereventsd service is running with pid $PID" + else + log_failure_msg "glustereventsd service is not running." + fi + exit $status +} + +case "$1" in + start) + do_start + ;; + stop) + do_stop + ;; + status) + do_status; + ;; + restart|force-reload) + do_stop + sleep 2 + do_start + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + diff --git a/extras/init.d/glustereventsd-FreeBSD.in b/extras/init.d/glustereventsd-FreeBSD.in new file mode 100644 index 00000000000..2e8303ec6c6 --- /dev/null +++ b/extras/init.d/glustereventsd-FreeBSD.in @@ -0,0 +1,19 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: glustereventsd + +. /etc/rc.subr + +name="glustereventsd" +rcvar=`set_rcvar` +command=@prefix@/sbin/${name} +command_interpreter=/usr/local/bin/python +pidfile="/var/run/${name}.pid" +glustereventsd_flags="-p /var/run/${name}.pid" +start_cmd="/usr/sbin/daemon $command ${glustereventsd_flags}" + +load_rc_config $name +run_rc_command "$1" diff --git a/extras/init.d/glustereventsd-Redhat.in b/extras/init.d/glustereventsd-Redhat.in new file mode 100644 index 00000000000..d23ce4c244f --- /dev/null +++ b/extras/init.d/glustereventsd-Redhat.in @@ -0,0 +1,129 @@ +#!/bin/bash +# +# glustereventsd Startup script for the glusterfs Events server +# +# chkconfig: - 20 80 +# description: Gluster Events Server + +### BEGIN INIT INFO +# Provides: glustereventsd +# Required-Start: $local_fs $network +# Required-Stop: $local_fs $network +# Should-Start: +# Should-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: glusterfs Events server +# Description: GlusterFS Events Server +### END INIT INFO +# + +# Source function library. +. /etc/rc.d/init.d/functions + +BASE=glustereventsd + +# Fedora File System Layout dictates /run +[ -e /run ] && RUNDIR="/run" +PIDFILE="${RUNDIR:-/var/run}/${BASE}.pid" + +PID=`test -f $PIDFILE && cat $PIDFILE` + +GLUSTEREVENTSD_BIN=@prefix@/sbin/$BASE +GLUSTEREVENTSD_OPTS="--pid-file=$PIDFILE" +GLUSTEREVENTSD="$GLUSTEREVENTSD_BIN $GLUSTEREVENTSD_OPTS" +RETVAL=0 + +LOCKFILE=/var/lock/subsys/${BASE} + +# Start the service $BASE +start() +{ + if pidofproc -p $PIDFILE $GLUSTEREVENTSD_BIN &> /dev/null; then + echo "glustereventsd service is already running with pid $PID" + return 0 + else + echo -n $"Starting $BASE:" + daemon $GLUSTEREVENTSD & + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && touch $LOCKFILE + return $RETVAL + fi +} + +# Stop the service $BASE +stop() +{ + echo -n $"Stopping $BASE:" + if pidofproc -p $PIDFILE $GLUSTEREVENTSD_BIN &> /dev/null; then + killproc -p $PIDFILE $BASE + else + killproc $BASE + fi + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && rm -f $LOCKFILE + return $RETVAL +} + +restart() +{ + stop + start +} + +reload() +{ + restart +} + +force_reload() +{ + restart +} + +rh_status() +{ + status $BASE +} + +rh_status_q() +{ + rh_status &>/dev/null +} + + +### service arguments ### +case $1 in + start) + rh_status_q && exit 0 + $1 + ;; + stop) + rh_status_q || exit 0 + $1 + ;; + restart) + $1 + ;; + reload) + rh_status_q || exit 7 + $1 + ;; + force-reload) + force_reload + ;; + status) + rh_status + ;; + condrestart|try-restart) + rh_status_q || exit 0 + restart + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" + exit 1 +esac + +exit $? |
