MXS-1044: Added init-script for SLES11

This commit is contained in:
Bernd Wolber 2016-12-02 11:20:10 +01:00 committed by Markus Mäkelä
parent 3872cebd09
commit 5c5b2594b5
3 changed files with 173 additions and 1 deletions

View File

@ -278,6 +278,8 @@ if(WITH_SCRIPTS)
configure_file(${CMAKE_SOURCE_DIR}/etc/maxscale.service.in ${CMAKE_BINARY_DIR}/maxscale.service @ONLY)
if(DEB_BASED)
configure_file(${CMAKE_SOURCE_DIR}/etc/ubuntu/init.d/maxscale.in ${CMAKE_BINARY_DIR}/maxscale @ONLY)
elseif(SLES_BASED)
configure_file(${CMAKE_SOURCE_DIR}/etc/sles/init.d/maxscale.in ${CMAKE_BINARY_DIR}/maxscale @ONLY)
else()
configure_file(${CMAKE_SOURCE_DIR}/etc/init.d/maxscale.in ${CMAKE_BINARY_DIR}/maxscale @ONLY)
endif()

View File

@ -65,13 +65,19 @@ macro(check_dirs)
if(${DEB_FNC} MATCHES "DEB_FNC-NOTFOUND")
message(FATAL_ERROR "Cannot find required init-functions in /lib/lsb/ or /etc/rc.d/init.d/, please confirm that your system files are OK.")
else()
set(DEB_BASED TRUE CACHE BOOL "If init.d script uses /lib/lsb/init-functions instead of /etc/rc.d/init.d/functions.")
find_file(SLES_FNC SuSE-release PATHS /etc)
if(${SLES_FNC} MATCHES "SLES_FNC-NOTFOUND")
set(DEB_BASED TRUE CACHE BOOL "If init.d script uses /lib/lsb/init-functions instead of /etc/rc.d/init.d/functions.")
else()
set(SLES_BASED TRUE CACHE BOOL "SLES11 has reduced /lib/lsb/init-functions and needs a special init-script")
endif()
endif()
else()
set(DEB_BASED FALSE CACHE BOOL "If init.d script uses /lib/lsb/init-functions instead of /etc/rc.d/init.d/functions.")
endif()
unset(DEB_FNC)
unset(RPM_FNC)
unset(SLES_FNC)
endif()
#Check RabbitMQ headers and libraries

164
etc/sles11/init.d/maxscale.in Executable file
View File

@ -0,0 +1,164 @@
#!/bin/bash
#
# maxscale: The MariaDB Corporation MaxScale database proxy
#
# description: MaxScale provides database specific proxy functionality
#
# processname: maxscale
#
### BEGIN INIT INFO
# Provides: maxscale
# Required-Start: $syslog $local_fs
# Required-Stop: $syslog $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: The maxscale database proxy
# Description: MaxScale is a database proxy server that can be used to front end
# database clusters offering different routing, filtering and protocol choices
### END INIT INFO
#############################################
# MaxScale HOME, PIDFILE, LIB
#############################################
export MAXSCALE_PIDFILE=@MAXSCALE_VARDIR@/run/maxscale/maxscale.pid
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:@CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@/maxscale
###############################
# LSB Exit codes (non-Status)
###############################
_RETVAL_GENERIC=1
_RETVAL_NOT_INSTALLED=5
_RETVAL_NOT_RUNNING=7
###############################
# LSB Status action Exit codes
###############################
_RETVAL_STATUS_OK=0
_RETVAL_STATUS_NOT_RUNNING=3
# Sanity checks.
[ -x @CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale ] || exit $_RETVAL_NOT_INSTALLED
# Source additional command line arguments.
[ -f /etc/default/maxscale ] && . /etc/default/maxscale
#################################
# stop/start/status related vars
#################################
NAME=maxscale
DAEMON=@CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale
DAEMON_OPTS="--user=maxscale $MAXSCALE_OPTIONS"
# Source function library.
. /lib/lsb/init-functions
# we can rearrange this easily
processname=maxscale
servicename=maxscale
RETVAL=0
start() {
if [ ! -d @MAXSCALE_VARDIR@/log/maxscale ]
then
mkdir -p @MAXSCALE_VARDIR@/log/maxscale
fi
if [ ! -d @MAXSCALE_VARDIR@/cache/maxscale ]
then
mkdir -p @MAXSCALE_VARDIR@/cache/maxscale
fi
if [ ! -d @MAXSCALE_VARDIR@/lib/maxscale ]
then
mkdir -p @MAXSCALE_VARDIR@/lib/maxscale
fi
if [ ! -d @MAXSCALE_VARDIR@/run/maxscale ]
then
mkdir -p @MAXSCALE_VARDIR@/run/maxscale
fi
chown -R maxscale:maxscale @MAXSCALE_VARDIR@/log/maxscale
chown -R maxscale:maxscale @MAXSCALE_VARDIR@/lib/maxscale
chown -R maxscale:maxscale @MAXSCALE_VARDIR@/cache/maxscale
chown -R maxscale:maxscale @MAXSCALE_VARDIR@/run/maxscale
chmod 0755 @MAXSCALE_VARDIR@/log/maxscale
chmod 0755 @MAXSCALE_VARDIR@/lib/maxscale
chmod 0755 @MAXSCALE_VARDIR@/cache/maxscale
chmod 0755 @MAXSCALE_VARDIR@/run/maxscale
ulimit -HSn 65535
echo -n "Starting MaxScale"
start_daemon -p "$MAXSCALE_PIDFILE" $DAEMON $DAEMON_OPTS 2> /dev/null > /dev/null
sleep 2
checkproc $DAEMON
rc_status -v
}
stop() {
echo -n "Stopping MaxScale"
maxscale_wait_stop
rc_status -v
}
reload() {
echo -n "Reloading MaxScale"
kill -HUP $(cat "$MAXSCALE_PIDFILE")
rc_status -v
}
maxscale_wait_stop() {
PIDTMP=$(pidofproc -p "$MAXSCALE_PIDFILE" "$DAEMON")
kill -TERM "${PIDTMP:-}" 2> /dev/null;
if [ -n "${PIDTMP:-}" ] && kill -0 "${PIDTMP:-}" 2> /dev/null; then
local i=0
while kill -0 "${PIDTMP:-}" 2> /dev/null; do
if [ $i = '60' ]; then
break
STATUS=2
fi
[ "$VERBOSE" != no ] && echo -n "."
sleep 1
i=$(($i+1))
done
return $STATUS
else
return $STATUS
fi
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
# return 0 on success
# return 3 on any error
echo -n "Checking MaxScale"
checkproc $DAEMON
rc_status -v
;;
restart)
stop
start
;;
reload)
reload
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload}"
;;
esac
exit $RETVAL