Improve the reception of replies in the confd client
[ganeti-local] / daemons / daemon-util.in
index 5bf2c3f..786c4b0 100644 (file)
@@ -20,7 +20,9 @@
 
 set -e
 
-defaults_file=@SYSCONFDIR@/default/ganeti
+@SHELL_ENV_INIT@
+
+readonly defaults_file="$SYSCONFDIR/default/ganeti"
 
 # This is a list of all daemons and the order in which they're started. The
 # order is important as there are dependencies between them. On shutdown,
@@ -31,7 +33,11 @@ DAEMONS=(
   ganeti-rapi
   )
 
-if [[ "@CUSTOM_ENABLE_CONFD@" == True ]]; then
+_confd_enabled() {
+  [[ "@CUSTOM_ENABLE_CONFD@" == True ]]
+}
+
+if _confd_enabled; then
   DAEMONS+=( ganeti-confd )
 fi
 
@@ -52,7 +58,7 @@ _ignore_error() {
 }
 
 _daemon_pidfile() {
-  echo "@LOCALSTATEDIR@/run/ganeti/$1.pid"
+  echo "$RUN_DIR/$1.pid"
 }
 
 _daemon_executable() {
@@ -81,7 +87,7 @@ _daemon_usergroup() {
 
 # Checks whether the local machine is part of a cluster
 check_config() {
-  local server_pem=@LOCALSTATEDIR@/lib/ganeti/server.pem
+  local server_pem=$DATA_DIR/server.pem
   local fname
 
   for fname in $server_pem; do
@@ -203,20 +209,18 @@ start() {
   fi
 
   local name="$1"; shift
+  # Convert daemon name to uppercase after removing "ganeti-" prefix
+  local plain_name=${name#ganeti-}
+  local ucname=$(tr a-z A-Z <<<$plain_name)
   local pidfile=$(_daemon_pidfile $name)
   local usergroup=$(_daemon_usergroup $plain_name)
   local daemonexec=$(_daemon_executable $name)
 
-  if [[ "$name" == ganeti-confd &&
-        "@CUSTOM_ENABLE_CONFD@" == False ]]; then
+  if [[ "$name" == ganeti-confd ]] && ! _confd_enabled; then
     echo 'ganeti-confd disabled at build time' >&2
     return 1
   fi
 
-  # Convert daemon name to uppercase after removing "ganeti-" prefix
-  local plain_name=${name#ganeti-}
-  local ucname=$(tr a-z A-Z <<<$plain_name)
-
   # Read $<daemon>_ARGS and $EXTRA_<daemon>_ARGS
   eval local args="\"\$${ucname}_ARGS \$EXTRA_${ucname}_ARGS\""