aboutsummaryrefslogtreecommitdiffstats
path: root/testing/opennebula/opennebula.initd
blob: 0da109904939b015aa88d3c46eab52c915cd5319 (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
#!/sbin/runscript
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

depend() {
    after mysql
}

start() {
    checkconfig || return 1

    ebegin "Starting OpenNebula daemon"
    start-stop-daemon \
        --start \
        --exec /usr/bin/oned \
        --user ${USER}:${GROUP} \
        -- ${ONED_OPTIONS}
    eend $?

    ebegin "Starting OpenNebula scheduler"
    start-stop-daemon \
        --start \
        --exec /usr/bin/mm_sched \
        --pidfile "${SCHED_PIDFILE}" \
        --make-pidfile \
        --background \
        --user ${USER}:${GROUP} \
        -- ${SCHED_OPTIONS}
    eend $?
}

stop() {
    ebegin "Stopping OpenNebula daemon"
    start-stop-daemon \
        --stop \
        --exec /usr/bin/oned
    eend $?

    ebegin "Stopping OpenNebula scheduler"
    start-stop-daemon \
        --stop \
        --exec /usr/bin/mm_sched \
        --pidfile "${SCHED_PIDFILE}"
    eend $?
}

gen_key() {
    ebegin "Generating ssh key"
    su - ${USER} -c "ssh-keygen -q -t dsa -N '' -f ${HOME}/.ssh/id_dsa"
    cp -p "${HOME}/.ssh/id_dsa.pub" "${HOME}/.ssh/authorized_keys"
    eend $?
}

checkconfig() {
    if [ ! -f "${HOME}/.ssh/id_dsa" ] ; then
        gen_key || return 1
    fi
}