Skip to content

Commit

Permalink
poweroff flag
Browse files Browse the repository at this point in the history
  • Loading branch information
nothub committed Dec 6, 2023
1 parent d3d7751 commit c7cacb7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 14 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <username> Admin username"
echo " -p <password> Admin password"
Expand All @@ -15,6 +15,7 @@ usage() {
echo " -i <iso_url> ISO download URL"
echo " -s <sign_key> ISO pgp sign key"
echo " -o <out_file> ISO output file"
echo " -x Power off after install"
echo " -v Enable verbose mode"
echo " -h Display this help message"
}
Expand All @@ -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" ;;
Expand All @@ -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 ;;
Expand Down Expand Up @@ -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}"
Expand All @@ -125,3 +135,5 @@ echo "user: ${username}"
echo "pass: ${password}"

rm -rf "${workdir}"

sha256sum "${out_file}" >"${out_file}.sum"
5 changes: 4 additions & 1 deletion installer/preseed.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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@

0 comments on commit c7cacb7

Please sign in to comment.