We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4b9bc4c commit 88b4f59Copy full SHA for 88b4f59
slib.sh
@@ -475,12 +475,13 @@ set_hostname () {
475
log_warning "Hostname $line is not fully qualified."
476
else
477
hostname "$line"
478
+ echo "$line" > /etc/hostname
479
detect_ip
480
shortname=$(echo "$line" | cut -d"." -f1)
- if grep "$address" /etc/hosts; then
481
+ if grep "^$address" /etc/hosts >/dev/null; then
482
log_debug "Entry for IP $address exists in /etc/hosts."
483
log_debug "Updating with new hostname."
- sed -i "s/^$address\([\s\t]+\).*$/$address\1$line\t$shortname/" /etc/hosts
484
+ sed -i "s/^$address\([\s\t]+\).*$/$address $line $shortname/" /etc/hosts
485
486
log_debug "Adding new entry for hostname $line on $address to /etc/hosts."
487
printf "%s\t%s\t%s\n" "$address" "$line" "$shortname" >> /etc/hosts
0 commit comments