From: John Wolfe Date: Sat, 25 Dec 2021 17:51:13 +0000 (-0800) Subject: Salt-minion and componentMgr plugin updates. X-Git-Tag: stable-12.0.0~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff6e8264fedfc3237ab66b91598d998bfa7eae39;p=thirdparty%2Fopen-vm-tools.git Salt-minion and componentMgr plugin updates. 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. --- diff --git a/open-vm-tools/services/plugins/componentMgr/componentMgr.c b/open-vm-tools/services/plugins/componentMgr/componentMgr.c index 971a12238..3fde4c6f1 100644 --- a/open-vm-tools/services/plugins/componentMgr/componentMgr.c +++ b/open-vm-tools/services/plugins/componentMgr/componentMgr.c @@ -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, diff --git a/open-vm-tools/services/plugins/componentMgr/componentMgrInstallAction.c b/open-vm-tools/services/plugins/componentMgr/componentMgrInstallAction.c index 3ac3743b5..697d39fd4 100644 --- a/open-vm-tools/services/plugins/componentMgr/componentMgrInstallAction.c +++ b/open-vm-tools/services/plugins/componentMgr/componentMgrInstallAction.c @@ -36,7 +36,6 @@ #include "util.h" #include "guestApp.h" #include "codeset.h" -#include "conf.h" /* diff --git a/open-vm-tools/services/plugins/componentMgr/componentMgrPlugin.h b/open-vm-tools/services/plugins/componentMgr/componentMgrPlugin.h index 771013799..667ef9603 100644 --- a/open-vm-tools/services/plugins/componentMgr/componentMgrPlugin.h +++ b/open-vm-tools/services/plugins/componentMgr/componentMgrPlugin.h @@ -31,7 +31,10 @@ * */ -#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" @@ -47,7 +50,18 @@ /** * 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. diff --git a/open-vm-tools/services/plugins/componentMgr/svtminion.sh b/open-vm-tools/services/plugins/componentMgr/svtminion.sh index ef42bfccc..18b22c090 100644 --- a/open-vm-tools/services/plugins/componentMgr/svtminion.sh +++ b/open-vm-tools/services/plugins/componentMgr/svtminion.sh @@ -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 '$?'";