diff options
author | Dieter Plaetinck <dieter@plaetinck.be> | 2009-03-08 17:33:31 +0100 |
---|---|---|
committer | Dieter Plaetinck <dieter@plaetinck.be> | 2009-03-08 17:33:31 +0100 |
commit | 4dd67fa4ffb704f695ace2b62f3a54ccf1d43ee9 (patch) | |
tree | 9a215083ebb7d82ae4ffe725a480b22ca308ab08 /src | |
parent | c8d426c97e9183425b9553340226da8133c9ede5 (diff) |
automatically update hostname in /etc/hosts after updating /etc/rc.conf. See FS#11416
Diffstat (limited to 'src')
-rw-r--r-- | src/core/libs/lib-ui-interactive.sh | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 42a2fd5..b9d5469 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -53,6 +53,17 @@ interactive_configure_system() else #regular file $EDITOR ${var_TARGET_DIR}${FILE} fi + + # if user edited /etc/rc.conf, add the hostname to /etc/hosts if it's not already there. + # note that if the user edits rc.conf several times to change the hostname more then once, we will add them all to /etc/hosts. this is not perfect, but to avoid this, too much code would be required (feel free to prove me wrong :)) + if [ "$FILE" = "/etc/rc.conf" ] + then + HOSTNAME=`sed -n '/^HOSTNAME/s/HOSTNAME=//p' ${var_TARGET_DIR}${FILE} | sed 's/"//'` + if ! grep '127\.0\.0\.1' ${var_TARGET_DIR}/etc/hosts | grep -q "$HOSTNAME" + then + sed -i "s/127\.0\.0\.1.*/& $HOSTNAME/" ${var_TARGET_DIR}/etc/hosts + fi + fi done # temporary backup files are not useful anymore past this point. |