summaryrefslogtreecommitdiffstats
path: root/core/modules/hardware-stats/data/opt/openslx/scripts
diff options
context:
space:
mode:
authorSimon Rettberg2017-07-12 14:12:48 +0200
committerSimon Rettberg2017-07-12 14:12:48 +0200
commitc70af5479c890b109ffa12617def457e49f7baf1 (patch)
treee655d3fc498646a674dd437768ec074aab8d0746 /core/modules/hardware-stats/data/opt/openslx/scripts
parent[rfs-stage31] init: Create /tmp early, unmount before switchroot (diff)
downloadmltk-c70af5479c890b109ffa12617def457e49f7baf1.tar.gz
mltk-c70af5479c890b109ffa12617def457e49f7baf1.tar.xz
mltk-c70af5479c890b109ffa12617def457e49f7baf1.zip
[init, etc] Pass system-uuid when fetching config & config.tgz
Also save the system-uuid for later use in stage32+, which changed locations from /run to /etc - modules got updated accordingly
Diffstat (limited to 'core/modules/hardware-stats/data/opt/openslx/scripts')
-rwxr-xr-xcore/modules/hardware-stats/data/opt/openslx/scripts/cron-system_usage_update4
-rwxr-xr-xcore/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update2
-rwxr-xr-xcore/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats26
3 files changed, 7 insertions, 25 deletions
diff --git a/core/modules/hardware-stats/data/opt/openslx/scripts/cron-system_usage_update b/core/modules/hardware-stats/data/opt/openslx/scripts/cron-system_usage_update
index df8dab45..8a8bc642 100755
--- a/core/modules/hardware-stats/data/opt/openslx/scripts/cron-system_usage_update
+++ b/core/modules/hardware-stats/data/opt/openslx/scripts/cron-system_usage_update
@@ -1,11 +1,11 @@
#!/bin/ash
-[ -r "/run/system-uuid" ] || exit 0
+[ -r "/etc/system-uuid" ] || exit 0
. /opt/openslx/config
[ -z "$SLX_REMOTE_LOG" ] && exit 0
-UUID=$(cat "/run/system-uuid")
+UUID=$(cat "/etc/system-uuid")
[ -z "$UUID" ] && exit 1
diff --git a/core/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update b/core/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update
index dc9f8f73..ce474fa2 100755
--- a/core/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update
+++ b/core/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update
@@ -3,7 +3,7 @@
. /opt/openslx/config
[ -z "$SLX_REMOTE_LOG" ] && exit 0
-UUID=$(cat /run/system-uuid)
+UUID=$(cat /etc/system-uuid)
[ -z "$UUID" ] && exit 1
diff --git a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
index 618326aa..9e959ecb 100755
--- a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
+++ b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
@@ -78,30 +78,13 @@ fi
MAC=${BOOTIF:3}
# 2) Get machine UUID, with fallback to MAC address if it fails for some reason, or if the UUID is blacklisted
-UUID=$(dmidecode -q -s system-uuid | grep -v '^#' | head -n 1 | tr '[a-z]' '[A-Z]')
+UUID=$(cat /etc/system-uuid)
+if [ -z "$UUID" ] || [ "${#UUID}" -ne "36" ]; then
+ UUID=$(dmidecode -q -s system-uuid | grep -v '^#' | head -n 1 | tr '[a-z]' '[A-Z]')
+fi
if [ "${#UUID}" -ne "36" ]; then
echo "Determined UUID (${UUID}) has not expected length of 36, falling back to MAC..."
UUID="000000000000000-$BOOTIF"
-else
- # Got UUID, check blacklist
- DIR="/opt/openslx/hardware-stats/bad-uuid.d"
- TMPLIST=$(mktemp)
- BADLIST="/run/bad-uuids"
- for file in "$DIR"/*; do
- [ -f "$file" ] || continue
- # 11111111-2222-3333-4444-555555555555
- < "$file" tr '[a-z]' '[A-Z]' | grep -Po '[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{12}'
- done | tee "$TMPLIST" > "$BADLIST"
- # Also add flipped version of bad uuids. Found some of them through googling and discovered that sometimes
- # users report them in a different order. UUIDs use different endianness for the first three blocks than
- # the remaining two, but some tools seem to ignore that fact.
- < "$BADLIST" sed -r 's/^(..)(..)(..)(..)\-(..)(..)\-(..)(..)\-([0-9A-F]{4}\-[0-9A-F]{12})$/\4\3\2\1-\6\5-\8\7-\9/' >> "$TMPLIST"
- # Finally make unique
- sort -u "$TMPLIST" > "$BADLIST"
- if grep -Fxq "$UUID" "$BADLIST"; then
- echo "WARNING: UUID is blacklisted as potentially not being unique, using MAC fallback"
- UUID="000000000000000-$BOOTIF"
- fi
fi
# 3) Uptime in seconds
@@ -299,7 +282,6 @@ for DELAY in 1 1 0; do
--data-urlencode "badsectors=$BADSECTORS" --data-urlencode "systemmodel=$MODEL" \
--data-urlencode "data@$DATAFILE" "$SLX_REMOTE_LOG" | grep -q "RESULT=0"; then
rm -f -- "$DATAFILE"
- echo "$UUID" > "/run/system-uuid"
START=$(( $RANDOM % 5 ))
cat > "/etc/cron.d/usage_stats" <<-EOF
# Update usage statistics on server