Skip to content

Commit a741681

Browse files
committed
fix
1 parent 2c95585 commit a741681

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

AzureMonitorAgent/agent.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -428,23 +428,19 @@ def install():
428428
if rsyslog_exit_code != 0:
429429
return rsyslog_exit_code, rsyslog_output
430430

431-
# Check if SLES 16+ VMs have 'which' package
431+
# Check if SLES 16+ VMs have 'which' package (changed from Requires to Recommends in spec, may not be installed)
432432
if (vm_dist.startswith('suse') or vm_dist.startswith('sles')) and int(vm_ver.split('.')[0]) >= 16:
433433
check_which, _ = run_command_and_log("rpm -q which")
434434
if check_which != 0:
435-
hutil_log_info("'which' package missing from SLES {0} machine, attempting to install.".format(vm_ver))
436-
which_exit_code, which_output = run_command_and_log("zypper --non-interactive install which")
437-
if which_exit_code != 0:
438-
hutil_log_info("Could not install 'which' via zypper (exit code {0}). Creating 'which' alias using 'command -v' as fallback.".format(which_exit_code))
439-
# Create an alias so that calls to 'which' in RPM post-install scripts still work
440-
try:
441-
which_alias = "/usr/local/bin/which"
442-
with open(which_alias, "w") as f:
443-
f.write("#!/bin/sh\ncommand -v \"$@\"\n")
444-
os.chmod(which_alias, 0o755)
445-
hutil_log_info("Created 'which' alias at {0}".format(which_alias))
446-
except Exception as ex:
447-
hutil_log_error("Failed to create 'which' alias: {0}".format(ex))
435+
hutil_log_info("'which' package missing from SLES {0} machine, creating 'which' alias using 'command -v'.".format(vm_ver))
436+
try:
437+
which_alias = "/usr/local/bin/which"
438+
with open(which_alias, "w") as f:
439+
f.write("#!/bin/sh\ncommand -v \"$@\"\n")
440+
os.chmod(which_alias, 0o755)
441+
hutil_log_info("Created 'which' alias at {0}".format(which_alias))
442+
except Exception as ex:
443+
hutil_log_error("Failed to create 'which' alias: {0}".format(ex))
448444

449445
# Flag to handle the case where the same package is already installed
450446
same_package_installed = False

0 commit comments

Comments
 (0)