From c7cacb73001e399a6eba6524702050eac7192c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BCbner?= Date: Wed, 6 Dec 2023 23:41:13 +0100 Subject: [PATCH] poweroff flag --- build.sh | 16 ++++++++++++++-- installer/preseed.cfg | 5 ++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index a59031a..fa4d4d4 100755 --- a/build.sh +++ b/build.sh @@ -5,7 +5,7 @@ set -o nounset set -o pipefail usage() { - echo "Usage: $0 [-u username] [-p password] [-n hostname] [-d domain] [-a package] [-i iso_url] [-s sign_key] [-o path] [-v] [-h]" + echo "Usage: $0 [-u username] [-p password] [-n hostname] [-d domain] [-a package] [-i iso_url] [-s sign_key] [-o path] [-x] [-v] [-h]" echo "Options:" echo " -u Admin username" echo " -p Admin password" @@ -15,6 +15,7 @@ usage() { echo " -i ISO download URL" echo " -s ISO pgp sign key" echo " -o ISO output file" + echo " -x Power off after install" echo " -v Enable verbose mode" echo " -h Display this help message" } @@ -28,8 +29,9 @@ iso_url="https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.2.0 sign_key="DA87E80D6294BE9B" out_file="debian-12.2.0-amd64-auto.iso" apt_pkgs=() +poweroff="" -while getopts u:p:n:d:a:i:s:o:vh opt; do +while getopts u:p:n:d:a:i:s:o:xvh opt; do case $opt in u) username="$OPTARG" ;; p) password="$OPTARG" ; password_mask="true" ;; @@ -39,6 +41,7 @@ while getopts u:p:n:d:a:i:s:o:vh opt; do i) iso_url="$OPTARG" ;; s) sign_key="$OPTARG" ;; o) out_file="$OPTARG" ;; + x) poweroff="true" ;; v) set -o xtrace ;; h) usage ; exit 0 ;; *) usage ; exit 1 ;; @@ -100,6 +103,13 @@ replace_token "@HOSTNAME@" "${hostname}" replace_token "@DOMAIN@" "${domain}" replace_token "@PACKAGES@" "${apt_pkgs[*]}" +# add poweroff option +if test -n "${poweroff}"; then + replace_token "@POWEROFF@" "true" +else + replace_token "@POWEROFF@" "false" +fi + # clear existing output iso file if test -f "${out_file}"; then rm -f "${out_file}" @@ -125,3 +135,5 @@ echo "user: ${username}" echo "pass: ${password}" rm -rf "${workdir}" + +sha256sum "${out_file}" >"${out_file}.sum" diff --git a/installer/preseed.cfg b/installer/preseed.cfg index 34891c9..50ae0ce 100644 --- a/installer/preseed.cfg +++ b/installer/preseed.cfg @@ -76,5 +76,8 @@ d-i grub-installer/with_other_os boolean false d-i grub-installer/bootdev string default ### Misc -d-i finish-install/reboot_in_progress note d-i preseed/late_command string sh -c /cdrom/late.sh + +### Post-Install +d-i finish-install/reboot_in_progress note +d-i debian-installer/exit/poweroff boolean @POWEROFF@