Skip to content

Commit

Permalink
hostname + domain
Browse files Browse the repository at this point in the history
  • Loading branch information
nothub committed Oct 26, 2023
1 parent 621698c commit ba21467
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
25 changes: 15 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ set -o nounset
set -o pipefail

# TODO: flags
admin_user="hub"
admin_pass="$(pwgen -ns 16 1)"

debian_signing_key="DA87E80D6294BE9B"
username="hub"
password="$(pwgen -ns 16 1)"
hostname="machine"
domain="hub.lol"
iso_url="https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.2.0-amd64-netinst.iso"
signing_key="DA87E80D6294BE9B"

# download
iso_file=$(basename ${iso_url})
Expand All @@ -21,7 +22,7 @@ curl --silent --location --remote-name "$(dirname ${iso_url})/SHA256SUMS"
curl --silent --location --remote-name "$(dirname ${iso_url})/SHA256SUMS.sign"

# verify
gpg --keyserver keyring.debian.org --recv "${debian_signing_key}"
gpg --keyserver keyring.debian.org --recv "${signing_key}"
gpg --verify SHA256SUMS.sign SHA256SUMS
if ! sha256sum -c <<<"$(grep "${iso_file}" SHA256SUMS)"; then
echo >&2 "Error: Checksum not matching for: ${iso_file}"
Expand All @@ -42,13 +43,17 @@ sed -i "s#default vesamenu.c32#default auto#" "${workdir}/isolinux.cfg"
sed -i "s#auto=true#auto=true file=/cdrom/preseed.cfg#" "${workdir}/adtxt.cfg"

# admin user name
sed -i "s#admin=.*#admin=\"${admin_user}\"#" "installer/late.sh"

sed -i "s#admin=.*#admin=\"${username}\"#" "installer/late.sh"
# admin password
salt="$(pwgen -ns 16 1)"
hash="$(mkpasswd -m sha-512 -S "${salt}" "${admin_pass}")"
hash="$(mkpasswd -m sha-512 -S "${salt}" "${password}")"
sed -i "s#d-i passwd/user-password-crypted password.*#d-i passwd/user-password-crypted password ${hash}#" "installer/preseed.cfg"

# hostname
sed -i "s#d-i netcfg/get_hostname string.*#d-i netcfg/get_hostname string ${hostname}#" "installer/preseed.cfg"
# domain
sed -i "s#d-i netcfg/get_domain string.*#d-i netcfg/get_domain string ${domain}#" "installer/preseed.cfg"

# repack iso
rm -f "${iso_file//.iso/-auto.iso}"
xorriso -indev "${iso_file}" \
Expand All @@ -66,5 +71,5 @@ xorriso -indev "${iso_file}" \

rm -rf "${workdir}"

echo "user: ${admin_user}"
echo "pass: ${admin_pass}"
echo "user: ${username}"
echo "pass: ${password}"
4 changes: 2 additions & 2 deletions installer/preseed.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ d-i keyboard-configuration/xkb-keymap select de
### Network
d-i netcfg/choose_interface select auto
# Any hostname and domain names assigned from dhcp take precedence over values set here.
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/get_hostname string @HOSTNAME@
d-i netcfg/get_domain string @DOMAIN@
d-i hw-detect/load_firmware boolean true

### Mirror settings
Expand Down

0 comments on commit ba21467

Please sign in to comment.