Try to lookup for hostname if the var is empty
This commit is contained in:
parent
189a1ff13a
commit
3468bce210
|
@ -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
|
||||
|
||||
## }}}
|
||||
|
|
Loading…
Reference in New Issue