diff options
author | Simon Rettberg | 2017-07-12 14:12:48 +0200 |
---|---|---|
committer | Simon Rettberg | 2017-07-12 14:12:48 +0200 |
commit | c70af5479c890b109ffa12617def457e49f7baf1 (patch) | |
tree | e655d3fc498646a674dd437768ec074aab8d0746 /core/modules | |
parent | [rfs-stage31] init: Create /tmp early, unmount before switchroot (diff) | |
download | mltk-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')
-rw-r--r-- | core/modules/hardware-stats/data/etc/X11/Xsetup.d/99-detect-screens | 2 | ||||
-rwxr-xr-x | core/modules/hardware-stats/data/opt/openslx/scripts/cron-system_usage_update | 4 | ||||
-rwxr-xr-x | core/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update | 2 | ||||
-rwxr-xr-x | core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats | 26 | ||||
-rw-r--r-- | core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc | 29 | ||||
-rwxr-xr-x | core/modules/system-uuid/data/bin/get-uuid | 40 | ||||
-rw-r--r-- | core/modules/system-uuid/data/opt/openslx/bad-uuid.d/00-default (renamed from core/modules/hardware-stats/data/opt/openslx/hardware-stats/bad-uuid.d/00-default) | 0 | ||||
-rw-r--r-- | core/modules/system-uuid/module.build | 13 | ||||
-rw-r--r-- | core/modules/system-uuid/module.conf | 4 |
9 files changed, 94 insertions, 26 deletions
diff --git a/core/modules/hardware-stats/data/etc/X11/Xsetup.d/99-detect-screens b/core/modules/hardware-stats/data/etc/X11/Xsetup.d/99-detect-screens index 879cfe96..74f77621 100644 --- a/core/modules/hardware-stats/data/etc/X11/Xsetup.d/99-detect-screens +++ b/core/modules/hardware-stats/data/etc/X11/Xsetup.d/99-detect-screens @@ -11,7 +11,7 @@ bash <<"HEREDOC" . /opt/openslx/config [ -z "$SLX_REMOTE_LOG" ] && exit 0 - UUID=$( cat /run/system-uuid ) + UUID=$( cat /etc/system-uuid ) [ -z "$UUID" ] && exit 0 XRANDR=$( mktemp ) TMP=$( mktemp ) 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 diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc index 9db578c1..668dfa86 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc @@ -85,10 +85,39 @@ setup_fallback() { readonly VM_DISKFILE_RO } +setup_jambo() { + declare -r CMDLOG="$TMPDIR/sshfs.jambo" + declare -rg CLIENTPARTITION_ADMIN="/var/lib/vmware_admin" + #declare -r UPLOAD_KEYFILE="/var/lib/uploaduser" + #sudo -n sshfs "uploaduser@$JAMBOSERVER:/vms/bwlehrpool_store" "$CLIENTPARTITION_ADMIN" -o allow_other -o PreferredAuthentications=publickey -o IdentityFile="$UPLOAD_KEYFILE" -o IdentitiesOnly=yes &> "$CMDLOG" + sudo -n sshfs "uploaduser@$JAMBOSERVER:/vms/bwlehrpool_store" "$CLIENTPARTITION_ADMIN" -o allow_other -o PreferredAuthentications=publickey &> "$CMDLOG" + RET=$? + if [ "$RET" != "0" ]; then + writelog "SSHFS Failed + $(cat "$CMDLOG")" + EXIT_TYPE="user" EXIT_REASON="Schreibbarer VM-Speicher konnte nicht eingebunden werden. Adminmodus fehlgeschlagen." cleanexit 1 + fi + declare -rg VM_DISKFILE_RW="$CLIENTPARTITION_ADMIN/$SRC_IMG_RELATIVE" +} + ## MAIN PART / Sanity checks ## setup_image_access() { writelog "Setting up virtual hard disk access for virtualizer/emulator ..." + + if [ "$VMCHOOSER_ADMIN_MODE" = "TRUE" ] && [ -n "$SLX_JAMBOSERVER" ]; then + setup_jambo + writelog "\tVM disk file RW:\t\t$VM_DISKFILE_RW" + if ! [ -s "$VM_DISKFILE_RW" ]; then + writelog ".... not found!" + EXIT_TYPE="user" EXIT_REASON="Schreibbare VM nicht gefunden. Adminmodus fehlgeschlagen." cleanexit 1 + fi + if ! [ -w "$VM_DISKFILE_RW" ]; then + writelog ".... not writable!" + EXIT_TYPE="user" EXIT_REASON="VM-Image auf schreibbarem VM-Speicher nicht schreibbar. Adminmodus fehlgeschlagen." cleanexit 1 + fi + return 0 + fi unset VM_DISKFILE_RO declare -g VM_DISKFILE_RO diff --git a/core/modules/system-uuid/data/bin/get-uuid b/core/modules/system-uuid/data/bin/get-uuid new file mode 100755 index 00000000..30ef3cf9 --- /dev/null +++ b/core/modules/system-uuid/data/bin/get-uuid @@ -0,0 +1,40 @@ +#!/bin/ash + +eval $(grep -Eo BOOTIF=\\S+ /proc/cmdline) +if [ "${#BOOTIF}" -ne "20" ]; then + echo "Getting MAC from /proc/cmdline failed, using 'ip a'..." + BOOTIF=01-$(ip a | grep -A 1 ': br0' | grep -o 'ether ..:..:..:..:..:..' | cut -d' ' -f2 | sed s/:/-/g) + if [ "${#BOOTIF}" -ne "20" ]; then + echo "FAIL FAIL FAIL" + BOOTIF="99-88-77-66-55-44-33" + fi +fi + +UUID=$(dmidecode -q -s system-uuid | grep -v '^#' | head -n 1 | tr '[a-z]' '[A-Z]') +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/bad-uuid.d" + TMPLIST=$(mktemp) + BADLIST=$(mktemp) + for file in "$DIR"/*; do + [ -f "$file" ] || continue + # 11111111-2222-3333-4444-555555555555 + < "$file" tr '[a-z]' '[A-Z]' | grep -Eo '[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 + rm -f -- "$TMPLIST" "$BADLIST" +fi + +echo "$UUID" > "/run/system-uuid" diff --git a/core/modules/hardware-stats/data/opt/openslx/hardware-stats/bad-uuid.d/00-default b/core/modules/system-uuid/data/opt/openslx/bad-uuid.d/00-default index aaf59a7d..aaf59a7d 100644 --- a/core/modules/hardware-stats/data/opt/openslx/hardware-stats/bad-uuid.d/00-default +++ b/core/modules/system-uuid/data/opt/openslx/bad-uuid.d/00-default diff --git a/core/modules/system-uuid/module.build b/core/modules/system-uuid/module.build new file mode 100644 index 00000000..3c6eb632 --- /dev/null +++ b/core/modules/system-uuid/module.build @@ -0,0 +1,13 @@ +#!/bin/bash +fetch_source() { + : +} + +build() { + : +} + +post_copy() { + : +} + diff --git a/core/modules/system-uuid/module.conf b/core/modules/system-uuid/module.conf new file mode 100644 index 00000000..805ff2c4 --- /dev/null +++ b/core/modules/system-uuid/module.conf @@ -0,0 +1,4 @@ +#!/bin/bash +REQUIRED_MODULES=" + dmidecode +" |