diff --git a/debian/chroot.install b/debian/chroot.install index bb87bc3..b00e4d8 100755 --- a/debian/chroot.install +++ b/debian/chroot.install @@ -9,7 +9,8 @@ else exit 0 fi ## Computer hostname -new_hostname="ks10" +## If empty, the script will try to get one with nslookup +new_hostname="" ## Volume Group name to use for LVM vgname="ovhsys" ## If the script should manage the partitions (delete, add,…) @@ -227,7 +228,14 @@ chroot /target update-grub ## }}} ## Hostname {{{ -printf '%b\n' "${new_hostname}" > /target/etc/hostname + +if [ -z "${new_hostname}" ]; then + lookup_hostname=$(nslookup "${net_address}" || echo "server name = new_server") + get_hostname=$(echo "${lookup_hostname}" | awk '/name =/{print $4;}' | cut -d. -f1) + printf '%b\n' "${get_hostname}" > /target/etc/hostname +else + printf '%b\n' "${new_hostname}" > /target/etc/hostname +fi #printf '%b\n' "127.0.0.1 ${new_hostname}" >> /target/etc/hosts ## }}}