From 793b38f5ec98c7355bcfc71e0ef54b02f3530ece Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Thu, 28 Oct 2004 19:37:11 +0000 Subject: [PATCH] Incorporate Suse init logic into common init.d/slurm program. --- etc/init.d.slurm | 41 +++++++--- etc/init.d.slurm.suse | 177 ------------------------------------------ 2 files changed, 30 insertions(+), 188 deletions(-) delete mode 100755 etc/init.d.slurm.suse diff --git a/etc/init.d.slurm b/etc/init.d.slurm index 467de96c7cd..dbefb27c7e8 100644 --- a/etc/init.d.slurm +++ b/etc/init.d.slurm @@ -13,8 +13,15 @@ # # config: /etc/sysconfig/slurm # - -# $Id$ +### BEGIN INIT INFO +# Provides: slurm +# Required-Start: $local_fs $syslog $network $named munge +# Required-Stop: $local_fs $syslog $network $named munge +# Default-Start: 3 5 +# Default-Stop: 0 1 2 6 +# Short-Description: slurm daemon management +# Description: Start slurm to provide resource management +### END INIT INFO BINDIR=/usr/bin CONFDIR=/etc/slurm @@ -22,8 +29,24 @@ LIBDIR=/usr/lib SBINDIR=/usr/sbin # Source function library. -[ -f /etc/rc.d/init.d/functions ] || exit 0 -. /etc/rc.d/init.d/functions +if [ -f /etc/rc.status ]; then + . /etc/rc.status + SUSE=1 + + rc_reset +else + [ -f /etc/rc.d/init.d/functions ] || exit 0 + . /etc/rc.d/init.d/functions + SUSE=0 + + function rc_status() { + RETVAL=$? + } + function rc_exit () { + exit $RETVAL + } + RETVAL=0 +fi # Source slurm specific configuration if [ -f /etc/sysconfig/slurm ] ; then @@ -38,25 +61,21 @@ fi # setup library paths for slurm and munge support export LD_LIBRARY_PATH="$LIBDIR:$LD_LIBRARY_PATH" -RETVAL=0 - start() { echo -n "starting $1: " unset HOME MAIL USER USERNAME daemon $SBINDIR/$1 $2 - RETVAL=$? + rc_status -v echo touch /var/lock/subsys/slurm - return $RETVAL } stop() { echo -n "stopping $1: " killproc $1 -TERM - RETVAL=$? + rc_status -v echo rm -f /var/lock/subsys/slurm - return $RETVAL } startall() { @@ -168,4 +187,4 @@ case "$1" in ;; esac -exit $RETVAL +rc_exit diff --git a/etc/init.d.slurm.suse b/etc/init.d.slurm.suse deleted file mode 100755 index 383f4001173..00000000000 --- a/etc/init.d.slurm.suse +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/bash -# -# chkconfig: 345 90 10 -# description: SLURM is a simple resource management system which \ -# manages exclusive access to a set of compute \ -# resources and distributes work to those resources. -# -# processname: /usr/sbin/slurmd -# pidfile: /var/run/slurmd.pid -# -# processname: /usr/sbin/slurmctld -# pidfile: /var/run/slurmctld.pid -# -# config: /etc/sysconfig/slurm -# -### BEGIN INIT INFO -# Provides: slurm -# Required-Start: $local_fs $syslog $network $named munge -# Required-Stop: $local_fs $syslog $network $named munge -# Default-Start: 3 5 -# Default-Stop: 0 1 2 6 -# Short-Description: slurm daemon management -# Description: Start slurm to provide resource management -### END INIT INFO - -BINDIR=/usr/bin -CONFDIR=/etc/slurm -LIBDIR=/usr/lib -SBINDIR=/usr/sbin - -# Source function library. -[ -f /etc/rc.status ] || exit 0 -. /etc/rc.status - -# Reset status of this service -rc_reset - -# Source slurm specific configuration -if [ -f /etc/sysconfig/slurm ] ; then - . /etc/sysconfig/slurm -else - SLURMCTLD_OPTIONS="" - SLURMD_OPTIONS="" -fi - -[ -f $CONFDIR/slurm.conf ] || exit 1 - -# setup library paths for slurm and munge support -export LD_LIBRARY_PATH="$LIBDIR:$LD_LIBRARY_PATH" - -start() { - echo -n "starting $1: " - unset HOME MAIL USER USERNAME - startproc $SBINDIR/$1 $2 - rc_status -v - echo - touch /var/lock/subsys/slurm -} - -stop() { - echo -n "stopping $1: " - killproc $1 -TERM - rc_status -v - echo - rm -f /var/lock/subsys/slurm -} - -startall() { - for prog in `$BINDIR/scontrol show daemons`; do - optvar=`echo ${prog}_OPTIONS | tr "a-z" "A-Z"` - start $prog ${!optvar} - done -} - -# status() with slight modifications to take into account -# instantiations of job manager slurmd's, which should not be -# counted as "running" -# -slurmstatus() { - local base=${1##*/} - local pid - local rpid - local pidfile - - pidfile=`grep -i ${base}pid $CONFDIR/slurm.conf | grep -v '^ *#'` - if [ $? = 0 ]; then - pidfile=${pidfile##*=} - pidfile=${pidfile%#*} - else - pidfile=/var/run/${base}.pid - fi - - pid=`pidof -o $$ -o $$PPID -o %PPID -x $1 || \ - pidof -o $$ -o $$PPID -o %PPID -x ${base}` - - if [ -f $pidfile ]; then - read rpid < $pidfile - if [ "$rpid" != "" -a "$pid" != "" ]; then - for i in $pid ; do - if [ "$i" = "$rpid" ]; then - echo $"${base} (pid $pid) is running..." - return 0 - fi - done - elif [ "$rpid" != "" -a "$pid" = "" ]; then - echo $"${base} dead but pid file exists" - return 1 - fi - - fi - - if [ "$base" = "slurmctld" -a "$pid" != "" ] ; then - echo $"${base} (pid $pid) is running..." - return 0 - fi - - echo $"${base} is stopped" - - return 3 -} - - -# -# The pathname substitution in daemon command assumes prefix and -# exec_prefix are same. This is the default, unless the user requests -# otherwise. -# -# Any node can be a slurm controller and/or server. -# -case "$1" in - start) - startall - ;; - startclean) - SLURMCTLD_OPTIONS="-c $SLURMCTLD_OPTIONS" - SLURMD_OPTIONS="-c $SLURMD_OPTIONS" - startall - ;; - stop) - for prog in `$BINDIR/scontrol show daemons`; do - stop $prog - done - ;; - status) - for prog in `$BINDIR/scontrol show daemons`; do - slurmstatus $prog - done - ;; - restart) - $0 stop - $0 start - ;; - condrestart) - if [ -f /var/lock/subsys/slurm ]; then - for prog in `$BINDIR/scontrol show daemons`; do - stop $prog - start $prog - done - fi - ;; - reconfig) - for prog in `$BINDIR/scontrol show daemons`; do - killproc $prog -HUP - done - ;; - test) - for prog in `$BINDIR/scontrol show daemons`; do - echo "$prog runs here" - done - ;; - *) - echo "Usage: $0 {start|startclean|stop|status|restart|reconfig|condrestart|test}" - exit 1 - ;; -esac - -rc_exit -- GitLab