|
86 | 86 | # most recent version# found here under `Agent`: https://support.bigfix.com/bes/release/ |
87 | 87 | URLVERSION=11.0.6.137 |
88 | 88 |
|
| 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 | + |
89 | 101 | # check for x32bit or x64bit OS |
90 | 102 | MACHINETYPE=`uname -m` |
91 | 103 |
|
92 | 104 | # set OSBIT based on MACHINETYPE. Only x86-family CPUs get OSBIT=x32 (name lacks "64" but contains "86"). |
93 | 105 | # 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 |
95 | 110 | OSBIT=x32 |
96 | 111 | URLVERSION=9.5.25.11 |
97 | 112 | else |
|
101 | 116 | # (see the TODO in the rpm branch), so it would wrongly download x86_64 there. |
102 | 117 | fi |
103 | 118 |
|
104 | | -URLMAJORMINOR=`echo $URLVERSION | awk -F. '{print $1 $2}'` |
| 119 | +URLMAJORMINOR=`echo $URLVERSION | $AWK -F. '{print $1 $2}'` |
105 | 120 |
|
106 | 121 | ############################################################ |
107 | 122 | # TODO: add more linux cases, not all are handled |
|
467 | 482 | if [[ $OSTYPE != darwin* ]]; then |
468 | 483 | # if missing, create besclient.config file based upon the staged clientsettings.cfg |
469 | 484 | 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 |
471 | 486 | chmod 600 /var/opt/BESClient/besclient.config |
472 | 487 | fi |
473 | 488 |
|
@@ -495,13 +510,17 @@ sleep 10 |
495 | 510 |
|
496 | 511 | # output the contents of the log file to see if things are working: https://github.com/jgstew/tools/blob/master/bash/bigfixlogs.sh |
497 | 512 | # 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 <==" |
500 | 519 | if [ -n "$NOEXIT" ]; then |
501 | 520 | # 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" |
503 | 522 | else |
504 | | - tail --lines=25 --verbose "/var/opt/BESClient/__BESData/__Global/Logs/`date +%Y%m%d`.log" |
| 523 | + tail -n 25 "$BESLOGFILE" |
505 | 524 | fi |
506 | 525 | # Related: |
507 | 526 | # - https://bigfix.me/fixlet/details/24646 |
|
0 commit comments