update-ui/send-update.log.sh

20 lines
573 B
Bash

#!/bin/bash
API_URL="http://192.168.18.4:8000/api/updatecheck/"
API_TOKEN="9d207bf0-10f5-4d8f-a479-22ff5aeff8d1"
HOSTNAME=$(hostname)
TIMESTAMP=$(date -Iseconds)
OS=$(lsb_release -ds 2>/dev/null || echo "Unknown")
KERNEL=$(uname -r)
# Pakete
PACKAGES="python3|openssh-server|nginx"
PACKAGE_VERSIONS=$(dpkg-query -W -f='${binary:Package}=${Version}\n' 2>/dev/null | grep -E "$PACKAGES" | tr '\n' ';')
# Zusammenbauen
BODY="$HOSTNAME,$TIMESTAMP,os=$OS;kernel=$KERNEL;$PACKAGE_VERSIONS"
curl -s -X POST "$API_URL" \
-H "Authorization: Bearer $API_TOKEN" \
-d "$BODY"