Statistics
| Branch: | Tag: | Revision:

root / doc / examples / ganeti.initd.in @ 2395c322

History | View | Annotate | Download (2.2 kB)

1 c1671c0e Michael Hanselmann
#!/bin/sh
2 a8083063 Iustin Pop
# ganeti node daemon starter script
3 a8083063 Iustin Pop
# based on skeleton from Debian GNU/Linux
4 24d48647 Guido Trotter
### BEGIN INIT INFO
5 24d48647 Guido Trotter
# Provides:          ganeti
6 24d48647 Guido Trotter
# Required-Start:    $syslog $remote_fs xend
7 24d48647 Guido Trotter
# Required-Stop:     $syslog $remote_fs xend
8 24d48647 Guido Trotter
# Default-Start:     2 3 4 5
9 24d48647 Guido Trotter
# Default-Stop:      S 0 1 6
10 24d48647 Guido Trotter
# Short-Description: Ganeti Xen Cluster Manager
11 24d48647 Guido Trotter
# Description:       Ganeti Xen Cluster Manager 
12 24d48647 Guido Trotter
### END INIT INFO
13 a8083063 Iustin Pop
14 880478f8 Iustin Pop
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
15 9bd7f742 Iustin Pop
DESC="Ganeti cluster"
16 c1671c0e Michael Hanselmann
NAME=ganeti-noded
17 c1671c0e Michael Hanselmann
NODED=@PREFIX@/sbin/ganeti-noded
18 c1671c0e Michael Hanselmann
MASTER=@PREFIX@/sbin/ganeti-master
19 c1671c0e Michael Hanselmann
SCRIPTNAME=@SYSCONFDIR@/init.d/ganeti
20 a8083063 Iustin Pop
21 9bd7f742 Iustin Pop
test -f $NODED || exit 0
22 a8083063 Iustin Pop
23 a8083063 Iustin Pop
. /lib/lsb/init-functions
24 a8083063 Iustin Pop
25 a8083063 Iustin Pop
check_config() {
26 c1671c0e Michael Hanselmann
    for fname in \
27 c1671c0e Michael Hanselmann
        "@LOCALSTATEDIR@/lib/ganeti/ssconf_node_pass" \
28 c1671c0e Michael Hanselmann
        "@LOCALSTATEDIR@/lib/ganeti/server.pem"
29 c1671c0e Michael Hanselmann
    do
30 3c9a0742 Michael Hanselmann
        if ! [ -f "$fname" ]; then
31 3c9a0742 Michael Hanselmann
            log_end_msg 0
32 3c9a0742 Michael Hanselmann
            log_warning_msg "Config $fname not there, will not run."
33 3c9a0742 Michael Hanselmann
            exit 0
34 3c9a0742 Michael Hanselmann
        fi
35 3c9a0742 Michael Hanselmann
    done
36 a8083063 Iustin Pop
}
37 a8083063 Iustin Pop
38 9bd7f742 Iustin Pop
master_action() {
39 9bd7f742 Iustin Pop
    log_action_begin_msg "ganeti-master"; $MASTER "$1"
40 9bd7f742 Iustin Pop
    RC=$?
41 9bd7f742 Iustin Pop
    case $RC in
42 9bd7f742 Iustin Pop
        0)
43 9bd7f742 Iustin Pop
            log_action_end_msg 0
44 9bd7f742 Iustin Pop
            ;;
45 9bd7f742 Iustin Pop
        11)
46 9bd7f742 Iustin Pop
            log_action_end_msg 0 "not master"
47 9bd7f742 Iustin Pop
            ;;
48 9bd7f742 Iustin Pop
        *)
49 9bd7f742 Iustin Pop
            log_action_end_msg 1 "exit code $RC"
50 9bd7f742 Iustin Pop
            ;;
51 9bd7f742 Iustin Pop
    esac
52 9bd7f742 Iustin Pop
}
53 9bd7f742 Iustin Pop
54 a8083063 Iustin Pop
case "$1" in
55 3c9a0742 Michael Hanselmann
    start)
56 9bd7f742 Iustin Pop
        log_daemon_msg "Starting $DESC" "$NAME"
57 3c9a0742 Michael Hanselmann
        check_config
58 9bd7f742 Iustin Pop
        if start-stop-daemon --start --quiet --exec $NODED; then
59 9bd7f742 Iustin Pop
            log_end_msg 0
60 9bd7f742 Iustin Pop
        else
61 9bd7f742 Iustin Pop
            log_end_msg 1
62 9bd7f742 Iustin Pop
        fi
63 9bd7f742 Iustin Pop
        master_action start
64 3c9a0742 Michael Hanselmann
    ;;
65 3c9a0742 Michael Hanselmann
    stop)
66 9bd7f742 Iustin Pop
        log_daemon_msg "Stopping $DESC" "$NAME"
67 9bd7f742 Iustin Pop
        if start-stop-daemon --stop --quiet --name $NAME; then
68 9bd7f742 Iustin Pop
            log_end_msg 0
69 9bd7f742 Iustin Pop
        else
70 9bd7f742 Iustin Pop
            log_end_msg 1
71 9bd7f742 Iustin Pop
        fi
72 9bd7f742 Iustin Pop
        master_action stop
73 3c9a0742 Michael Hanselmann
    ;;
74 3c9a0742 Michael Hanselmann
    restart|force-reload)
75 9bd7f742 Iustin Pop
        log_daemon_msg "Reloading $DESC"
76 3c9a0742 Michael Hanselmann
        start-stop-daemon --stop --quiet --oknodo --retry 30 --name $NAME
77 3c9a0742 Michael Hanselmann
        check_config
78 9bd7f742 Iustin Pop
        start-stop-daemon --start --quiet --exec $NODED
79 9bd7f742 Iustin Pop
        log_end_msg $?
80 9bd7f742 Iustin Pop
81 9bd7f742 Iustin Pop
        $MASTER stop
82 9bd7f742 Iustin Pop
        master_action start
83 9bd7f742 Iustin Pop
     ;;
84 3c9a0742 Michael Hanselmann
    *)
85 3c9a0742 Michael Hanselmann
        log_success_msg "Usage: $SCRIPTNAME {start|stop|force-reload|restart}"
86 3c9a0742 Michael Hanselmann
        exit 1
87 3c9a0742 Michael Hanselmann
    ;;
88 a8083063 Iustin Pop
esac
89 a8083063 Iustin Pop
90 a8083063 Iustin Pop
exit 0
91 3c9a0742 Michael Hanselmann
92 3c9a0742 Michael Hanselmann
# vim: set sw=4 sts=4 et foldmethod=marker :