Skip to content

Commit

Permalink
copy as templates
Browse files Browse the repository at this point in the history
  • Loading branch information
nothub committed Oct 26, 2023
1 parent 4f46633 commit d50c5f5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
42 changes: 21 additions & 21 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if ! sha256sum -c <<<"$(grep "${iso_file}" SHA256SUMS)"; then
exit 1
fi

workdir=$(mktemp --directory)
workdir="$(mktemp --directory)"

# unpack iso
xorriso \
Expand All @@ -69,36 +69,36 @@ xorriso \
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"

# copy files to include
cp -a configs/* "${workdir}"
cp -a installer/* "${workdir}"

# replace tokens
## username
find configs installer -type f -exec sed -i "s#@USERNAME@#${username}#" {} \;
## password hash
find "${workdir}" -type f -exec sed -i "s#@USERNAME@#${username}#" {} \;
salt="$(pwgen -ns 16 1)"
hash="$(mkpasswd -m sha-512 -S "${salt}" "${password}")"
sed -i "s#@PASSHASH@#${hash}#" "installer/preseed.cfg"
## hostname
sed -i "s#@HOSTNAME@#${hostname}#" "installer/preseed.cfg"
## domain
sed -i "s#@DOMAIN@#${domain}#" "installer/preseed.cfg"
sed -i "s#@PASSHASH@#${hash}#" "${workdir}/preseed.cfg"
sed -i "s#@HOSTNAME@#${hostname}#" "${workdir}/preseed.cfg"
sed -i "s#@DOMAIN@#${domain}#" "${workdir}/preseed.cfg"

# repack iso
rm -f "${iso_file//.iso/-auto.iso}"
xorriso -indev "${iso_file}" \
-map "${workdir}/isolinux.cfg" "/isolinux/isolinux.cfg" \
-map "${workdir}/adtxt.cfg" "/isolinux/adtxt.cfg" \
-map "installer/preseed.cfg" "/preseed.cfg" \
-map "installer/late.sh" "/late.sh" \
-map "installer/splash.png" "/isolinux/splash.png" \
-map "configs/motd" "/configs/motd" \
-map "configs/issue" "/configs/issue" \
-map "configs/sshd_config" "/configs/sshd_config" \
-map "configs/bashrc.bash" "/configs/bashrc.bash" \
-map "configs/authorized_keys" "/configs/authorized_keys" \
-map "${workdir}/adtxt.cfg" "/isolinux/adtxt.cfg" \
-map "${workdir}/isolinux.cfg" "/isolinux/isolinux.cfg" \
-map "${workdir}/splash.png" "/isolinux/splash.png" \
-map "${workdir}/late.sh" "/late.sh" \
-map "${workdir}/preseed.cfg" "/preseed.cfg" \
-map "${workdir}/authorized_keys" "/configs/authorized_keys" \
-map "${workdir}/bashrc.bash" "/configs/bashrc.bash" \
-map "${workdir}/issue" "/configs/issue" \
-map "${workdir}/motd" "/configs/motd" \
-map "${workdir}/sshd_config" "/configs/sshd_config" \
-boot_image isolinux dir=/isolinux \
-outdev "${iso_file//.iso/-auto.iso}"

rm -rf "${workdir}"

echo "host: ${hostname}.${domain}"
echo "user: ${username}"
echo "pass: ${password}"

rm -rf "${workdir}"
1 change: 0 additions & 1 deletion installer/preseed.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ d-i mirror/udeb/suite string stable
d-i passwd/root-login boolean false
d-i passwd/user-fullname string
d-i passwd/username string @USERNAME@
#This password hash will be replaced when executing build.sh
d-i passwd/user-password-crypted password @PASSHASH@
d-i user-setup/encrypt-home boolean false

Expand Down

0 comments on commit d50c5f5

Please sign in to comment.