summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2024-01-31 17:54:54 +0100
committerSimon Rettberg2024-01-31 17:54:54 +0100
commitacacfde5da4c681eb2bce75e87a10a88e1cd10d3 (patch)
tree32334922bd48bf36f6178d842729806666565d5a
parent[busybox] Split into services (diff)
downloadsystemd-init-acacfde5da4c681eb2bce75e87a10a88e1cd10d3.tar.gz
systemd-init-acacfde5da4c681eb2bce75e87a10a88e1cd10d3.tar.xz
systemd-init-acacfde5da4c681eb2bce75e87a10a88e1cd10d3.zip
De-dracutize service-scripts, try to use ash where applicable
-rwxr-xr-xmodules.d/conf-tgz/hooks/s3-fetch-config-tgz.sh38
-rwxr-xr-xmodules.d/conf-tgz/hooks/s3-unpack-config-tgz.sh90
-rwxr-xr-xmodules.d/dnbd3-rootfs/hooks/s3-dnbd3root.sh18
-rwxr-xr-xmodules.d/slx-addons/hooks/s3-setup-addons.sh22
-rwxr-xr-xmodules.d/slx-drm/hooks/s3-activate-nvidia-drivers.sh73
-rwxr-xr-xmodules.d/slx-drm/hooks/s3-copy-nvidia-drivers.sh15
-rwxr-xr-xmodules.d/slx-network/hooks/s3-copy-network-files.sh53
-rwxr-xr-xmodules.d/slx-network/hooks/s3-setup-bootif-network.sh14
-rwxr-xr-xmodules.d/slx-uuid/hooks/s3-get-system-uuid.sh116
9 files changed, 212 insertions, 227 deletions
diff --git a/modules.d/conf-tgz/hooks/s3-fetch-config-tgz.sh b/modules.d/conf-tgz/hooks/s3-fetch-config-tgz.sh
index 2ed5f579..1d032a19 100755
--- a/modules.d/conf-tgz/hooks/s3-fetch-config-tgz.sh
+++ b/modules.d/conf-tgz/hooks/s3-fetch-config-tgz.sh
@@ -1,27 +1,27 @@
-#!/usr/bin/env bash
+#!/bin/ash
# -*- coding: utf-8 -*-
-type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
-
. /etc/openslx
-if [ -z "$SLX_NO_CONFIG_TGZ" ]; then
- # build config.tgz url from SLX_KCL_SERVERS and SLX_BASE_PATH
- # both are written to /etc/openslx by dnbd3-rootfs's s3-fetch-config.sh script
- conftgz_url="http://${SLX_KCL_SERVERS}/${SLX_BASE_PATH}/config.tgz"
+[ -n "$SLX_NO_CONFIG_TGZ" ] && exit 0
- # check if system's uuid was set
- if [ -s "/run/system-uuid" ]; then
- uuid="$(cat /run/system-uuid)"
- if [ -n "$uuid" ]; then
- conftgz_url="${conftgz_url}?uuid=${uuid}"
- fi
- fi
- info "Download config.tgz from '$conftgz_url'..."
- slx-tools download_retry --slx-time 20 -sS "${conftgz_url}" > "/etc/config.tgz"
+# build config.tgz url from SLX_KCL_SERVERS and SLX_BASE_PATH
+# both are written to /etc/openslx by dnbd3-rootfs's s3-fetch-config.sh script
+conftgz_url="http://${SLX_KCL_SERVERS}/${SLX_BASE_PATH}/config.tgz"
- if [[ ! -s "/etc/config.tgz" ]]; then
- warn "Failed to download '${conftgz_url}'!"
+# check if system's uuid was set
+if [ -s "/run/system-uuid" ]; then
+ uuid="$(cat /run/system-uuid)"
+ if [ -n "$uuid" ]; then
+ conftgz_url="${conftgz_url}?uuid=${uuid}"
fi
fi
-:
+echo "Download config.tgz from '$conftgz_url'..."
+slx-tools download_retry --slx-time 20 -sS "${conftgz_url}" > "/etc/config.tgz"
+
+if ! [ -s "/etc/config.tgz" ]; then
+ echo "Failed to download '${conftgz_url}'"
+ exit 1
+fi
+
+exit 0
diff --git a/modules.d/conf-tgz/hooks/s3-unpack-config-tgz.sh b/modules.d/conf-tgz/hooks/s3-unpack-config-tgz.sh
index 2132423c..0ab877dd 100755
--- a/modules.d/conf-tgz/hooks/s3-unpack-config-tgz.sh
+++ b/modules.d/conf-tgz/hooks/s3-unpack-config-tgz.sh
@@ -1,58 +1,58 @@
-#!/usr/bin/env bash
+#!/bin/ash
# -*- coding: utf-8 -*-
-type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
-
# tarcopy <source_dir> <target_dir>
-tarcopy() {
- [ -d "$1" -a -d "$2" ] || return 1
- cd "$1"
+tarcopy() (
+ if ! [ -d "$1" ] || ! [ -d "$2" ]; then
+ echo "'$1' or '$2' is not a directory"
+ return 1
+ fi
+ cd "$1" || return 1
local filelist="$(mktemp)"
find . \! -type d > "$filelist"
- tar -c -p -T "$filelist" | tar -xp -C "$2"
+ if [ -s "$filelist" ]; then
+ tar -c -p -T "$filelist" | tar -xp -C "$2" || return 1
+ fi
rm -f -- "$filelist"
- cd - &>/dev/null
-}
+ return 0
+)
-unpack_config_tgz() {
- local config_tgz="/etc/config.tgz"
- [ -e "$config_tgz" ] || return 1
- # create list of overwritten files for debugging purposes
- mkdir -p "${NEWROOT}/opt/openslx"
- tar \
- --list \
- --verbose \
- --file="$config_tgz" \
- > "${NEWROOT}/opt/openslx/config.tgz.list" 2>&1
- local extract_dir="$(mktemp -d)"
- tar \
+config_tgz="/etc/config.tgz"
+[ -e "$config_tgz" ] || exit 1
+# create list of overwritten files for debugging purposes
+mkdir -p "${NEWROOT}/opt/openslx"
+tar \
+ --list \
+ --verbose \
+ --file="$config_tgz" \
+ > "${NEWROOT}/opt/openslx/config.tgz.list" 2>&1
+extract_dir="$(mktemp -d)"
+if ! tar \
--extract \
--preserve-permissions \
--file="$config_tgz" \
- --directory="$extract_dir"
- if [ "$?" -ne 0 ]; then
- warn "Failed to extract '$config_tgz' to '$extract_dir'."
- return 1
+ --directory="$extract_dir"; then
+ echo "Failed to extract '$config_tgz' to '$extract_dir'."
+ exit 1
+fi
+# check SLX_LOCAL_CONFIGURATION
+. "/etc/openslx"
+if [ -n "$SLX_LOCAL_CONFIGURATION" ]; then
+ if ! [ -d "${extract_dir}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" ]; then
+ echo "Ignoring missing SLX_LOCAL_CONFIGURATION in '$config_tgz'."
+ else
+ tarcopy \
+ "${extract_dir}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" \
+ "${extract_dir}"
fi
- # check SLX_LOCAL_CONFIGURATION
- source "/etc/openslx"
- if [ -n "$SLX_LOCAL_CONFIGURATION" ]; then
- if [ ! -d "${extract_dir}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" ]; then
- warn "Ignoring missing SLX_LOCAL_CONFIGURATION in '$config_tgz'."
- else
- tarcopy \
- "${extract_dir}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" \
- "${extract_dir}"
- fi
- fi
- # always purge openslx-configs/
- rm -rf "${extract_dir}/openslx-configs"
+fi
+# always purge openslx-configs/
+rm -rf "${extract_dir}/openslx-configs"
- # finally copy the rest into stage4
- if ! tarcopy "${extract_dir}" "$NEWROOT"; then
- warn "'tarcopy' from '$extract_dir' to '$NEWROOT' failed."
- fi
-}
+# finally copy the rest into stage4
+if ! tarcopy "${extract_dir}" "$NEWROOT"; then
+ echo "'tarcopy' from '$extract_dir' to '$NEWROOT' failed."
+ exit 1
+fi
-unpack_config_tgz
-:
+exit 0
diff --git a/modules.d/dnbd3-rootfs/hooks/s3-dnbd3root.sh b/modules.d/dnbd3-rootfs/hooks/s3-dnbd3root.sh
index 01a8c32c..47217c29 100755
--- a/modules.d/dnbd3-rootfs/hooks/s3-dnbd3root.sh
+++ b/modules.d/dnbd3-rootfs/hooks/s3-dnbd3root.sh
@@ -17,17 +17,17 @@ container_unpack_xmount() {
mkdir -p "$out_path"
# check tools first
if ! hash xmount systemd-preserve-process-marker; then
- warn "Missing xmount deps, will try raw..." 1>&2
+ echo "Missing xmount deps, will try raw..." 1>&2
elif ! systemd-preserve-process-marker xmount \
--in qemu "$in_device" \
--out raw "$out_path" &>/dev/null; then
- warn "xmount call failed, assuming raw image." 1>&2
+ echo "xmount call failed, assuming raw image." 1>&2
else
in_device="${out_path}/${_dnbd3_dev##*/}.dd"
fi
local out_device="$(losetup -f)"
if ! losetup "$out_device" "$in_device" --partscan; then
- warn "Failed to attach '$in_device' to '$out_device'."
+ echo "Failed to attach '$in_device' to '$out_device'."
return 1
fi
udevadm settle
@@ -39,11 +39,11 @@ container_unpack_xloop() {
local out_device="$(xlosetup -f)"
for kmod in xloop xloop_file_fmt_qcow xloop_file_fmt_raw; do
if ! modprobe "${kmod}"; then
- warn "Failed to load kernel module: $kmod"
+ echo "Failed to load kernel module: $kmod"
fi
done
if ! xlosetup -r -t QCOW "$out_device" "$in_device" --partscan; then
- warn "Failed to attach '$in_device' to '$out_device'."
+ echo "Failed to attach '$in_device' to '$out_device'."
return
fi
udevadm settle
@@ -74,7 +74,7 @@ if [ -n "$SLX_DNBD3_RID" ]; then
fi
if ! modprobe dnbd3; then
- warn "Failed to load kernel module: dnbd3"
+ echo "Failed to load kernel module: dnbd3"
fi
for try in {1..5} ""; do
@@ -85,7 +85,7 @@ for try in {1..5} ""; do
"Check if the image exists on one of the servers" \
"and if any is reachable from this client."
fi
- info "Trying hosts '$SLX_DNBD3_SERVERS'."
+ echo "Trying hosts '$SLX_DNBD3_SERVERS'."
if dnbd3-client \
--host "$SLX_DNBD3_SERVERS" \
--image "$SLX_DNBD3_IMAGE" \
@@ -138,12 +138,12 @@ else
eval "$SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT"
fi
if [[ -z "$read_only_partition" ]]; then
- warn "Failed to find unique device with identifier" \
+ echo "Failed to find unique device with identifier" \
"\"${SLX_SYSTEM_PARTITION_IDENTIFIER}\"; matched devices:" \
"\"${read_only_partition}\""
exit 1
fi
-info "Using read-only partition: $read_only_partition"
+echo "Using read-only partition: $read_only_partition"
# endregion
# region add rw layer to dnbd3 image
diff --git a/modules.d/slx-addons/hooks/s3-setup-addons.sh b/modules.d/slx-addons/hooks/s3-setup-addons.sh
index 0a947f23..495e3799 100755
--- a/modules.d/slx-addons/hooks/s3-setup-addons.sh
+++ b/modules.d/slx-addons/hooks/s3-setup-addons.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/bash
#
# Stage4 addons setup script
#
@@ -25,12 +25,10 @@
# or by chroot'ing into the stage4 before executing it.
### CURRENTLY NOT EXECUTED: Since whiteouts could be handled for _all_addons
-type emergency_shell >/dev/null 2>&1 || . /lib/dracut-lib.sh
-
# Check if we even have any addons to process
-if [ ! -d "$NEWROOT/opt/openslx/addons" ]; then
- info "No stage4 addons found."
- return 0
+if ! [ -d "$NEWROOT/opt/openslx/addons" ]; then
+ echo "No stage4 addons found."
+ exit 0
fi
# This just activates the ldconfig service to run during the sysinit target
@@ -47,13 +45,13 @@ activate_stage4_ldconfig() {
setup_addon() {
if [ ! -d "$1" ]; then
- warn "Given '$1' not a directory, skipping."
+ echo "Given '$1' not a directory, skipping."
return 1
fi
local addon_dir="$1"
cd "$addon_dir" || return 1
if ! bash addon-required 2>&1 ; then
- info "'$addon_dir/addon-required' missing or returned non-zero, skipping..."
+ echo "'$addon_dir/addon-required' missing or returned non-zero, skipping..."
return 1
fi
# purge addon-* files
@@ -82,7 +80,7 @@ active=()
for addon in "${NEWROOT}/opt/openslx/addons/"*; do
if setup_addon "$addon"; then
active+=("${addon#"${NEWROOT}/opt/openslx/addons/"}")
- info "Activated '$addon' (@ $(date +%s))"
+ echo "Activated '$addon' (@ $(date +%s))"
fi
done
@@ -91,13 +89,13 @@ done
if [ "${#active[@]}" -eq 1 ]; then
addon_cache="${NEWROOT}/opt/openslx/etc/${active[0]}.ld.so.cache"
if [ -e "$addon_cache" ]; then
- info "Using ld.so.cache of '${active[0]}'."
+ echo "Using ld.so.cache of '${active[0]}'."
mv -f -- "${NEWROOT}/etc/ld.so.cache"{,.stage4}
mv -f -- "$addon_cache" "${NEWROOT}/etc/ld.so.cache"
fi
elif [ "${#active[@]}" -gt 1 ]; then
- info "Activating ldconfig in stage4 due to multiple loaded addons: ${active[*]}"
+ echo "Activating ldconfig in stage4 due to multiple loaded addons: ${active[*]}"
activate_stage4_ldconfig
fi
-:
+exit 0
diff --git a/modules.d/slx-drm/hooks/s3-activate-nvidia-drivers.sh b/modules.d/slx-drm/hooks/s3-activate-nvidia-drivers.sh
index 00c2334a..28b0c639 100755
--- a/modules.d/slx-drm/hooks/s3-activate-nvidia-drivers.sh
+++ b/modules.d/slx-drm/hooks/s3-activate-nvidia-drivers.sh
@@ -1,42 +1,37 @@
-#!/bin/bash
+#!/bin/ash
-type emergency_shell >/dev/null 2>&1 || . /lib/dracut-lib.sh
-
-detect_nvidia_cards() {
- # hard check on nvidia graphic cards
- local cards="$( lspci -n | grep -o ' 03..: 10de:....' | awk '{print $2}' )"
- if ! [ -d "/drm.cfg.d" ] && [ -n "$cards" ]; then
- warn "Failed to find '/drm.cfg.d', but have nvidia cards - will try nouveau."
- return 1
+# hard check on nvidia graphic cards
+cards="$( lspci -n | grep -o ' 03..: 10de:....' | awk '{print $2}' )"
+if ! [ -d "/drm.cfg.d" ] && [ -n "$cards" ]; then
+ echo "Failed to find '/drm.cfg.d', but have nvidia cards - will try nouveau."
+ exit 1
+fi
+for card in $cards; do
+ driver="$(awk '$1 = /'"$card"'/ {print $2; exit}' /drm.cfg.d/*)"
+ [ -z "$driver" ] && continue
+ driver="${driver#'@'}"
+ driver="${driver//-/\/}"
+ driver_dir="/lib/modules/${driver}"
+ [ -d "$driver_dir" ] || continue
+ driver_target="/lib/modules/$(uname -r)/kernel/drivers/gpu/drm/nvidia"
+ if [ -d "$driver_target" ]; then
+ echo "'$driver_target' exists, will not overwrite!"
+ exit 1
+ fi
+ # all good, move it over
+ if ! mv "$driver_dir" "$driver_target" 2>&1; then
+ echo "Failed to move '$driver_dir' to '$driver_target'."
+ exit 1
+ fi
+ # finally run depmod to make it visible to udev
+ if ! depmod -a 2>&1 ; then
+ echo "Failed to run depmod, udev won't see the nvidia modules."
+ exit 1
fi
- for card in $cards; do
- local driver="$(awk '$1 = /'"$card"'/ {print $2; exit}' /drm.cfg.d/*)"
- [ -z "$driver" ] && continue
- driver="${driver#'@'}"
- driver="${driver//-/\/}"
- local driver_dir="/lib/modules/${driver}"
- [ -d "$driver_dir" ] || continue
- local driver_target="/lib/modules/$(uname -r)/kernel/drivers/gpu/drm/nvidia"
- if [ -d "$driver_target" ]; then
- warn "'$driver_target' exists, will not overwrite!"
- return 1
- fi
- # all good, move it over
- if ! mv "$driver_dir" "$driver_target" 2>&1; then
- warn "Failed to move '$driver_dir' to '$driver_target'."
- return 1
- fi
- # finally run depmod to make it visible to udev
- if ! depmod -a 2>&1 ; then
- warn "Failed to run depmod, udev won't see the nvidia modules."
- return 1
- fi
- # blacklist nouveau
- echo 'blacklist nouveau' > "/lib/modprobe.d/disable-nouveau.conf"
- info "Initialized nvidia drivers."
- return 0
- done
-}
+ # blacklist nouveau
+ echo 'blacklist nouveau' > "/lib/modprobe.d/disable-nouveau.conf"
+ echo "Initialized nvidia drivers."
+ break
+done
-detect_nvidia_cards
-:
+exit 0
diff --git a/modules.d/slx-drm/hooks/s3-copy-nvidia-drivers.sh b/modules.d/slx-drm/hooks/s3-copy-nvidia-drivers.sh
index 5afc71c7..f0b9f763 100755
--- a/modules.d/slx-drm/hooks/s3-copy-nvidia-drivers.sh
+++ b/modules.d/slx-drm/hooks/s3-copy-nvidia-drivers.sh
@@ -1,19 +1,17 @@
-#!/bin/bash
+#!/bin/ash
#
# This script checks whether the nvidia kernel module was loaded by udev
# and copies the kernel modules over to stage4 and disables nouveau
-type emergency_shell >/dev/null 2>&1 || . /lib/dracut-lib.sh
-
copy_nvidia_modules() {
local nvidia_moddir="/lib/modules/$(uname -r)/kernel/drivers/gpu/drm/nvidia"
if [ -d "${NEWROOT}/${nvidia_moddir}" ]; then
- warn "Stage4 contains nvidia driver which would be overwritten - skipping."
+ echo "Stage4 contains nvidia driver which would be overwritten - skipping."
return 1
fi
if ! ( cp -r "$nvidia_moddir" "${NEWROOT}/${nvidia_moddir}" \
&& depmod -a -b "$NEWROOT" ); then
- warn "Failed to copy/depmod nvidia modules to stage4."
+ echo "Failed to copy/depmod nvidia modules to stage4."
return 1
fi
# nouveau driver would needlessly load, prevent that
@@ -22,7 +20,8 @@ copy_nvidia_modules() {
return 0
}
-if lsmod | grep -q '^nvidia'; then
- copy_nvidia_modules
+if ! lsmod | grep -q '^nvidia'; then
+ exit 0
fi
-: # fake success
+
+copy_nvidia_modules
diff --git a/modules.d/slx-network/hooks/s3-copy-network-files.sh b/modules.d/slx-network/hooks/s3-copy-network-files.sh
index 5d28669e..46f4ab38 100755
--- a/modules.d/slx-network/hooks/s3-copy-network-files.sh
+++ b/modules.d/slx-network/hooks/s3-copy-network-files.sh
@@ -1,31 +1,30 @@
-#!/bin/bash
+#!/bin/ash
-type -p warn &> /dev/null || . /lib/dracut-lib.sh
+# backup network configuration files found in stage4, copy ours
+for file in "hostname" "hosts" "resolv.conf"; do
+ file="/etc/$file"
+ if ! [ -e "$file" ]; then
+ echo "Missing '$file' - can't move it to stage4. "
+ continue
+ fi
+ if [ -e "${NEWROOT}/${file}" ] || [ -h "${NEWROOT}/${file}" ]; then
+ mv "${NEWROOT}/${file}" "${NEWROOT}/${file}.renamed-by-stage3"
+ fi
+ cp -af -- "$file" "${NEWROOT}${file}"
+done
-if [ -n "$NEWROOT" ]; then
- # backup network configuration files found in stage4
- for file in /etc/{hostname,hosts,resolv.conf}; do
- if [ ! -e "$file" ]; then
- warn "Missing '$file' - can't move it to stage4. "
- continue
- fi
- if [ -e "${NEWROOT}/${file}" ] || [ -h "${NEWROOT}/${file}" ]; then
- mv "${NEWROOT}/${file}" "${NEWROOT}/${file}.renamed-by-stage3"
- fi
- cp -af "$file" "${NEWROOT}/etc/"
- done
- # special handling for resolv.conf:
- # move it to /opt/openslx to detect we are managing it
- mkdir -p "${NEWROOT}/opt/openslx"
- mv "${NEWROOT}/etc/resolv.conf" "${NEWROOT}/opt/openslx/resolv.conf"
- ln -s "/opt/openslx/resolv.conf" "${NEWROOT}/etc/resolv.conf"
+# special handling for resolv.conf:
+# move it to /opt/openslx to detect we are managing it
+mkdir -p "${NEWROOT}/opt/openslx"
+mv "${NEWROOT}/etc/resolv.conf" "${NEWROOT}/opt/openslx/resolv.conf"
+ln -nfs "/opt/openslx/resolv.conf" "${NEWROOT}/etc/resolv.conf"
- # HACK: finally make sure we have rdns helper
- # This should be done more elegantly one day...
- rdns="$(type -p rdns)"
- if [ -n "$rdns" ]; then
- mkdir -p "${NEWROOT}/opt/openslx/bin"
- cp -f "$rdns" "${NEWROOT}/opt/openslx/bin"
- fi
+# HACK: finally make sure we have rdns helper
+# This should be done more elegantly one day...
+rdns="$( command -p rdns )"
+if [ -n "$rdns" ]; then
+ mkdir -p "${NEWROOT}/opt/openslx/bin"
+ cp -f "$rdns" "${NEWROOT}/opt/openslx/bin"
fi
-true
+
+exit 0
diff --git a/modules.d/slx-network/hooks/s3-setup-bootif-network.sh b/modules.d/slx-network/hooks/s3-setup-bootif-network.sh
index 6b75170d..1aeac9b6 100755
--- a/modules.d/slx-network/hooks/s3-setup-bootif-network.sh
+++ b/modules.d/slx-network/hooks/s3-setup-bootif-network.sh
@@ -70,7 +70,7 @@ wait_for_iface() {
set -x
if ! wait_for_iface "$SLX_PXE_NETIF" 30; then
- warn "'$SLX_PXE_NETIF' still not up after 30sec ... trying anyway."
+ echo "'$SLX_PXE_NETIF' still not up after 30sec ... trying anyway."
# TODO handle case where we waited for 30sec and it is still not up
fi
@@ -78,14 +78,14 @@ fi
MAIN_NETIF="$SLX_PXE_NETIF"
if [ -n "$SLX_VLAN_ID" ]; then
# create VLAN interface
- modprobe 8021q || warn "Loading '8021q' failed - missing module?"
+ modprobe 8021q || echo "Loading '8021q' failed - missing module?"
ip link add link "$SLX_PXE_NETIF" name "${SLX_PXE_NETIF}.${SLX_VLAN_ID}" \
type vlan id "$SLX_VLAN_ID"
ip link set dev "${SLX_PXE_NETIF}.${SLX_VLAN_ID}" up
if wait_for_iface "${SLX_PXE_NETIF}.${SLX_VLAN_ID}"; then
MAIN_NETIF="${SLX_PXE_NETIF}.${SLX_VLAN_ID}"
else
- warn "Setting up VLAN '$SLX_VLAN_ID' failed, trying plain..."
+ echo "Setting up VLAN '$SLX_VLAN_ID' failed, trying plain..."
fi
fi
@@ -110,7 +110,7 @@ if [ -n "$SLX_BRIDGE" ]; then
emergency_shell "Failed to setup main network bridge, giving up!"
exit 1
fi
- warn "Failed to setup main network bridge on try $try. Retrying ..."
+ echo "Failed to setup main network bridge on try $try. Retrying ..."
# delete bridge, inc try and sleep 100ms before trying again
if [ -e "/sys/class/net/${SLX_BRIDGE}" ]; then
ip link set dev "$SLX_BRIDGE" down
@@ -128,14 +128,14 @@ if [ -n "$SLX_PXE_CLIENT_IP" ] && [ -n "$SLX_PXE_NETMASK" ]; then
# now if we got everything from the KCL and skip dhcp if so
if [ -n "$SLX_PXE_GATEWAY" ] && [ -n "$SLX_PXE_DNS" ]; then
- info "Got network configuration from KCL, skipping DHCP."
+ echo "Got network configuration from KCL, skipping DHCP."
if ! interface="$MAIN_NETIF" \
ip="$SLX_PXE_CLIENT_IP" \
router="$SLX_PXE_GATEWAY" \
dns="$SLX_PXE_DNS" \
hostname="$SLX_PXE_HOSTNAME" \
/usr/local/bin/udhcpc-trigger bound; then
- warn "Failed to launch DHCP trigger with KCL configuration - will DHCP."
+ echo "Failed to launch DHCP trigger with KCL configuration - will DHCP."
fi
exit 0
fi
@@ -182,7 +182,7 @@ for i in 1 1 1 fail; do
-s "/usr/local/bin/udhcpc-trigger" \
&& break
# failed, keep trying...
- warn "DHCP failed, retrying in $i sec..."
+ echo "DHCP failed, retrying in $i sec..."
sleep $i
done
diff --git a/modules.d/slx-uuid/hooks/s3-get-system-uuid.sh b/modules.d/slx-uuid/hooks/s3-get-system-uuid.sh
index e65a3394..e97a0e18 100755
--- a/modules.d/slx-uuid/hooks/s3-get-system-uuid.sh
+++ b/modules.d/slx-uuid/hooks/s3-get-system-uuid.sh
@@ -1,71 +1,65 @@
-#!/usr/bin/env bash
-#
+#!/bin/ash
+
# Slighty changed version of:
# http://git.openslx.org/openslx-ng/mltk.git/plain/core/modules/system-uuid/data/bin/get-uuid
-. /lib/dracut-lib.sh
-
-get_system_uuid() {
- if [ -e /run/openslx/network.conf ]; then
- . /run/openslx/network.conf
- else
- echo "Don't have /run/openslx/network.conf"
- fi
+if [ -e /run/openslx/network.conf ]; then
+ . /run/openslx/network.conf
+else
+ echo "Don't have /run/openslx/network.conf"
+fi
- if [ -z "$SLX_PXE_MAC" ]; then
- warn "Getting MAC from /run/openslx/network.conf failed, using 'ip a'..."
- for iface in "${SLX_BRIDGE:-br0}" boot0 eth0; do
- BOOTIF=01-$(ip a | grep -A 1 ": ${iface}" | grep -o 'ether ..:..:..:..:..:..' | cut -d' ' -f2 | sed s/:/-/g)
- [ "${#BOOTIF}" -eq "20" ] && break
- done
- if [ "${#BOOTIF}" -ne "20" ]; then
- warn "Getting MAC from 'ip a' failed, using bogus value..."
- BOOTIF="99-88-77-66-55-44-33"
- fi
- else
- BOOTIF="01-$(tr ':' '-' <<< $SLX_PXE_MAC)"
+if [ -z "$SLX_PXE_MAC" ]; then
+ echo "Getting MAC from /run/openslx/network.conf failed, using 'ip a'..."
+ for iface in "${SLX_BRIDGE:-br0}" boot0 eth0; do
+ BOOTIF=01-$(ip a | grep -A 1 ": ${iface}" | grep -o 'ether ..:..:..:..:..:..' | cut -d' ' -f2 | sed s/:/-/g)
+ [ "${#BOOTIF}" -eq "20" ] && break
+ done
+ if [ "${#BOOTIF}" -ne "20" ]; then
+ echo "Getting MAC from 'ip a' failed, using bogus value..."
+ BOOTIF="99-88-77-66-55-44-33"
fi
+else
+ BOOTIF="01-$( echo "$SLX_PXE_MAC" | tr ':' '-' )"
+fi
- local UUID=$(dmidecode -q -s system-uuid | grep -v '^#' | head -n 1 | tr 'a-z' 'A-Z')
- if [ "${#UUID}" -ne "36" ]; then
- warn "Determined UUID (${UUID}) has not expected length of 36, falling back to MAC..."
- # Maybe use /proc/sys/kernel/random/uuid ?
+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..."
+ # Maybe use /proc/sys/kernel/random/uuid ?
+ UUID=
+else
+ # Got UUID, check blacklist
+ DIR="/etc/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=
- else
- # Got UUID, check blacklist
- local DIR="/etc/bad-uuid.d"
- local TMPLIST=$(mktemp)
- local 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
- warn "WARNING: UUID is blacklisted as potentially not being unique, using MAC fallback"
- UUID=
- fi
- rm -f -- "$TMPLIST" "$BADLIST"
fi
+ rm -f -- "$TMPLIST" "$BADLIST"
+fi
- if [ -z "$UUID" ]; then
- UUID=$( echo "$BOOTIF" | sed -r 's/[^0-9A-Fa-f]//g' )
- [ "${#UUID}" -eq 14 ] && UUID="${UUID:2}"
- if [ "${#UUID}" -eq 12 ]; then
- UUID="baad1d00-9491-4716-b98b-$UUID"
- else
- UUID="baad1d00-9491-4716-b98b-000000000000"
- fi
+if [ -z "$UUID" ]; then
+ UUID=$( echo "$BOOTIF" | sed -r 's/[^0-9A-Fa-f]//g' )
+ [ "${#UUID}" -eq 14 ] && UUID="${UUID:2}"
+ if [ "${#UUID}" -eq 12 ]; then
+ UUID="baad1d00-9491-4716-b98b-$UUID"
+ else
+ UUID="baad1d00-9491-4716-b98b-000000000000"
fi
- UUID=$( echo "$UUID" | tr 'a-z' 'A-Z' )
- readonly UUID
- echo "$UUID" > "/run/system-uuid"
-}
-
-get_system_uuid
+fi
+UUID=$( echo "$UUID" | tr 'a-z' 'A-Z' )
+readonly UUID
+echo "$UUID" > "/run/system-uuid"