Add support to set hostname

This commit is contained in:
rockstable 2022-12-10 23:34:08 +01:00
parent 9f6d352899
commit 3bc3dbe301
3 changed files with 17 additions and 1 deletions

View File

@ -39,6 +39,7 @@ fai_flags:
- sshd
- createvt
- menu
fai_install_hostname: "user-pc"
fai_hw4f_password_salt: "toXu6kiez1haetan"
fai_hw4f_rootpw_fai: "fai"

View File

@ -6,7 +6,7 @@ TIMEZONE="Europe/Berlin"
STOP_ON_ERROR=700
MAXPACKAGES=800
HOSTNAME="user-pc"
INSTALL_HOSTNAME="{{ fai_install_hostname }}"
KEYMAP="de-latin1-nodeadkeys"

View File

@ -0,0 +1,15 @@
#!/bin/bash
error=0; trap 'error=$(($?>$error?$?:$error))'
if [ -n "$INSTALL_HOSTNAME" ]; then
echo "Setting HOSTNAME to '$INSTALL_HOSTNAME'"
echo "$INSTALL_HOSTNAME" > "$target/etc/hostname"
else
echo "Variable HOSTNAME is empty. Not setting HOSTNAME."
fi
echo "Removing FAI server from /etc/hosts"
sed -ri -e '/{{ server_name }}/d' "$target/etc/hosts"
exit $error