+_daemon_executable() {
+ echo "@PREFIX@/sbin/$1"
+}
+
+# Checks whether the local machine is part of a cluster
+check_config() {
+ local server_pem=@LOCALSTATEDIR@/lib/ganeti/server.pem
+ local fname
+
+ for fname in $server_pem; do
+ if [[ ! -f $fname ]]; then
+ echo "Missing configuration file $fname" >&2
+ return 1
+ fi
+ done
+
+ return 0
+}
+
+# Checks the exit code of a daemon
+check_exitcode() {
+ if [[ "$#" -lt 1 ]]; then
+ echo 'Missing exit code.' >&2
+ return 1
+ fi
+
+ local rc="$1"; shift
+
+ case "$rc" in
+ 0) ;;
+ 11)
+ echo "not master"
+ ;;
+ *)
+ echo "exit code $rc"
+ return 1
+ ;;
+ esac
+
+ return 0
+}
+
+# Prints a list of all daemons in the order in which they should be started
+list_start_daemons() {
+ local name
+
+ for name in "${DAEMONS[@]}"; do
+ echo "$name"
+ done
+}
+
+# Prints a list of all daemons in the order in which they should be stopped
+list_stop_daemons() {
+ list_start_daemons | tac
+}
+
+# Checks whether a daemon name is known
+is_daemon_name() {
+ if [[ "$#" -lt 1 ]]; then
+ echo 'Missing daemon name.' >&2
+ return 1
+ fi
+
+ local name="$1"; shift
+
+ for i in "${DAEMONS[@]}"; do
+ if [[ "$i" == "$name" ]]; then
+ return 0
+ fi
+ done
+
+ echo "Unknown daemon name '$name'" >&2
+ return 1
+}
+