4 # Copyright (C) 2009 Google Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 defaults_file=@SYSCONFDIR@/default/ganeti
30 # Read defaults file if it exists
31 if [[ -s $defaults_file ]]; then
36 echo "@LOCALSTATEDIR@/run/ganeti/$1.pid"
39 # Checks whether daemon is running
41 if [[ "$#" -lt 1 ]]; then
42 echo 'Missing daemon name.' >&2
46 local name="$1"; shift
48 start-stop-daemon --stop --signal 0 --quiet \
49 --pidfile $(_daemon_pidfile $name)
54 if [[ "$#" -lt 1 ]]; then
55 echo 'Missing daemon name.' >&2
59 local name="$1"; shift
61 # Convert daemon name to uppercase after removing "ganeti-" prefix
62 local ucname=$(echo ${name#ganeti-} | tr a-z A-Z)
64 # Read $<daemon>_ARGS and $EXTRA_<daemon>_ARGS
65 eval local args="\"\$${ucname}_ARGS \$EXTRA_${ucname}_ARGS\""
67 start-stop-daemon --start --quiet --oknodo \
68 --pidfile $(_daemon_pidfile $name) \
69 --startas "@PREFIX@/sbin/$name" \
75 if [[ "$#" -lt 1 ]]; then
76 echo 'Missing daemon name.' >&2
80 local name="$1"; shift
82 start-stop-daemon --stop --quiet --oknodo --retry 30 \
83 --pidfile $(_daemon_pidfile $name)
86 # Starts a daemon if it's not yet running
90 if ! check $name; then
95 # Starts the master role
101 # Stops the master role
107 # Reloads the SSH keys
109 @RPL_SSH_INITD_SCRIPT@ restart
112 if [[ "$#" -lt 1 ]]; then
113 echo "Usage: $0 <action>" >&2
117 orig_action=$1; shift
119 if [[ "$orig_action" == *_* ]]; then
120 echo "Command must not contain underscores" >&2
124 # Replace all dashes (-) with underlines (_)
125 action=${orig_action//-/_}
127 # Is it a known function?
128 if ! declare -F "$action" >/dev/null 2>&1; then
129 echo "Unknown command: $orig_action" >&2
133 # Call handler function