summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac9
-rw-r--r--gluster-block.spec.in18
-rw-r--r--systemd/Makefile.am13
-rw-r--r--systemd/gluster-blockd.initd.in142
5 files changed, 178 insertions, 6 deletions
diff --git a/Makefile.am b/Makefile.am
index 7e5018b..962da8c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,6 +11,8 @@ EXTRA_DIST = autogen.sh README.md COPYING-GPLV2 COPYING-LGPLV3 \
if USE_SYSTEMD
RPM_WITH_FLAGS = --with systemd
+else
+RPM_WITH_FLAGS = --with initd
endif
rpms: prep
diff --git a/configure.ac b/configure.ac
index 750055b..3fd3646 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,13 @@ AC_ARG_WITH(systemddir,
AC_SUBST(systemddir)
AM_CONDITIONAL([USE_SYSTEMD], test [ -d '/usr/lib/systemd/system' ])
+AC_ARG_WITH(initddir,
+ AC_HELP_STRING([--with-initddir=DIR],
+ [initd service files in DIR @<:@/etc/rc.d/init.d@:>@]),
+ [initddir=$withval],
+ [initddir='/etc/rc.d/init.d'])
+AC_SUBST(initddir)
+
AC_ARG_WITH(sysconfigdir,
AC_HELP_STRING([--with-sysconfigdir=DIR],
[system service configuration in DIR @<:@/etc/sysconfig@:>@]),
@@ -32,6 +39,7 @@ AC_SUBST(sysconfigdir)
AM_INIT_AUTOMAKE([-Wall -Werror foreign nostdinc silent-rules])
AC_CONFIG_HEADERS([config.h])
+
AC_CONFIG_FILES([gluster-block.spec
Makefile
rpc/Makefile
@@ -42,6 +50,7 @@ AC_CONFIG_FILES([gluster-block.spec
systemd/Makefile
systemd/gluster-blockd.service
systemd/gluster-block-target.service
+ systemd/gluster-blockd.initd
docs/Makefile])
AC_CONFIG_MACRO_DIR([m4])
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
diff --git a/gluster-block.spec.in b/gluster-block.spec.in
index e9e01e1..b14c5d5 100644
--- a/gluster-block.spec.in
+++ b/gluster-block.spec.in
@@ -2,8 +2,10 @@
##-----------------------------------------------------------------------------
## All %%global definitions should be placed here and keep them sorted
##
-%if ( 0%{?fedora} ) || ( 0%{?rhel} && 0%{?rhel} > 6 )
+%if ( 0%{?fedora} ) || ( 0%{?rhel} && 0%{?rhel} > 6 ) || ( 0%{?centos_version} && 0%{?centos_version} > 6)
%global _with_systemd true
+%else
+%global _with_initd true
%endif
@@ -42,12 +44,19 @@ make
%install
make DESTDIR=${RPM_BUILD_ROOT} install
+%if ( 0%{?_with_initd:1} )
+mv %{buildroot}/%{_initddir}/gluster-blockd.initd %{buildroot}/%{_initddir}/gluster-blockd
+%endif
%clean
rm -rf ${RPM_BUILD_ROOT}
%files
+%if ( 0%{?_with_initd:1} )
+%doc COPYING-GPLV2 COPYING-LGPLV3
+%else
%license COPYING-GPLV2 COPYING-LGPLV3
+%endif
%doc README.md INSTALL
%{_sbindir}/gluster-block
%{_sbindir}/gluster-blockd
@@ -55,10 +64,15 @@ rm -rf ${RPM_BUILD_ROOT}
%if ( 0%{?_with_systemd:1} )
%{_unitdir}/gluster-blockd.service
%{_unitdir}/gluster-block-target.service
-%config(noreplace) %{_sysconfdir}/sysconfig/gluster-blockd
+%else
+%attr(755, root, root) %{_initddir}/gluster-blockd
%endif
+%config(noreplace) %{_sysconfdir}/sysconfig/gluster-blockd
%changelog
+* Fri Sep 15 2017 Ji-Hyeon Gim <potatogim@potatogim.net>
+- update with sysconfig handling for non-systemd distros
+
* Fri Aug 11 2017 Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
- add wrapper target service unit
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 $?