[#454] adopt enforcement framework + STATUS; modernize librenms agent scripts
check-rules green; shellcheck fixes to dpkg.sh/os-updates.sh (legacy backticks, unquoted vars, array-quoted command builders); Discourse pointers added to basis docs; awx/k8s/compliance repos referenced. https://projects.knownelement.com/issues/454
This commit is contained in:
@@ -5,18 +5,22 @@
|
||||
if [ -x /usr/bin/dpkg-query ]; then
|
||||
DATE=$(date +%s)
|
||||
FILE=/var/cache/librenms/agent-local-dpkg
|
||||
|
||||
|
||||
[ -d /var/cache/librenms ] || mkdir -p /var/cache/librenms
|
||||
|
||||
if [ ! -e $FILE ]; then
|
||||
dpkg-query -W --showformat='${Status} ${Package} ${Version} ${Architecture} ${Installed-Size}\n'|grep " installed "|cut -d\ -f4- > $FILE
|
||||
|
||||
refresh() {
|
||||
dpkg-query -W --showformat='${Status} ${Package} ${Version} ${Architecture} ${Installed-Size}\n' \
|
||||
| grep " installed " | cut -d\ -f4- > "$FILE"
|
||||
}
|
||||
|
||||
if [ ! -e "$FILE" ]; then
|
||||
refresh
|
||||
fi
|
||||
FILEMTIME=$(stat -c %Y $FILE)
|
||||
FILEAGE=$(($DATE-$FILEMTIME))
|
||||
if [ $FILEAGE -gt 1800 ]; then
|
||||
dpkg-query -W --showformat='${Status} ${Package} ${Version} ${Architecture} ${Installed-Size}\n'|grep " installed "|cut -d\ -f4- > $FILE
|
||||
FILEMTIME=$(stat -c %Y "$FILE")
|
||||
FILEAGE=$((DATE - FILEMTIME))
|
||||
if [ "$FILEAGE" -gt 1800 ]; then
|
||||
refresh
|
||||
fi
|
||||
echo "<<<dpkg>>>"
|
||||
cat $FILE
|
||||
cat "$FILE"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user