Statistics
| Branch: | Tag: | Revision:

root / doc / examples / ganeti.initd.in @ 298fe380

History | View | Annotate | Download (2.7 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 e71d6323 Iustin Pop
# Default-Stop:      0 1 6
10 24d48647 Guido Trotter
# Short-Description: Ganeti Xen Cluster Manager
11 e71d6323 Iustin Pop
# 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 40dacb4d Iustin Pop
MASTERD_NAME=ganeti-masterd
20 40dacb4d Iustin Pop
MASTERD="@PREFIX@/sbin/$MASTERD_NAME"
21 c1671c0e Michael Hanselmann
SCRIPTNAME=@SYSCONFDIR@/init.d/ganeti
22 a8083063 Iustin Pop
23 9bd7f742 Iustin Pop
test -f $NODED || exit 0
24 a8083063 Iustin Pop
25 a8083063 Iustin Pop
. /lib/lsb/init-functions
26 a8083063 Iustin Pop
27 a8083063 Iustin Pop
check_config() {
28 c1671c0e Michael Hanselmann
    for fname in \
29 c1671c0e Michael Hanselmann
        "@LOCALSTATEDIR@/lib/ganeti/ssconf_node_pass" \
30 c1671c0e Michael Hanselmann
        "@LOCALSTATEDIR@/lib/ganeti/server.pem"
31 c1671c0e Michael Hanselmann
    do
32 3c9a0742 Michael Hanselmann
        if ! [ -f "$fname" ]; then
33 3c9a0742 Michael Hanselmann
            log_end_msg 0
34 3c9a0742 Michael Hanselmann
            log_warning_msg "Config $fname not there, will not run."
35 3c9a0742 Michael Hanselmann
            exit 0
36 3c9a0742 Michael Hanselmann
        fi
37 3c9a0742 Michael Hanselmann
    done
38 a8083063 Iustin Pop
}
39 a8083063 Iustin Pop
40 9bd7f742 Iustin Pop
master_action() {
41 9bd7f742 Iustin Pop
    log_action_begin_msg "ganeti-master"; $MASTER "$1"
42 9bd7f742 Iustin Pop
    RC=$?
43 9bd7f742 Iustin Pop
    case $RC in
44 9bd7f742 Iustin Pop
        0)
45 9bd7f742 Iustin Pop
            log_action_end_msg 0
46 9bd7f742 Iustin Pop
            ;;
47 9bd7f742 Iustin Pop
        11)
48 9bd7f742 Iustin Pop
            log_action_end_msg 0 "not master"
49 9bd7f742 Iustin Pop
            ;;
50 9bd7f742 Iustin Pop
        *)
51 9bd7f742 Iustin Pop
            log_action_end_msg 1 "exit code $RC"
52 9bd7f742 Iustin Pop
            ;;
53 9bd7f742 Iustin Pop
    esac
54 9bd7f742 Iustin Pop
}
55 9bd7f742 Iustin Pop
56 a8083063 Iustin Pop
case "$1" in
57 3c9a0742 Michael Hanselmann
    start)
58 9bd7f742 Iustin Pop
        log_daemon_msg "Starting $DESC" "$NAME"
59 3c9a0742 Michael Hanselmann
        check_config
60 9bd7f742 Iustin Pop
        if start-stop-daemon --start --quiet --exec $NODED; then
61 9bd7f742 Iustin Pop
            log_end_msg 0
62 9bd7f742 Iustin Pop
        else
63 9bd7f742 Iustin Pop
            log_end_msg 1
64 9bd7f742 Iustin Pop
        fi
65 9bd7f742 Iustin Pop
        master_action start
66 40dacb4d Iustin Pop
        if start-stop-daemon --start --quiet --exec $MASTERD; then
67 40dacb4d Iustin Pop
            log_end_msg 0
68 40dacb4d Iustin Pop
        else
69 40dacb4d Iustin Pop
            log_end_msg 1
70 40dacb4d Iustin Pop
        fi
71 40dacb4d Iustin Pop
     ;;
72 3c9a0742 Michael Hanselmann
    stop)
73 9bd7f742 Iustin Pop
        log_daemon_msg "Stopping $DESC" "$NAME"
74 9bd7f742 Iustin Pop
        if start-stop-daemon --stop --quiet --name $NAME; then
75 9bd7f742 Iustin Pop
            log_end_msg 0
76 9bd7f742 Iustin Pop
        else
77 9bd7f742 Iustin Pop
            log_end_msg 1
78 9bd7f742 Iustin Pop
        fi
79 40dacb4d Iustin Pop
        if start-stop-daemon --stop --quiet --name $MASTERD_NAME; then
80 40dacb4d Iustin Pop
            log_end_msg 0
81 40dacb4d Iustin Pop
        else
82 40dacb4d Iustin Pop
            log_end_msg 1
83 40dacb4d Iustin Pop
        fi
84 40dacb4d Iustin Pop
         master_action stop
85 3c9a0742 Michael Hanselmann
    ;;
86 3c9a0742 Michael Hanselmann
    restart|force-reload)
87 9bd7f742 Iustin Pop
        log_daemon_msg "Reloading $DESC"
88 3c9a0742 Michael Hanselmann
        start-stop-daemon --stop --quiet --oknodo --retry 30 --name $NAME
89 40dacb4d Iustin Pop
        start-stop-daemon --stop --quiet --oknodo --retry 30 --name $MASTERD_NAME
90 3c9a0742 Michael Hanselmann
        check_config
91 9bd7f742 Iustin Pop
        start-stop-daemon --start --quiet --exec $NODED
92 40dacb4d Iustin Pop
        start-stop-daemon --start --quiet --exec $MASTERD
93 9bd7f742 Iustin Pop
        log_end_msg $?
94 9bd7f742 Iustin Pop
95 9bd7f742 Iustin Pop
        $MASTER stop
96 9bd7f742 Iustin Pop
        master_action start
97 9bd7f742 Iustin Pop
     ;;
98 3c9a0742 Michael Hanselmann
    *)
99 3c9a0742 Michael Hanselmann
        log_success_msg "Usage: $SCRIPTNAME {start|stop|force-reload|restart}"
100 3c9a0742 Michael Hanselmann
        exit 1
101 3c9a0742 Michael Hanselmann
    ;;
102 a8083063 Iustin Pop
esac
103 a8083063 Iustin Pop
104 a8083063 Iustin Pop
exit 0