Revision 5d8acbdd

b/daemons/daemon-util.in
22 22

  
23 23
defaults_file=@SYSCONFDIR@/default/ganeti
24 24

  
25
# This is a list of all daemons and the order in which they're started. The
26
# order is important as there are dependencies between them. On shutdown,
27
# they're stopped in reverse order.
28
DAEMONS=(
29
  ganeti-noded
30
  ganeti-masterd
31
  ganeti-rapi
32
  ganeti-confd
33
  )
34

  
25 35
NODED_ARGS=
26 36
MASTERD_ARGS=
27 37
CONFD_ARGS=
......
74 84
  return 0
75 85
}
76 86

  
87
# Prints a list of all daemons in the order in which they should be started
88
list_start_daemons() {
89
  local name
90

  
91
  for name in "${DAEMONS[@]}"; do
92
    echo "$name"
93
  done
94
}
95

  
96
# Prints a list of all daemons in the order in which they should be stopped
97
list_stop_daemons() {
98
  list_start_daemons | tac
99
}
100

  
101
# Checks whether a daemon name is known
102
is_daemon_name() {
103
  if [[ "$#" -lt 1 ]]; then
104
    echo 'Missing daemon name.' >&2
105
    return 1
106
  fi
107

  
108
  local name="$1"; shift
109

  
110
  for i in "${DAEMONS[@]}"; do
111
    if [[ "$i" == "$name" ]]; then
112
      return 0
113
    fi
114
  done
115

  
116
  echo "Unknown daemon name '$name'" >&2
117
  return 1
118
}
119

  
77 120
# Checks whether daemon is running
78 121
check() {
79 122
  if [[ "$#" -lt 1 ]]; then
b/doc/examples/ganeti.initd.in
14 14
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
15 15
DESC="Ganeti cluster"
16 16

  
17
NODED="ganeti-noded"
18
MASTERD="ganeti-masterd"
19
CONFD="ganeti-confd"
20
RAPI="ganeti-rapi"
21

  
22 17
DAEMON_UTIL=@PKGLIBDIR@/daemon-util
23 18

  
24 19
SCRIPTNAME="@SYSCONFDIR@/init.d/ganeti"
25 20

  
26
test -f "@PREFIX@/sbin/$NODED" || exit 0
21
test -f "$DAEMON_UTIL" || exit 0
27 22

  
28 23
. /lib/lsb/init-functions
29 24

  
......
69 64
        exit 0
70 65
    fi
71 66

  
72
    for i in $NODED $MASTERD $CONFD $RAPI; do \
67
    for i in $($DAEMON_UTIL list-start-daemons); do
73 68
        maybe_do "$1" start_action $i
74 69
    done
75 70
}
76 71

  
77 72
stop_all() {
78
    for i in $RAPI $CONFD $MASTERD $NODED; do \
73
    for i in $($DAEMON_UTIL list-stop-daemons); do
79 74
        maybe_do "$1" stop_action $i
80 75
    done
81 76
}
82 77

  
83
if [ -n "$2" -a \
84
    "$2" != "$NODED" -a \
85
    "$2" != "$CONFD" -a \
86
    "$2" != "$MASTERD" -a \
87
    "$2" != "$RAPI" ]; then
88
    log_failure_msg "Unknown daemon '$2' requested"
78
if [ -n "$2" ] && ! errmsg=$($DAEMON_UTIL is-daemon-name "$2" 2>&1); then
79
    log_failure_msg "$errmsg"
89 80
    exit 1
90 81
fi
91 82

  

Also available in: Unified diff