]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Salt-minion and componentMgr plugin updates.
authorJohn Wolfe <jwolfe@vmware.com>
Sat, 25 Dec 2021 17:51:13 +0000 (09:51 -0800)
committerJohn Wolfe <jwolfe@vmware.com>
Sat, 25 Dec 2021 17:51:13 +0000 (09:51 -0800)
Lastest version of the Salt Minion installer script.
The poll-interval of the componentMgr can be set to a minimum value of
five (5) seconds when compiled with -DVMX86_DEBUG.

open-vm-tools/services/plugins/componentMgr/componentMgr.c
open-vm-tools/services/plugins/componentMgr/componentMgrInstallAction.c
open-vm-tools/services/plugins/componentMgr/componentMgrPlugin.h
open-vm-tools/services/plugins/componentMgr/svtminion.sh

index 971a12238eca6176a938ff4953fd8cf0bcdd68b7..3fde4c6f18b652ed775ebe5be707407a430998f2 100644 (file)
@@ -29,7 +29,6 @@
 
 #include "componentMgrPlugin.h"
 #include "str.h"
-#include "conf.h"
 #include "vm_version.h"
 #include "embed_version.h"
 #include "vmtoolsd_version.h"
@@ -113,11 +112,11 @@ ReconfigureComponentMgrPollLoopEx(ToolsAppCtx *ctx,  // IN
    }
 
    if (pollInterval != 0) {
-      if (pollInterval < COMPONENTMGR_POLL_INTERVAL ||
+      if (pollInterval < COMPONENTMGR_MIN_POLL_INTERVAL ||
          pollInterval > (G_MAXINT / 1000)) {
          g_warning("%s: Invalid poll interval. Using default %us.\n",
-                   __FUNCTION__, COMPONENTMGR_POLL_INTERVAL);
-         pollInterval = COMPONENTMGR_POLL_INTERVAL;
+                   __FUNCTION__, COMPONENTMGR_DEFAULT_POLL_INTERVAL);
+         pollInterval = COMPONENTMGR_DEFAULT_POLL_INTERVAL;
       }
 
       g_info("%s: New value for %s is %us.\n", __FUNCTION__,
@@ -215,7 +214,7 @@ ComponentMgrPollLoop(ToolsAppCtx *ctx) // IN
    pollInterval = VMTools_ConfigGetInteger(ctx->config,
                                            COMPONENTMGR_CONF_GROUPNAME,
                                            COMPONENTMGR_CONF_POLLINTERVAL,
-                                           COMPONENTMGR_POLL_INTERVAL);
+                                           COMPONENTMGR_DEFAULT_POLL_INTERVAL);
 
    listString = VMTools_ConfigGetString(ctx->config,
                                         COMPONENTMGR_CONF_GROUPNAME,
index 3ac3743b5811a1cd2d6f7608380cf485191f4a04..697d39fd4ff1fdcc4b7721db550864004be21ee6 100644 (file)
@@ -36,7 +36,6 @@
 #include "util.h"
 #include "guestApp.h"
 #include "codeset.h"
-#include "conf.h"
 
 
 /*
index 771013799d66c1131fd873d187caff21bf67c751..667ef9603332a956c00e24f1589897c2c22de897 100644 (file)
  *
  */
 
-#define G_LOG_DOMAIN "componentMgr"
+
+#include "conf.h"
+
+#define G_LOG_DOMAIN COMPONENTMGR_CONF_GROUPNAME
 
 #include "vm_basic_defs.h"
 #include "vmware/tools/plugin.h"
 /**
  * Default and minimum poll interval for componentMgr in seconds.
  */
-#define COMPONENTMGR_POLL_INTERVAL 180
+#define COMPONENTMGR_DEFAULT_POLL_INTERVAL 180
+
+/**
+ * Minimum poll interval for componentMgr in seconds.
+ * For development and beta builds the poll-interval can be configured
+ * lower than the default poll-interval.
+ */
+#ifdef VMX86_DEBUG
+#define COMPONENTMGR_MIN_POLL_INTERVAL 5
+#else
+#define COMPONENTMGR_MIN_POLL_INTERVAL COMPONENTMGR_DEFAULT_POLL_INTERVAL
+#endif
 
 /*
  * Poll interval between 2 consecutive check status operation in seconds.
index ef42bfccc8d638df587d2e66dad99629d020c837..18b22c09086fd5053b578e0bd30c571deb716298 100644 (file)
@@ -14,7 +14,7 @@ set -o pipefail
 # using bash for now
 # run this script as root, as needed to run salt
 
-readonly SCRIPT_VERSION='1.0'
+readonly SCRIPT_VERSION='1.1'
 
 # definitions
 
@@ -46,7 +46,9 @@ readonly list_file_dirs_to_remove="${base_salt_location}
 /var/cache/salt
 /var/log/salt
 /usr/bin/salt-*
+/lib/systemd/system/salt-minion.service
 /usr/lib/systemd/system/salt-minion.service
+/usr/local/lib/systemd/system/salt-minion.service
 /etc/systemd/system/salt-minion.service
 "
 ## /var/log/vmware-${SCRIPTNAME}-*
@@ -1186,7 +1188,6 @@ _status_fn() {
 #
 #   Check dependencies for using salt-minion
 #
-#
 # Side Effects:
 # Results:
 #   Exits with 0 or error code
@@ -1213,6 +1214,45 @@ _deps_chk_fn() {
     return 0
 }
 
+#
+# _find_system_lib_path
+#
+# find with systemd library path to use
+#
+# Result:
+#   echos the systemd library path
+#   will error if no systemd library path can be determined
+#
+# Note:
+#   /lib/systemd/system
+#       System units installed by the distribution package manage
+#   /usr/lib/systemd/system
+#       System units installed by the Administrator
+#   /usr/local/lib/systemd/system
+#       System units installed by the Administrator (possible on some OS)
+#
+# Will use /usr/lib/systemd/system available, since this is generally
+# the default used on modern Linux OS by salt-minion, some earlier OS's
+# (Debian 9, Ubuntu 18.04) use /lib/systemd/system
+#
+_find_system_lib_path () {
+
+    local path_found=""
+    _info_log "$0:${FUNCNAME[0]} finding systemd library path to use"
+    if [[ -d "/usr/lib/systemd/system" ]]; then
+        path_found="/usr/lib/systemd/system"
+    elif [[ -d "/lib/systemd/system" ]]; then
+        path_found="/lib/systemd/system"
+    elif [[ -d "/usr/local/lib/systemd/system" ]]; then
+        path_found="/usr/local/lib/systemd/system"
+    else
+        _error_log "$0:${FUNCNAME[0]} unable to determine systemd"\
+        "library path to use"
+    fi
+    _debug_log "$0:${FUNCNAME[0]} found library path to use ${path_found}"
+    echo "${path_found}"
+}
+
 
 #
 #  _install_fn
@@ -1307,28 +1347,31 @@ _install_fn () {
         fi
 
         # install salt-minion systemd service script
+        # first find with systemd library path to use
+        local systemd_lib_path=""
+        systemd_lib_path=$(_find_system_lib_path)
+        local name_service="salt-minion.service"
         _debug_log "$0:${FUNCNAME[0]} copying systemd service script "\
-            "'salt-minion.service' to directory /usr/lib/systemd/system"
+            "${name_service} to directory ${systemd_lib_path}"
         echo "${salt_minion_service_wrapper}" \
-            > /usr/lib/systemd/system/salt-minion.service || {
+            > "${systemd_lib_path}/${name_service}" || {
             _error_log "$0:${FUNCNAME[0]} failed to copy systemd service "\
-                "file 'salt-minion.service' to directory "\
-                "/usr/lib/systemd/system, retcode '$?'";
+                "file ${name_service} to directory "\
+                "${systemd_lib_path}, retcode '$?'";
         }
         cd /etc/systemd/system || return $?
-        rm -f "salt-minion.service"
-        ln -s "/usr/lib/systemd/system/salt-minion.service" \
-            "salt-minion.service" || {
+        rm -f "${name_service}"
+        ln -s "${systemd_lib_path}/${name_service}" \
+            "${name_service}" || {
                 _error_log "$0:${FUNCNAME[0]} failed to symbolic link "\
-                    "systemd service file 'salt-minion.service' in "\
+                    "systemd service file ${name_service} in "\
                     "directory /etc/systemd/system, retcode '$?'";
         }
         _debug_log "$0:${FUNCNAME[0]} symbolically linked systemd service "\
-            "file 'salt-minion.service' in directory /etc/systemd/system"
+            "file ${name_service} in directory /etc/systemd/system"
         cd "${CURRDIR}" || return $?
 
         # start the salt-minion using systemd
-        local name_service="salt-minion.service"
         systemctl daemon-reload || {
             _error_log "$0:${FUNCNAME[0]} reloading the systemd daemon "\
                 "failed , retcode '$?'";