summaryrefslogtreecommitdiff
blob: fb86356ec0a67cba08ea4a0e2a21525c0be1112a (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
#!/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-client-init.d-2.7.0,v 1.1 2008/03/06 23:05:44 jsbronder Exp $


depend() {
	need net
	need localmount
	before pbs_mom
	after pvfs2-server
}

checkconfig() {
	if [ ! -x "${PVFS2_CLIENT}" -o ! -x "${PVFS2_CLIENT_CORE}" ]; then
		eend 1 "pvfs-2 was not correctly installed."
		return 1
	fi

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

start() {
	local rc=0
    local server_mp server mp
    checkconfig || return 1
	ebegin "Starting pvfs2-client"

    if ! grep -qs pvfs2 /proc/filesystems; then
        eerror "Kernel does not support pvfs2 filesystems"
        return 1
    fi

    # Don't fork the client so we can get the pid with s-s-d.
	if ! start-stop-daemon --start -m -b --quiet \
        --pidfile ${PVFS2_CLIENT_PIDFILE} \
        --exec "${PVFS2_CLIENT}" \
        -- -f -p ${PVFS2_CLIENT_CORE} ${PVFS2_CLIENT_ARGS}; then
        rc=1
	elif [ -n "${PVFS2_MOUNTS}" ]; then
        for server_mp in ${PVFS2_MOUNTS}; do
            mount -t pvfs2 \
                tcp://$(echo ${server_mp} | cut -d',' -f1)/pvfs2-fs \
                $(echo ${server_mp} | cut -d',' -f2)
            rc=$?
            [[ ${rc} -ne 0 ]] && break
        done
        [[ ${rc} -ne 0 ]] && start-stop-daemon --stop -p ${PVFS2_CLIENT_PIDFILE} 
    fi

	eend ${rc}
}

stop() {
    local rc=0
    local server_mp
    checkconfig || return 1
	ebegin "Stopping pvfs2-client"

    if [ -n "${PVFS2_MOUNTS}" ]; then
        for server_mp in ${PVFS2_MOUNTS}; do
            umount -f $(echo ${server_mp} | cut -d',' -f2)
            rc=$?
            [[ ${rc} -ne 0 ]] && break
        done
    fi

    if [[ ${rc} -eq 0 ]]; then
	    start-stop-daemon --stop -p ${PVFS2_CLIENT_PIDFILE} 
        rc=$?
    fi

	eend ${rc}
}