diff options
author | Vikas Gorur <vikas@zresearch.com> | 2009-02-18 17:36:07 +0530 |
---|---|---|
committer | Vikas Gorur <vikas@zresearch.com> | 2009-02-18 17:36:07 +0530 |
commit | 77adf4cd648dce41f89469dd185deec6b6b53a0b (patch) | |
tree | 02e155a5753b398ee572b45793f889b538efab6b /extras/init.d | |
parent | f3b2e6580e5663292ee113c741343c8a43ee133f (diff) |
Added all files
Diffstat (limited to 'extras/init.d')
-rw-r--r-- | extras/init.d/Makefile.am | 9 | ||||
-rwxr-xr-x | extras/init.d/glusterfs-server | 100 | ||||
-rw-r--r-- | extras/init.d/glusterfs-server.plist.in | 15 | ||||
-rwxr-xr-x | extras/init.d/glusterfsd | 110 |
4 files changed, 234 insertions, 0 deletions
diff --git a/extras/init.d/Makefile.am b/extras/init.d/Makefile.am new file mode 100644 index 00000000000..608b5bb2d4d --- /dev/null +++ b/extras/init.d/Makefile.am @@ -0,0 +1,9 @@ + +EXTRA_DIST = glusterfsd glusterfs-server glusterfs-server.plist + +CLEANFILES = + +install-data-am: +if GF_DARWIN_HOST_OS + cp glusterfs-server.plist /Library/LaunchDaemons/com.zresearch.glusterfs.plist +endif diff --git a/extras/init.d/glusterfs-server b/extras/init.d/glusterfs-server new file mode 100755 index 00000000000..975283982b2 --- /dev/null +++ b/extras/init.d/glusterfs-server @@ -0,0 +1,100 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: glusterfsd +# Required-Start: $local_fs $network +# Required-Stop: $local_fs $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: gluster server +# Description: This file starts / stops the gluster 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=glusterfsd +SCRIPTNAME=/etc/init.d/$NAME +DAEMON=/usr/sbin/$NAME +PIDFILE=/var/run/$NAME.pid +CONFIGFILE=/etc/glusterfs/server.vol +GLUSTERFS_OPTS="-f $CONFIGFILE" +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 + +check_config() +{ + if [ ! -f "$CONFIGFILE" ]; then + echo "Config file $CONFIGFILE is missing...exiting!" + exit 0 + fi +} + +do_start() +{ + check_config; + pidofproc -p $PIDFILE $DAEMON >/dev/null + status=$? + if [ $status -eq 0 ]; then + log_success_msg "glusterfs server is already running with pid $PID" + else + log_daemon_msg "Starting glusterfs server" "glusterfsd" + start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- -p $PIDFILE $GLUSTERFS_OPTS + log_end_msg $? + start_daemon -p $PIDFILE $DAEMON -f $CONFIGFILE + return $? + fi +} + +do_stop() +{ + log_daemon_msg "Stopping glusterfs server" "glusterfsd" + 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 "glusterfs server is running with pid $PID" + else + log_failure_msg "glusterfs server 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/glusterfs-server.plist.in b/extras/init.d/glusterfs-server.plist.in new file mode 100644 index 00000000000..4d2287c5759 --- /dev/null +++ b/extras/init.d/glusterfs-server.plist.in @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>Label</key> + <string>com.zresearch.glusterfs</string> + <key>ProgramArguments</key> + <array> + <string>@prefix@/sbin/glusterfsd</string> + <string>-N</string> + <string>-f</string> + <string>@prefix@/etc/glusterfs/server.vol</string> + </array> +</dict> +</plist> diff --git a/extras/init.d/glusterfsd b/extras/init.d/glusterfsd new file mode 100755 index 00000000000..866a0010e9a --- /dev/null +++ b/extras/init.d/glusterfsd @@ -0,0 +1,110 @@ +#!/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 |