Set $(hostname) in /etc/hosts during node spinup
[releng/builder.git] / jenkins-scripts / mininet-ubuntu.sh
index 0b925bb29b7b1285db0b50427cf6a90483398c29..7f0cd569ef76c7f4bed431f669c4d8b37ca3a4f6 100755 (executable)
@@ -8,3 +8,9 @@ EOF
 
 # disable the firewall
 /bin/bash ./disable_firewall.sh
+
+# Add 'hostname' into /etc/hosts during node spinup time to avoid sudo returning
+# an 'unable to resolve host' message or some Java API's returning an unknown
+# host exception. The workaround on adding "myhostname" into /etc/nss-switch.conf
+# does not work on Ubuntu flavours.
+sed -i "/127.0.0.1/s/$/\t$(hostname)/" /etc/hosts