home · contact · privacy
Some linking reoragnization. master
authorChristian Heller <c.heller@plomlompom.de>
Wed, 26 Mar 2025 02:38:59 +0000 (03:38 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 26 Mar 2025 02:38:59 +0000 (03:38 +0100)
19 files changed:
bookworm/preseed.cfg [new file with mode: 0644]
bookworm/scripts/lib/abort [new file with mode: 0644]
bookworm/scripts/lib/abort_if_not_user [new file with mode: 0644]
bookworm/scripts/lib/abort_if_offline [new file with mode: 0644]
bookworm/scripts/lib/constants_installer [new file with mode: 0644]
bookworm/scripts/lib/expect_min_n_args [new file with mode: 0644]
bookworm/scripts/lib/get_mountable_device_path [new file with mode: 0644]
bookworm/scripts/make_writable_installer.sh [new file with mode: 0755]
bookworm/scripts/update_preseed.sh [new file with mode: 0755]
testing/home/desktop/.plomlib.sh/get_passphrase [changed from file to symlink]
testing/home/desktop/.plomlib.sh/path_tmp_timestamped [changed from file to symlink]
testing/scripts/lib/abort [changed from file to symlink]
testing/scripts/lib/abort_if_not_user [changed from file to symlink]
testing/scripts/lib/abort_if_offline [changed from file to symlink]
testing/scripts/lib/expect_min_n_args [deleted file]
testing/scripts/lib/get_passphrase [new file with mode: 0644]
testing/scripts/lib/path_tmp_timestamped [new file with mode: 0644]
testing/scripts/setup_desktop.sh
testing/scripts/setup_secrets.sh

diff --git a/bookworm/preseed.cfg b/bookworm/preseed.cfg
new file mode 100644 (file)
index 0000000..67ed33b
--- /dev/null
@@ -0,0 +1,27 @@
+#_preseed_V1
+
+d-i passwd/root-login boolean true
+user-setup-udeb        passwd/make-user boolean false
+
+d-i netcfg/choose_interface select auto
+d-i netcfg/link_wait_timeout string 3
+d-i netcfg/wireless_wep string
+d-i netcfg/disable_autoconfig boolean false
+d-i netcfg/get_hostname string unassigned-hostname
+d-i netcfg/get_domain string unassigned-domain
+
+# d-i partman-auto/method string crypto
+d-i partman-auto-lvm/guided_size string max
+# d-i partman-auto/choose_recipe select atomic
+d-i partman-auto-crypto/erase_disks boolean false
+# d-i partman-lvm/confirm boolean true
+
+d-i base-installer/kernel/image string linux-image-amd64
+
+d-i mirror/protocol string http
+d-i apt-setup/non-free-firmware boolean true
+d-i apt-setup/non-free boolean true
+d-i apt-setup/contrib boolean true
+
+clock-setup clock-setup/utc boolean true
+d-i finish-install/reboot_in_progress note
diff --git a/bookworm/scripts/lib/abort b/bookworm/scripts/lib/abort
new file mode 100644 (file)
index 0000000..b0a1704
--- /dev/null
@@ -0,0 +1,4 @@
+abort() {
+    echo "$1"
+    exit 1
+}
diff --git a/bookworm/scripts/lib/abort_if_not_user b/bookworm/scripts/lib/abort_if_not_user
new file mode 100644 (file)
index 0000000..a7b3da3
--- /dev/null
@@ -0,0 +1,7 @@
+. lib/abort
+
+abort_if_not_user() {
+    if [ "$(whoami)" != "$1" ]; then
+        abort "Must be run as ${1}."
+    fi
+}
diff --git a/bookworm/scripts/lib/abort_if_offline b/bookworm/scripts/lib/abort_if_offline
new file mode 100644 (file)
index 0000000..b81c784
--- /dev/null
@@ -0,0 +1,7 @@
+. lib/abort
+
+abort_if_offline() {
+    if ! ping -c1 -W2 1.1.1.1 > /dev/null 2>&1; then
+        abort 'Must be run online.'
+    fi
+}
diff --git a/bookworm/scripts/lib/constants_installer b/bookworm/scripts/lib/constants_installer
new file mode 100644 (file)
index 0000000..b710116
--- /dev/null
@@ -0,0 +1,3 @@
+FILENAME_PRESEED_CFG=preseed.cfg
+PATH_PRESEED_CFG="../${FILENAME_PRESEED_CFG}"
+PATH_MNT_STICK=/mnt/stick
diff --git a/bookworm/scripts/lib/expect_min_n_args b/bookworm/scripts/lib/expect_min_n_args
new file mode 100644 (file)
index 0000000..8f9c74d
--- /dev/null
@@ -0,0 +1,9 @@
+expect_min_n_args() {
+    MIN_ARGS="$1"
+    EXPLAINER="$2"
+    shift 2
+    if [ "$#" -lt "${MIN_ARGS}" ]; then
+        echo "Need at least ${MIN_ARGS} arguments … ${EXPLAINER}"
+        false
+    fi
+}
diff --git a/bookworm/scripts/lib/get_mountable_device_path b/bookworm/scripts/lib/get_mountable_device_path
new file mode 100644 (file)
index 0000000..7090a46
--- /dev/null
@@ -0,0 +1,11 @@
+. lib/abort
+
+get_mountable_device_path() {
+    PATH_DEV="/dev/$1"
+    if [ ! -b "${PATH_DEV}" ]; then
+        abort "No block device at ${PATH_DEV}."
+    elif [ $(mount | grep -E "^${PATH_DEV}" | wc -l) -gt 0 ]; then
+        abort "${PATH_DEV} already mounted."
+    fi
+    printf "${PATH_DEV}"
+}
diff --git a/bookworm/scripts/make_writable_installer.sh b/bookworm/scripts/make_writable_installer.sh
new file mode 100755 (executable)
index 0000000..d828344
--- /dev/null
@@ -0,0 +1,79 @@
+#!/bin/sh
+# based on <https://wiki.debian.org/DebianInstaller/WritableUSBStick>
+set -e
+cd $(dirname "$0")
+. lib/abort
+. lib/abort_if_not_user
+. lib/abort_if_offline
+. lib/constants_installer
+. lib/expect_min_n_args
+. lib/get_mountable_device_path
+
+INSTALLER_VERSION=12.10.0
+PATH_MNT_ISO=/mnt/iso
+
+abort_if_not_user root
+abort_if_offline root
+abort_if_command_unknown() {
+    if ! which "$1" > /dev/null; then
+        abort "expected command unavailable: ${1}."
+    fi
+}
+abort_if_command_unknown wget 
+abort_if_command_unknown rsync
+abort_if_command_unknown parted 
+abort_if_command_unknown mkfs.vfat 
+
+expect_min_n_args 1 '(device name, e.g. "sdb")' $@
+PATH_STICK="$(get_mountable_device_path $1)"
+
+FILENAME_ISO="debian-${INSTALLER_VERSION}-amd64-netinst.iso"
+echo "Retrieving ${FILENAME_ISO}."
+URL_ISO="https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/${FILENAME_ISO}"
+PATH_ISO="/tmp/${FILENAME_ISO}"
+wget --output-document "${PATH_ISO}" "${URL_ISO}"
+
+echo "Preparing partition/filesystem on ${PATH_STICK}."
+parted --script "${PATH_STICK}" mklabel msdos
+parted --script "${PATH_STICK}" mkpart primary fat32 0% 100%
+PATH_PARTITION="${PATH_STICK}1"
+mkfs.vfat "${PATH_PARTITION}" 
+
+echo "Mounting ${PATH_MNT_ISO} and ${PATH_MNT_STICK}."
+mkdir -p "${PATH_MNT_ISO}" "${PATH_MNT_STICK}"
+mount "${PATH_PARTITION}" "${PATH_MNT_STICK}"
+mount -o loop "${PATH_ISO}" "${PATH_MNT_ISO}"
+do_umounts() {
+    set +e
+    echo "Unmounting ${PATH_MNT_ISO}"
+    umount "${PATH_MNT_ISO}"
+    echo "Unmounting ${PATH_MNT_STICK}"
+    umount "${PATH_MNT_STICK}"
+    set -e
+}
+trap do_umounts EXIT INT TERM
+
+echo "Copying contents of ${PATH_MNT_ISO} to ${PATH_MNT_STICK}/."
+PATH_RSYNC_ERRORS=/tmp/rsync_errors
+set +e
+rsync -a "${PATH_MNT_ISO}/" "${PATH_MNT_STICK}/" 2> "${PATH_RSYNC_ERRORS}"
+RESULT=$?
+set -e
+if [ "${RESULT}" != "0" ]; then
+    echo 'rsync errors:'
+    cat "${PATH_RSYNC_ERRORS}"
+    echo 'rsync encountered errors, see above – continue? (Y/N)'
+    rm "${PATH_RSYNC_ERRORS}"
+    read ANSWER
+    FIRST_CHAR=$(echo "${ANSWER}" | cut -c1)
+    if ! [ "${FIRST_CHAR}" = 'y' -o "${FIRST_CHAR}" = 'Y' ]; then
+        abort 'as requested'
+    fi
+fi
+
+echo "Installing preseed file."
+cp "${PATH_PRESEED_CFG}" "${PATH_MNT_STICK}/"
+sed --in-place 's/ --- / --- preseed\/file=\/cdrom\/'"${FILENAME_PRESEED_CFG}"' /g' "${PATH_MNT_STICK}/boot/grub/grub.cfg"
+
+rm "${PATH_ISO}"
+echo "Done!"
diff --git a/bookworm/scripts/update_preseed.sh b/bookworm/scripts/update_preseed.sh
new file mode 100755 (executable)
index 0000000..17f5098
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+set -e
+set -x
+cd $(dirname "$0")
+. lib/abort_if_not_user
+. lib/constants_installer
+. lib/expect_min_n_args
+. lib/get_mountable_device_path
+
+abort_if_not_user root
+expect_min_n_args 1 '(e.g. "sdb1")' $@
+PATH_STICK="$(get_mountable_device_path $1)"
+
+mount "${PATH_STICK}" "${PATH_MNT_STICK}"
+trap "umount ${PATH_MNT_STICK}" EXIT INT TERM
+cp "${PATH_PRESEED_CFG}" "${PATH_MNT_STICK}/"
deleted file mode 100644 (file)
index 6e3f0ff5663b3aeef4ee03b797f357e47f726861..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,6 +0,0 @@
-get_passphrase() {
-    stty -echo
-    read PASSPHRASE
-    stty echo
-    printf "${PASSPHRASE}"
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..3d542b530c156671537ace0e9b91d6918327403c
--- /dev/null
@@ -0,0 +1 @@
+../../../scripts/lib/get_passphrase
\ No newline at end of file
deleted file mode 100644 (file)
index 7ae63cd5288127fbfc3d754d2d0ad3a1ef26fa8d..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,3 +0,0 @@
-path_tmp_timestamped () {
-    printf "/tmp/${1}_$(date +'%s')"
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..0752df58ef9a6d5e74b80587d2f8b976dabb2e49
--- /dev/null
@@ -0,0 +1 @@
+../../../scripts/lib/path_tmp_timestamped
\ No newline at end of file
deleted file mode 100644 (file)
index b0a1704541ee20fa3c76d90c68a9bccfd6696b13..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,4 +0,0 @@
-abort() {
-    echo "$1"
-    exit 1
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..55742334a709031ce309b602d5b14503c3ead109
--- /dev/null
@@ -0,0 +1 @@
+../../../bookworm/scripts/lib/abort
\ No newline at end of file
deleted file mode 100644 (file)
index a7b3da39d8b27e31d23be9f0e2099a418e2fdea4..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,7 +0,0 @@
-. lib/abort
-
-abort_if_not_user() {
-    if [ "$(whoami)" != "$1" ]; then
-        abort "Must be run as ${1}."
-    fi
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..b152dcad0f4d0ed438a6c14b537a1102adb5ef18
--- /dev/null
@@ -0,0 +1 @@
+../../../bookworm/scripts/lib/abort_if_not_user
\ No newline at end of file
deleted file mode 100644 (file)
index b81c7847858df2497591a500d311fe7b3f532816..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,7 +0,0 @@
-. lib/abort
-
-abort_if_offline() {
-    if ! ping -c1 -W2 1.1.1.1 > /dev/null 2>&1; then
-        abort 'Must be run online.'
-    fi
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..c2f519fda60ef596261cf258310faf53d8789eb3
--- /dev/null
@@ -0,0 +1 @@
+../../../bookworm/scripts/lib/abort_if_offline
\ No newline at end of file
diff --git a/testing/scripts/lib/expect_min_n_args b/testing/scripts/lib/expect_min_n_args
deleted file mode 100644 (file)
index 8f9c74d..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-expect_min_n_args() {
-    MIN_ARGS="$1"
-    EXPLAINER="$2"
-    shift 2
-    if [ "$#" -lt "${MIN_ARGS}" ]; then
-        echo "Need at least ${MIN_ARGS} arguments … ${EXPLAINER}"
-        false
-    fi
-}
diff --git a/testing/scripts/lib/get_passphrase b/testing/scripts/lib/get_passphrase
new file mode 100644 (file)
index 0000000..6e3f0ff
--- /dev/null
@@ -0,0 +1,6 @@
+get_passphrase() {
+    stty -echo
+    read PASSPHRASE
+    stty echo
+    printf "${PASSPHRASE}"
+}
diff --git a/testing/scripts/lib/path_tmp_timestamped b/testing/scripts/lib/path_tmp_timestamped
new file mode 100644 (file)
index 0000000..7ae63cd
--- /dev/null
@@ -0,0 +1,3 @@
+path_tmp_timestamped () {
+    printf "/tmp/${1}_$(date +'%s')"
+}
index 53327efd22ee9d63b0786f8fe4ef28841a1f46ca..9834ceb44af6c0c965449445abcdc953b0a3f8fa 100755 (executable)
@@ -1,7 +1,6 @@
 #!/bin/sh
 set -e
 cd $(dirname "$0")
 #!/bin/sh
 set -e
 cd $(dirname "$0")
-
 . lib/constants  # PATH_USER_HOME, USERNAME
 . lib/expect_min_n_args
 . lib/abort
 . lib/constants  # PATH_USER_HOME, USERNAME
 . lib/expect_min_n_args
 . lib/abort
index 4eb26459a83a3f6ff6598acf599305d8c04b0062..f41778878fb820eb6a8e12b475284a4c56331e0f 100755 (executable)
@@ -1,16 +1,14 @@
 #!/bin/sh
 set -e
 cd $(dirname "$0")
 #!/bin/sh
 set -e
 cd $(dirname "$0")
-
-. lib/constants  # PATH_USER_HOME, USERNAME
-. lib/expect_min_n_args
 . lib/abort
 . lib/abort_if_exists
 . lib/abort_if_not_user
 . lib/abort_if_offline
 . lib/abort
 . lib/abort_if_exists
 . lib/abort_if_not_user
 . lib/abort_if_offline
-
-. "${PATH_USER_HOME}/.plomlib.sh/get_passphrase"
-. "${PATH_USER_HOME}/.plomlib.sh/path_tmp_timestamped"
+. lib/constants  # PATH_USER_HOME, USERNAME
+. lib/expect_min_n_args
+. lib/get_passphrase
+. lib/path_tmp_timestamped
 
 PATH_REL_SECRETS=to_usb
 export PATH_SECRETS="${PATH_USER_HOME}/${PATH_REL_SECRETS}"
 
 PATH_REL_SECRETS=to_usb
 export PATH_SECRETS="${PATH_USER_HOME}/${PATH_REL_SECRETS}"