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

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


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

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

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

start() {
    local rc
    checkconfig || return 1
    
    ebegin "Starting PVFS2 server"
    
    # Optionally force pvfs2-server to generate the pvfs2 filesystem.
    if [[ ${PVFS2_AUTO_MKFS} -ne 0 && \
        ! -f $(grep StorageSpace ${PVFS2_FS_CONF} | cut -d' ' -f 2)/collections.db ]]; then
        ewarn "Initializing the file system storage with --mkfs"
        "${PVFS2_SERVER}"  --mkfs "${PVFS2_FS_CONF}"
        rc=$?
    fi

    if [[ ${rc} -eq 0 ]]; then 
        start-stop-daemon -b --start  --quiet \
            --pidfile "${PVFS2_PIDFILE}" \
            --exec "${PVFS2_SERVER}" \
            -- -p "${PVFS2_PIDFILE}" ${PVFS2_OPTIONS} "${PVFS2_FS_CONF}"
        rc=$?
    fi
    eend ${rc}
}

stop() {
    checkconfig || return 1
    ebegin "Stopping PVFS2 server"
    start-stop-daemon --stop  --quiet --pidfile "${PVFS2_PIDFILE}"
    eend
}

restart() {
    svc_stop
    sleep 2
    svc_start
}