Skip to content

Commit 265aee6

Browse files
committed
fixes #19 by using package managers and checking for missing libraries and attempting to install them.
1 parent 68d8076 commit 265aee6

1 file changed

Lines changed: 49 additions & 4 deletions

File tree

‎bash/install_bigfix.sh‎

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,16 @@ fi
359359
# install BigFix client
360360
if [[ $INSTALLER == *.deb ]]; then
361361
# debian (DEB)
362-
dpkg -i $INSTALLER
362+
# Prefer apt-get so runtime dependencies get resolved automatically on
363+
# minimal or container images. Fall back to dpkg (no dependency
364+
# resolution) if apt-get is missing or fails (e.g. empty package lists).
365+
# The ./ prefix makes apt-get treat it as a local file, not a repo package.
366+
# see the issue this solves: https://github.com/jgstew/tools/issues/19
367+
if command_exists apt-get ; then
368+
apt-get install -y "./$INSTALLER" || dpkg -i $INSTALLER
369+
else
370+
dpkg -i $INSTALLER
371+
fi
363372
fi
364373
if [[ $INSTALLER == *.pkg ]]; then
365374
# PKG type
@@ -377,12 +386,48 @@ if [[ $INSTALLER == *.pkg ]]; then
377386
fi # *.pkg install file
378387
if [[ $INSTALLER == *.rpm ]]; then
379388
# linux (RPM)
380-
# if file `/etc/init.d/besclient` exists then do upgrade
389+
# if file `/etc/init.d/besclient` exists then stop before upgrade
381390
if [ -f /etc/init.d/besclient ]; then
382391
/etc/init.d/besclient stop
383-
rpm -U $INSTALLER
392+
fi
393+
# Prefer a dependency resolving package manager (dnf, then yum) so runtime
394+
# dependencies like libstdc++ get pulled in automatically on minimal or
395+
# container images. Fall back to plain rpm, which does not resolve
396+
# dependencies, since some environments only have the rpm command.
397+
# The ./ prefix makes dnf/yum treat it as a local file, not a repo package.
398+
# see the issue this solves: https://github.com/jgstew/tools/issues/19
399+
if command_exists dnf ; then
400+
dnf install -y "./$INSTALLER"
401+
elif command_exists yum ; then
402+
yum install -y "./$INSTALLER"
384403
else
385-
rpm -ivh $INSTALLER
404+
# if file `/etc/init.d/besclient` exists then do upgrade
405+
if [ -f /etc/init.d/besclient ]; then
406+
rpm -U $INSTALLER
407+
else
408+
rpm -ivh $INSTALLER
409+
fi
410+
fi
411+
412+
# The BESAgent rpm does not declare its shared library dependencies
413+
# (verified against 11.0.6.137: `rpm -qp --requires` lists no sonames),
414+
# so even a dependency resolving package manager cannot pull them in.
415+
# Instead ask ldd which libraries are actually missing and install
416+
# whatever package provides that soname (e.g. minimal container images
417+
# are missing libdbus-1.so.3 and sometimes libstdc++.so.6).
418+
# Nothing is hardcoded here so this adapts if the missing library changes.
419+
# see the issue this solves: https://github.com/jgstew/tools/issues/19
420+
if command_exists ldd && [ -f /opt/BESClient/bin/BESClient ]; then
421+
for MISSINGLIB in `ldd /opt/BESClient/bin/BESClient 2>/dev/null | grep "not found" | awk '{print $1}' | sort -u`; do
422+
echo "BESClient requires missing library: $MISSINGLIB - attempting to install it"
423+
if command_exists dnf ; then
424+
dnf install -y "$MISSINGLIB()(64bit)" || dnf install -y "$MISSINGLIB"
425+
elif command_exists yum ; then
426+
yum install -y "$MISSINGLIB()(64bit)" || yum install -y "$MISSINGLIB"
427+
else
428+
(>&2 echo "WARNING: no package manager available to install $MISSINGLIB - BESClient may not run")
429+
fi
430+
done
386431
fi
387432
fi
388433

0 commit comments

Comments
 (0)