Skip to content

Commit 783ebd0

Browse files
jgstewclaude
andcommitted
fix install_bigfix.sh Solaris branch: awk, tail, and i86pc arch detection
The new Solaris e2e test surfaced three real bugs in the Solaris (pkgadd) branch, all confirmed in CI: - awk: Solaris /usr/bin/awk is the ancient oawk, which has no gsub() and misparses the bare /=/ regex as the /= operator, so besclient.config generation errored out. Prefer nawk / xpg4 awk (POSIX); no-op on Linux where awk is already gawk/mawk. Also rewrote `/=/` as `$0 ~ /=/`. - tail: `tail --lines=25 --verbose` uses GNU long options that Solaris /usr/bin/tail rejects, exiting nonzero and failing the whole script (the observed exit code 2). Use POSIX `tail -n 25` / `tail -f` and print the filename ourselves. - arch: `uname -m` returns "i86pc" on 64-bit Solaris x86, which the OSBIT heuristic misread as 32-bit and forced BigFix 9.5. Exclude i86pc so Solaris gets the 64-bit BigFix 11 pkg. Verified: Linux deb+rpm e2e still pass (awk/tail changes are portable). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent bb1bb04 commit 783ebd0

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

‎bash/install_bigfix.sh‎

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,27 @@ fi
8686
# most recent version# found here under `Agent`: https://support.bigfix.com/bes/release/
8787
URLVERSION=11.0.6.137
8888

89+
# Pick a modern awk. Solaris /usr/bin/awk is the ancient oawk: it has no
90+
# gsub() and misparses the /=/ regex as the /= operator (breaks the
91+
# besclient.config generator below). nawk and /usr/xpg4/bin/awk are POSIX.
92+
# On Linux awk is already gawk/mawk and nawk is normally absent, so this
93+
# resolves back to plain awk there - a no-op.
94+
AWK=awk
95+
if command_exists nawk ; then
96+
AWK=nawk
97+
elif [ -x /usr/xpg4/bin/awk ] ; then
98+
AWK=/usr/xpg4/bin/awk
99+
fi
100+
89101
# check for x32bit or x64bit OS
90102
MACHINETYPE=`uname -m`
91103

92104
# set OSBIT based on MACHINETYPE. Only x86-family CPUs get OSBIT=x32 (name lacks "64" but contains "86").
93105
# Anything else (x86_64, aarch64, ppc64le, s390x, armv7l, ...) gets OSBIT=x64 and is disambiguated below.
94-
if [[ $MACHINETYPE != *"64"* ]] && [[ $MACHINETYPE == *"86"* ]]; then
106+
# Solaris x86 reports "i86pc" from `uname -m` for 64-bit hardware too (it is a
107+
# platform token, not a bitness), so it is excluded here - BigFix 11 ships a
108+
# 64-bit Solaris pkg and Solaris 11 is 64-bit only.
109+
if [[ $MACHINETYPE != *"64"* ]] && [[ $MACHINETYPE == *"86"* ]] && [[ $MACHINETYPE != "i86pc" ]]; then
95110
OSBIT=x32
96111
URLVERSION=9.5.25.11
97112
else
@@ -101,7 +116,7 @@ else
101116
# (see the TODO in the rpm branch), so it would wrongly download x86_64 there.
102117
fi
103118

104-
URLMAJORMINOR=`echo $URLVERSION | awk -F. '{print $1 $2}'`
119+
URLMAJORMINOR=`echo $URLVERSION | $AWK -F. '{print $1 $2}'`
105120

106121
############################################################
107122
# TODO: add more linux cases, not all are handled
@@ -467,7 +482,7 @@ fi
467482
if [[ $OSTYPE != darwin* ]]; then
468483
# if missing, create besclient.config file based upon the staged clientsettings.cfg
469484
if [ ! -f /var/opt/BESClient/besclient.config ]; then
470-
cat "$STAGED_CFG" | awk 'BEGIN { print "[Software\\BigFix\\EnterpriseClient]"; print "EnterpriseClientFolder = /opt/BESClient"; print; print "[Software\\BigFix\\EnterpriseClient\\GlobalOptions]"; print "StoragePath = /var/opt/BESClient"; print "LibPath = /opt/BESClient/BESLib"; } /=/ {gsub(/=/, " "); print "\n[Software\\BigFix\\EnterpriseClient\\Settings\\Client\\" $1 "]\nvalue = " $2;}' > /var/opt/BESClient/besclient.config
485+
cat "$STAGED_CFG" | $AWK 'BEGIN { print "[Software\\BigFix\\EnterpriseClient]"; print "EnterpriseClientFolder = /opt/BESClient"; print; print "[Software\\BigFix\\EnterpriseClient\\GlobalOptions]"; print "StoragePath = /var/opt/BESClient"; print "LibPath = /opt/BESClient/BESLib"; } $0 ~ /=/ {gsub(/=/, " "); print "\n[Software\\BigFix\\EnterpriseClient\\Settings\\Client\\" $1 "]\nvalue = " $2;}' > /var/opt/BESClient/besclient.config
471486
chmod 600 /var/opt/BESClient/besclient.config
472487
fi
473488

@@ -495,13 +510,17 @@ sleep 10
495510

496511
# output the contents of the log file to see if things are working: https://github.com/jgstew/tools/blob/master/bash/bigfixlogs.sh
497512
# TODO: add mac support to the following:
498-
if [ -f "/var/opt/BESClient/__BESData/__Global/Logs/`date +%Y%m%d`.log" ]; then
499-
513+
BESLOGFILE="/var/opt/BESClient/__BESData/__Global/Logs/`date +%Y%m%d`.log"
514+
if [ -f "$BESLOGFILE" ]; then
515+
# -n/-f are POSIX; the old GNU long options (--lines/--verbose) are not
516+
# accepted by Solaris /usr/bin/tail (it exited nonzero and failed the whole
517+
# script). Print the filename ourselves in place of GNU --verbose.
518+
echo "==> $BESLOGFILE <=="
500519
if [ -n "$NOEXIT" ]; then
501520
# tail log forever if NOEXIT set to anything
502-
tail --verbose "/var/opt/BESClient/__BESData/__Global/Logs/`date +%Y%m%d`.log"
521+
tail -f "$BESLOGFILE"
503522
else
504-
tail --lines=25 --verbose "/var/opt/BESClient/__BESData/__Global/Logs/`date +%Y%m%d`.log"
523+
tail -n 25 "$BESLOGFILE"
505524
fi
506525
# Related:
507526
# - https://bigfix.me/fixlet/details/24646

0 commit comments

Comments
 (0)