summaryrefslogtreecommitdiff
blob: 75cb21ef28fba3bec7662a21b50b970c99e14af3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-cluster/slurm/files/slurmctld.initd,v 1.3 2012/04/18 13:53:03 alexxy Exp $

extra_commands="reload"

[[ -f /etc/conf.d/slurm ]] && . /etc/conf.d/slurm

depend() {
	local _need="net"
	[[ ${SLURM_USE_MUNGE} -ne 0 ]] && _need="${_need} munged"
	[[ ${SLURM_USE_YPBIND} -ne 0 ]] && _need="${_need} ypbind"
	after logger slurmdbd
	need ${_need}
}

create_folder_and_set_permission() {
    folder=${1}
    # Fix permissions (/tmp is wiped at boot)
    if [[ "${folder}" == "/tmp" ]]; then
        eerror "SLURM: folder == ${folder} == /tmp"
        exit
    fi
    if [[ "${folder}" == "/var/tmp" ]]; then
        eerror "SLURM: folder == ${folder} == /var/tmp"
        exit
    fi
    checkpath -d -o slurm:slurm ${folder}
}

checkconfig() {
	if [ ! -e "/etc/slurm/slurm.conf" ]; then
		eerror "Missing config /etc/slurm/slurm.conf"
		eerror "Customize sample one or generate new by configurator.html"
		eerror "in slurm doc directory"
		return 1
	fi
	
	# Make sure folders exists
	. /etc/slurm/slurm.conf
	folders=(${SlurmdSpoolDir} `dirname ${SlurmctldLogFile}` `dirname ${SlurmctldPidFile}` `dirname ${SlurmdLogFile}` `dirname ${SlurmdPidFile}` ${SlurmdSpoolDir} ${StateSaveLocation})
	for folder in ${folders[*]}; do
		create_folder_and_set_permission ${folder}
	done
}

start() {
	ebegin "Starting slurm control daemon"
	checkconfig
	start-stop-daemon --start --quiet --background \
		--pidfile /var/run/slurm/slurmctld.pid \
		--user slurm \
		--group slurm \
		--exec /usr/sbin/slurmctld -- ${SLURMCTLD_OPTS}
	eend $?
}

stop() {
	ebegin "Stopping slurm control daemon"
	start-stop-daemon --stop --pidfile /var/run/slurm/slurmctld.pid
	eend $?
}

reload() {
	ebegin "Reloading slurm daemon configuration"
	start-stop-daemon --signal HUP --pidfile /var/run/slurm/slurmctld.pid
	eend $?
}