From: Christian Heller Date: Tue, 19 Aug 2025 17:50:03 +0000 (+0200) Subject: Fixes. X-Git-Url: https://plomlompom.com/repos/blog?a=commitdiff_plain;h=a656f368884d23fbd6242194a599aa51f22f61c4;p=config Fixes. --- diff --git a/bookworm/scripts/lib/prefixed_msg.sh b/bookworm/scripts/lib/prefixed_msg.sh index f9084cf..c8c7f0e 100644 --- a/bookworm/scripts/lib/prefixed_msg.sh +++ b/bookworm/scripts/lib/prefixed_msg.sh @@ -1,5 +1,6 @@ prefixed_msg_init() { - export prefixed_msg_OLD_PREFIX="${prefixed_msg_PREFIX}|${prefixed_msg_OLD_PREFIX}" + prefixed_msg_OLD_PREFIX="${prefixed_msg_PREFIX}|${prefixed_msg_OLD_PREFIX}" + export prefixed_msg_OLD_PREFIX if [ -z "$1" ]; then export prefixed_msg_PREFIX=$(basename "$0") else diff --git a/trixie/scripts/lib/get_mountable_device_path.sh b/trixie/scripts/lib/get_mountable_device_path.sh index 8405944..bad3d68 100644 --- a/trixie/scripts/lib/get_mountable_device_path.sh +++ b/trixie/scripts/lib/get_mountable_device_path.sh @@ -7,7 +7,7 @@ get_mountable_device_path() { abort "No block device at ${PATH_DEV}." else local COUNT - COUNT=$(mount | grep -cE "^${PATH_DEV}") + COUNT=$(mount | grep -E "^${PATH_DEV}" | wc -l) if [ "${COUNT}" -gt 0 ]; then abort "${PATH_DEV} already mounted." fi diff --git a/trixie/scripts/make_writable_installer.sh b/trixie/scripts/make_writable_installer.sh index 6505bdf..8e0ecd0 100755 --- a/trixie/scripts/make_writable_installer.sh +++ b/trixie/scripts/make_writable_installer.sh @@ -1,6 +1,6 @@ #!/usr/bin/env dash # based on -set -eu +set -e PARENT_DIR=$(dirname "$0") cd "${PARENT_DIR}" . lib/INSTALLER_VERSION.sh @@ -12,8 +12,11 @@ cd "${PARENT_DIR}" . lib/expect_n_args.sh . lib/get_mountable_device_path.sh . lib/path_tmp_timestamped.sh +. lib/prefixed_msg.sh . lib/trapp.sh +prefixed_msg_init make_writable_installer + FILENAME_ISO="debian-${INSTALLER_VERSION}-amd64-netinst.iso" URL_ISO="https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/${FILENAME_ISO}" PATH_MNT_ISO=/mnt/iso @@ -26,11 +29,11 @@ abort_if_command_unknown rsync abort_if_command_unknown wget if [ -z "$2" ]; then - echo "No file path set, so will try to retrieve image online from ${URL_ISO}." + prefixed_msg "No file path set, so will try to retrieve image online from ${URL_ISO}." abort_if_offline else - echo "With file path set, checking if we can use file at ${PATH_FILE_ISO}." PATH_FILE_ISO=$(realpath "$2") + prefixed_msg "With file path set, checking if we can use file at ${PATH_FILE_ISO}." BASENAME_FILE_ISO=$(basename "${PATH_FILE_ISO}") if [ ! "${FILENAME_ISO}" = "${BASENAME_FILE_ISO}" ]; then abort "basename of PATH_FILE_ISO != expected ${FILENAME_ISO}" @@ -41,7 +44,7 @@ fi PATH_DEV=$(get_mountable_device_path "$1") PATH_PROCESSING="$(path_tmp_timestamped make_writable_installer)" -echo "Setting up processing directory at ${PATH_PROCESSING} …" +prefixed_msg "Setting up processing directory at ${PATH_PROCESSING} …" RM_PROCESSING="rm -rf ${PATH_PROCESSING}" mkdir "${PATH_PROCESSING}" trapp "${RM_PROCESSING}" @@ -55,17 +58,17 @@ else ln -s "${PATH_FILE_ISO}" . fi -echo "Preparing partition/filesystem on ${PATH_DEV} …" +prefixed_msg "Preparing partition/filesystem on ${PATH_DEV} …" parted --script "${PATH_DEV}" mklabel msdos parted --script "${PATH_DEV}" mkpart primary fat32 0% 100% PATH_PARTITION="${PATH_DEV}1" mkfs.vfat "${PATH_PARTITION}" > /dev/null PATH_MNT_DEV='/mnt/'$(basename "${PATH_PARTITION}") -echo -n "Mounting ${PATH_MNT_ISO} and ${PATH_MNT_DEV} …" +prefixed_msg "Mounting ${PATH_MNT_ISO} and ${PATH_MNT_DEV} …" mkdir -p "${PATH_MNT_ISO}" "${PATH_MNT_DEV}" do_umount() { - echo "Unmounting $1 …" + prefixed_msg "Unmounting $1 …" set +e umount "$1" set -e @@ -75,16 +78,16 @@ trapp "${RM_PROCESSING}; do_umount ${PATH_MNT_DEV}" mount -o loop "${FILENAME_ISO}" "${PATH_MNT_ISO}" 2>&1 | sed 's|mount: /mnt/iso: WARNING: source write-protected, mounted read-only.||' trapp "${RM_PROCESSING}; do_umount ${PATH_MNT_DEV}; do_umount ${PATH_MNT_ISO}" -echo "Copying contents of ${PATH_MNT_ISO} to ${PATH_MNT_DEV}/ …" +prefixed_msg "Copying contents of ${PATH_MNT_ISO} to ${PATH_MNT_DEV}/ …" FILENAME_RSYNC_ERRORS="rsync_errors" set +e rsync -a "${PATH_MNT_ISO}/" "${PATH_MNT_DEV}/" 2> "${FILENAME_RSYNC_ERRORS}" RESULT=$? set -e if [ "${RESULT}" != "0" ]; then - echo 'RSYNC ERRORS:' + prefixed_msg 'RSYNC ERRORS:' cat "${FILENAME_RSYNC_ERRORS}" - echo '\nrsync encountered errors, see above – continue? (Y/N)' + prefixed_msg '\nrsync encountered errors, see above – continue? (Y/N)' read -r ANSWER FIRST_CHAR=$(echo "${ANSWER}" | cut -c1) if ! [ "${FIRST_CHAR}" = 'y' ] || [ "${FIRST_CHAR}" = 'Y' ]; then @@ -92,8 +95,10 @@ if [ "${RESULT}" != "0" ]; then fi fi -echo "Installing preseed file …" +prefixed_msg "Installing preseed file …" cp "${PATH_PRESEED_CFG}" "${PATH_MNT_DEV}/" sed --in-place 's/ --- / --- preseed\/file=\/cdrom\/'"${FILENAME_PRESEED_CFG}"' /g' "${PATH_MNT_DEV}/boot/grub/grub.cfg" -echo "Done!" +prefixed_msg "Done!" + +prefixed_msg_exit