summaryrefslogtreecommitdiffstats
path: root/systemd
diff options
context:
space:
mode:
authorJi-Hyeon Gim <potatogim@gluesys.com>2017-09-09 13:35:25 +0900
committerJi-Hyeon Gim <potatogim@potatogim.net>2017-09-21 19:30:27 +0900
commitfeb517ae133fd4af0dc35725070e80522ea43539 (patch)
tree51aa21a538139b495de5cb2a0b60daa94f086654 /systemd
parent95db5c36b38fa883141cb3eeb237957d18091168 (diff)
dist: supports initd for non-systemd distros
Problem gluster-blockd supports systemd officially but many legacy distros want to use initd Resolve includes initd scripts for non-systemd distros Change-Id: I8495e8d9abbef6d26ac7dc8dbbe6d07e7713f537 Signed-off-by: Ji-Hyeon Gim <potatogim@gluesys.com>
Diffstat (limited to 'systemd')
-rw-r--r--systemd/Makefile.am13
-rw-r--r--systemd/gluster-blockd.initd.in142
2 files changed, 151 insertions, 4 deletions
diff --git a/systemd/Makefile.am b/systemd/Makefile.am
index e1545db..798b4a8 100644
--- a/systemd/Makefile.am
+++ b/systemd/Makefile.am
@@ -1,13 +1,18 @@
-DISTCLEANFILES = Makefile.in gluster-blockd.service gluster-block-target.service
+DISTCLEANFILES = Makefile.in gluster-blockd.service gluster-block-target.service \
+ gluster-blockd.initd
-CLEANFILES = *~ gluster-blockd.service gluster-block-target.service
+CLEANFILES = *~ gluster-blockd.service gluster-block-target.service \
+ gluster-blockd.initd
-EXTRA_DIST = gluster-blockd.service.in gluster-block-target.service.in \
- gluster-blockd.sysconfig
+EXTRA_DIST = gluster-blockd.service.in gluster-block-target.service.in \
+ gluster-blockd.initd.in gluster-blockd.sysconfig
if USE_SYSTEMD
# systemddir is already defined through configure.ac
systemd_DATA = gluster-blockd.service gluster-block-target.service
+else
+# initddir is already defined through configure.ac
+initd_DATA = gluster-blockd.initd
endif
install-data-local:
diff --git a/systemd/gluster-blockd.initd.in b/systemd/gluster-blockd.initd.in
new file mode 100644
index 0000000..39fb256
--- /dev/null
+++ b/systemd/gluster-blockd.initd.in
@@ -0,0 +1,142 @@
+#!/bin/bash
+#
+# gluster-blockd Startup script for the gluster-blockd server
+#
+# chkconfig: - 20 80
+# description: GlusterFS block server
+
+### BEGIN INIT INFO
+# Provides: gluster-block
+# 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 block server
+# Description: GlusterFS block server
+### END INIT INFO
+#
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+BASE=gluster-blockd
+
+# 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
+GB_GLFS_LRU_COUNT=5
+GB_LOG_LEVEL='INFO'
+GB_EXTRA_ARGS=""
+GB_NOFILE='65536'
+
+[ -f /etc/sysconfig/${BASE} ] && . /etc/sysconfig/${BASE}
+
+[ ! -z $GB_LOG_LEVEL ] && GB_OPTIONS="${GB_OPTIONS} --log-level ${GB_LOG_LEVEL}"
+[ ! -z $GB_GLFS_LRU_COUNT ] && GB_OPTIONS="${GB_OPTIONS} --glfs-lru-count ${GB_GLFS_LRU_COUNT}"
+[ ! -z $GB_EXTRA_ARGS ] && GB_OPTIONS="${GB_OPTIONS} ${GB_EXTRA_ARGS}"
+
+GBD_BIN=@prefix@/sbin/$BASE
+GBD_OPTS="${GB_OPTIONS}"
+GBD="$GBD_BIN $GBD_OPTS"
+RETVAL=0
+
+LOCKFILE=/var/lock/subsys/${BASE}
+
+# Start the service $BASE
+start()
+{
+ if pidofproc -p $PIDFILE $GBD_BIN &> /dev/null; then
+ echo "gluster-blockd service is already running with pid $PID"
+ return 0
+ else
+ ulimit -n $GB_NOFILE
+ echo -n $"Starting $BASE:"
+ nohup $GBD &> /dev/null &
+ RETVAL=$?
+ echo
+ [ $RETVAL -eq 0 ] && touch $LOCKFILE
+ return $RETVAL
+ fi
+}
+
+# Stop the service $BASE
+stop()
+{
+ echo -n $"Stopping $BASE:"
+ if pidofproc -p $PIDFILE $GBD_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 $?