summaryrefslogtreecommitdiff
blob: 4706159e166a93834ad3390f342f5661b750d19d (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/sbin/runscript
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-cluster/pvfs2/files/pvfs2-server.rc,v 1.1 2007/10/05 14:03:13 mabi Exp $

checkconfig() {
	local piddir=$(dirname "${PVFS2_PIDFILE}")
	if [ ! -d "${piddir}" ]; then
		mkdir -p "${piddir}" || return 1
	fi

	# verify presence of server binary
	if ! [ -x "${PVFS2SERVER}" ]; then
		eerror "Error: could not find executable ${PVFS2SERVER}"
		return 1
	fi

	# look for fs conf
	if [ -n "${PVFS2_FS_CONF}" ]; then
		PVFS2_FS_CONF="${PVFS2_CONF_PATH}/${PVFS2_FS_CONF}"
	else
		PVFS2_FS_CONF="${PVFS2_CONF_PATH}"/pvfs2-fs.conf
	fi

	if ! [ -r "${PVFS2_FS_CONF}" ]; then
		eerror "Error: could not read ${PVFS2_FS_CONF}"
		return 1
	fi

	# look for server conf
	if [ -n "${PVFS2_SERVER_CONF_BASE}" ]; then 
		local myhost=`hostname -s`
		if [ "${myhost}" == "localhost" ]; then
			ewarn "Warning: detected hostname as localhost, may confuse PVFS2 startup"
		fi
		PVFS2_SERVER_CONF="${PVFS2_CONF_PATH}/${PVFS2_SERVER_CONF_BASE}-${myhost}"
	elif [ -n "${PVFS2_SERVER_CONF}" ]; then
		PVFS2_SERVER_CONF="${PVFS2_CONF_PATH}/${PVFS2_SERVER_CONF}"
	else
		PVFS2_SERVER_CONF="${PVFS2_CONF_PATH}/pvfs2-server.conf"
	fi

	if ! [ -r "${PVFS2_SERVER_CONF}" ]; then
		eerror "Error: could not read ${PVFS2_SERVER_CONF}"
		return 1
	fi
}

depend() {
	after localmount netmount nfsmount dns
	use net
}

start() {
	ebegin "Starting PVFS2 server"
	local rc
	checkconfig || return 1

	start-stop-daemon -b --start  --quiet \
		--pidfile "${PVFS2_PIDFILE}" \
		--exec "${PVFS2SERVER}" -- -p "${PVFS2_PIDFILE}" ${PVFS2_OPTIONS} \
		"${PVFS2_FS_CONF}" "${PVFS2_SERVER_CONF}"
	rc=$?

	# Optionally force pvfs2-server to generate the pvfs2 filesystem.
	if [[ $PVFS2_AUTO_MKFS -ne 0 ]]; then
		local test_pid
		sleep 1
		test_pid=$(pidof pvfs2-server)
		if [ -z "$test_pid" ] || [ ! -f "${PVFS2_PIDFILE}" ] || [[ $test_pid -ne `cat ${PVFS2_PIDFILE}` ]]; then
			rm -f "${PVFS2_PIDFILE}" &>/dev/null
			ewarn "Initializing the file system storage with --mkfs"
			"${PVFS2SERVER}"  --mkfs "${PVFS2_FS_CONF}" "${PVFS2_SERVER_CONF}"
			rc=$?
			if [[ $rc -ne 0 ]]; then
				eerror "Failed to initialize the filesystem storage with --mkfs"
				eend ${rc}
				return 1
			fi
			start-stop-daemon -b --start  --quiet \
				--pidfile ${PVFS2_PIDFILE} \
				--exec ${PVFS2SERVER} -- -p "${PVFS2_PIDFILE}" ${PVFS2_OPTIONS} \
				"${PVFS2_FS_CONF}" "${PVFS2_SERVER_CONF}"
			rc=$?
		fi
	fi

	if [[ $rc -ne 0 ]]; then
		eend $rc "Error starting PVFS2 server"
		return 1
	else
		eend 0
		return 0
	fi
}

stop() {
	ebegin "Stopping PVFS2 server"
	start-stop-daemon --stop  --quiet --pidfile "${PVFS2_PIDFILE}"
	eend $? "Error stopping PVFS2 server"
}

restart() {
	svc_stop
	sleep 2
	svc_start
}