diff options
Diffstat (limited to 'extras/init.d/glusterd-FbRedhat.in')
-rw-r--r-- | extras/init.d/glusterd-FbRedhat.in | 214 |
1 files changed, 214 insertions, 0 deletions
diff --git a/extras/init.d/glusterd-FbRedhat.in b/extras/init.d/glusterd-FbRedhat.in new file mode 100644 index 00000000000..18be537cb6b --- /dev/null +++ b/extras/init.d/glusterd-FbRedhat.in @@ -0,0 +1,214 @@ +#!/bin/bash +# +# Script to manage the various Gluster systemd services +# +# +# ** DO NOT INCLUDE /etc/rc.d/init.d/functions ** +# ** This will break all automation because of systemctl redirect ** +# + +. /etc/rc.d/init.d/glusterd.functions + +PATH="$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin" + +# BEGIN functions copied out of /etc/rc.d/init.d/functions +if [ -z "${BOOTUP:-}" ]; then + if [ -f /etc/sysconfig/init ]; then + . /etc/sysconfig/init + else + # This all seem confusing? Look in /etc/sysconfig/init, + # or in /usr/share/doc/initscripts-*/sysconfig.txt + BOOTUP=color + RES_COL=60 + MOVE_TO_COL="echo -en \\033[${RES_COL}G" + SETCOLOR_SUCCESS="echo -en \\033[1;32m" + SETCOLOR_FAILURE="echo -en \\033[1;31m" + SETCOLOR_WARNING="echo -en \\033[1;33m" + SETCOLOR_NORMAL="echo -en \\033[0;39m" + LOGLEVEL=1 + fi + if [ "$CONSOLETYPE" = "serial" ]; then + BOOTUP=serial + MOVE_TO_COL= + SETCOLOR_SUCCESS= + SETCOLOR_FAILURE= + SETCOLOR_WARNING= + SETCOLOR_NORMAL= + fi +fi + +success() { + [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_success + return 0 +} + +# Log that something failed +failure() { + local rc=$? + [ "$BOOTUP" != "verbose" -a -z "${LSB:-}" ] && echo_failure + [ -x /bin/plymouth ] && /bin/plymouth --details + return $rc +} + + +# Run some action. Log its output. +action() { + local STRING rc + + STRING=$1 + echo -n "$STRING " + shift + "$@" && success $"$STRING" || failure $"$STRING" + rc=$? + echo + return $rc +} + +echo_success() { + [ "$BOOTUP" = "color" ] && $MOVE_TO_COL + echo -n "[" + [ "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS + echo -n $" OK " + [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL + echo -n "]" + echo -ne "\r" + return 0 +} + +echo_failure() { + [ "$BOOTUP" = "color" ] && $MOVE_TO_COL + echo -n "[" + [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE + echo -n $"FAILED" + [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL + echo -n "]" + echo -ne "\r" + return 1 +} +# END copy from /etc/rc.d/init.d/functions + +_start_service() +{ + _service=$1 + _desc=$2 + [ -z "$_desc" ] && _desc=$_service + action "Starting $_desc..." /bin/systemctl start "$_service" +} + +_stop_service() +{ + _service=$1 + _desc=$2 + [ -z "$_desc" ] && _desc=$_service + action "Stopping $_desc..." /bin/systemctl stop "$_service" +} + +# SHD Management Functions +start_shd() +{ + _start_service glusterd-shd "self-heal daemon" +} + +stop_shd() +{ + _stop_service glusterd-shd "self-heal daemon" +} + +restart_shd() +{ + stop_shd + start_shd +} + +# NFSd Management Functions +start_nfsd() +{ + _start_service glusterd-nfsd "nfs daemon" +} + +stop_nfsd() +{ + _stop_service glusterd-nfsd "nfs daemon" +} + +restart_nfsd() +{ + stop_nfsd + start_nfsd +} + +# GFProxyd Management Functions +start_gfproxyd() +{ + _start_service glusterd-gfproxyd "gfproxy daemon" +} + +stop_gfproxyd() +{ + _stop_service glusterd-gfproxyd "gfproxy daemon" +} + +restart_gfproxyd() +{ + stop_gfproxyd + start_gfproxyd +} + +# mgmt daemon Management Functions +start_mgmt() +{ + _start_service glusterd-mgmt "mgmt daemon" +} + +stop_mgmt() +{ + _stop_service glusterd-mgmt "mgmt daemon" + pkill -f '^/usr/sbin/glusterd.*' +} + +restart_mgmt() +{ + stop_mgmt + start_mgmt +} + +start() +{ + start_mgmt + start_nfsd + start_shd + #start_gfproxyd +} + +stop() +{ + stop_mgmt + stop_nfsd + stop_shd + #stop_gfproxyd + # Stop the bricks, since they are not managed by systemd + pkill -f '^/usr/sbin/glusterfsd.*' +} + +restart() +{ + stop + start +} + +case $1 in + start) start ;; + start_nfsd) start_nfsd ;; + start_shd) start_shd ;; + stop) stop ;; + stop_nfsd) stop_nfsd ;; + stop_shd) stop_shd ;; + #stop_gfproxyd) stop_gfproxyd ;; + restart) restart;; + restart_nfsd) restart_nfsd ;; + restart_shd) restart_shd ;; + #restart_gfproxyd) restart_gfproxyd ;; + checkquorum) check_quorum ;; +esac + +exit 0 |