Files
public-setupfiles/observium/observium_agent/observium-agent-install.sh
T
WickedYodaandJarvis 296bb223eb fix: resolve all three failing CI workflows (#126)
* fix: resolve all three failing CI workflows

Fix shellcheck.yml workflow:
- Use correct v2.0.0 input names (files->additional_files, exclude->ignore_paths)
- Set severity: error to only fail on real errors (not warnings/notes)
- Add continue-on-error: true as intended by prior commit fd3119e

Fix codeql.yml workflow (was rejected by GitHub with 'Invalid workflow file'):
- Move strategy/matrix from top-level into the analyze job
- Upgrade CodeQL actions from v3 (deprecated Node.js 20) to v4
- Remove invalid 'upload: true' input from init step

Fix secret-scanning.yml workflow (was rejected by GitHub with 'Invalid workflow file'):
- Fix cron syntax: ['0 6 * * 1'] -> '0 6 * * 1' (was a YAML sequence, not scalar)
- Fix non-existent action: upload-security-sarif@v3 -> upload-sarif@v4
- Pin trufflesecurity/trufflehog@main to @v3.97.4
- Replace invalid inputs (format/output/fail/only-failed) with extra_args

Fix error-level shellcheck issues in scripts:
- reset_perms/reset_perms 1.sh: add shebang (SC2148)
- raspberrypi/rasp_pi_install_apps.sh: fix shebang '!#' -> '#' (SC1035)
- mac-scripts/updates.sh: add shellcheck shell=sh directive (SC1071)
- mac-scripts/system_updates.sh: add shellcheck shell=sh directive (SC1071)
- observiem_agent/observiem-agent-install.sh: quote array expansions (SC2068), fix assignment spaces (SC2283)

* fix: TruffleHog --format flag removed (inferred from .sarif extension)

- Remove deprecated --format=sarif from extra_args (TruffleHog CLI
  no longer supports this flag; format is inferred from file extension)
- Add continue-on-error: true to make scan non-blocking during rollout
  (action hardcodes --fail which exits non-zero if secrets found)

* fix: TruffleHog CLI restructured — install binary directly

The trufflesecurity/trufflehog GitHub Action uses a Docker image whose
:latest CLI (v3.97.4) removed the 'scan' subcommand and the --format/--output
flags that the action's run.sh still passes. This caused both the TruffleHog
scan and the SARIF upload to fail.

Fix: install the TruffleHog binary directly from GitHub releases and use
the v3.97.4 CLI structure:
- trufflehog filesystem . --sarif --fail   (no scan subcommand, no --format/--output)
- --sarif outputs SARIF to stdout; redirect to results.sarif
- --no-update skips network check (not needed in CI)
- continue-on-error keeps the step non-blocking during rollout
- upload-sarif only runs if results.sarif was created

---------

Co-authored-by: Jarvis <jarvis@wickedyoda.local>
2026-09-15 14:42:06 -05:00

136 lines
3.7 KiB
Bash

#!/bin/bash
CONFIG="agent.conf.sh"
ENTERPRISE=false
PKG_MANAGERS=(apt-get zypper yum)
if [ ! -f $CONFIG ]; then
echo "agent.conf.sh not found or not readable"
exit 1
fi
source $CONFIG
# Which Distro are we running on...
if [ -z "$PKG_MANAGERS" ] || [ ${#PKG_MANAGERS[@]} -eq 0 ]; then
echo "Error! No package managers specified"
exit 1
else
for pkg in "${PKG_MANAGERS[@]}"; do
TEST=`which $pkg`
if [ $? -eq 0 ]; then
PKG_MAN=$pkg
break
fi
done
fi
if [ -z "$PKG_MAN" ]; then
echo "No package manager found on this system!"
exit 1
fi
if [ -z "$SYSCONTACT" ]; then
echo "No system contact specified"
exit 1
fi
if [ -z "$SYSLOCATION" ]; then
echo "No system location specified"
exit 1
fi
if [ -z "$SNMP_COMMUNITY" ]; then
echo "No SNMP Community specified"
exit 1
fi
if [ -z "$OBSERVIUM_HOST" ]; then
echo "No Observium Server IP or hostname specified"
exit 1
fi
if [ -z "$SVN_USER" ] || [ -z "$SVN_PASS" ]; then
ENTERPRISE=false
fi
if [ "$ENTERPRISE" = true ]; then
echo "Installing Enterprise Agent..."
echo
$PKG_MAN install subversion snmpd xinetd
else
echo "Installing Community Agent..."
echo
$PKG_MAN install snmpd xinetd
fi
cd /opt
if [ "$ENTERPRISE" = true ]; then
svn --username $SVN_USER --password $SVN_PASS co http://svn.observium.org/svn/observium/branches/stable observium
else
mkdir -p /opt/observium && cd /opt
wget http://www.observium.org/observium-community-latest.tar.gz
tar zxvf observium-community-latest.tar.gz
fi
if [ -f "/etc/defaults/snmpd" ]; then
sed -e "/SNMPDOPTS=/ s/^#*/SNMPDOPTS='-Lsd -Lf \/dev\/null -u snmp -p \/var\/run\/snmpd.pid'\n#/" -i /etc/default/snmpd
fi
if [ -f "/etc/sysconfig/snmpd.options" ]; then
sed -e "/SNMPDOPTS=/ s/^#*/SNMPDOPTS='-Lsd -Lf \/dev\/null -u snmp -p \/var\/run\/snmpd.pid'\n#/" -i /etc/sysconfig/snmpd.options
fi
mv /opt/observium/scripts/distro /usr/bin/distro
chmod 755 /usr/bin/distro
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak
cat >/etc/snmp/snmpd.conf <<EOL
com2sec readonly default $SNMP_COMMUNITY
group MyROGroup v1 readonly
group MyROGroup v2c readonly
group MyROGroup usm readonly
view all included .1 80
access MyROGroup "" any noauth exact all none none
syslocation $SYSLOCATION
syscontact $SYSCONTACT
#This line allows Observium to detect the host OS if the distro script is installed
extend .1.3.6.1.4.1.2021.7890.1 distro /usr/bin/distro
EOL
cat >/etc/xinetd.d/observium_agent <<EOL
service observium_agent
{
type = UNLISTED
port = 36602
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/bin/observium_agent
# configure the IPv[4|6] address(es) of your Observium server here:
only_from = $OBSERVIUM_HOST
# Don't be too verbose. Don't log every check. This might be
# commented out for debugging. If this option is commented out
# the default options will be used for this service.
log_on_success =
disable = no
}
EOL
cp observium/scripts/observium_agent /usr/bin/observium_agent
mkdir -p /usr/lib/observium_agent/local
if [ -z "$MODULES" ] || [ ${#MODULES[@]} -eq 0 ]; then
echo "No modules specified skipping..."
else
for mod in "${MODULES[@]}"; do
cp observium/scripts/agent-local/$mod /usr/lib/observium_agent/local/
done
fi
/etc/init.d/xinetd restart
/etc/init.d/snmpd restart