home · contact · privacy
Fixes.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 19 Aug 2025 17:50:03 +0000 (19:50 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 19 Aug 2025 17:50:03 +0000 (19:50 +0200)
bookworm/scripts/lib/prefixed_msg.sh
trixie/scripts/lib/get_mountable_device_path.sh
trixie/scripts/make_writable_installer.sh

index f9084cfe9748b77e79753ee41bc196040f245d35..c8c7f0e0783678a2f6fc346e730914d05adbc67d 100644 (file)
@@ -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
index 8405944dca5fda2b90c299952f047c1784cbcf08..bad3d681816914c424841b45c2e6667d91bfe413 100644 (file)
@@ -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
index 6505bdf546375327cfbb425b507f38b8d9823b91..8e0ecd0640ddc980a1cf3ef8681a13132ab4dae1 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env dash
 # based on <https://wiki.debian.org/DebianInstaller/WritableUSBStick>
-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