[Bug 1042431] [NEW] lxc-start-ephemeral needs tweak to handle centos and fedora hostname setting

Dan Kegel dank at kegel.com
Mon Aug 27 21:31:50 UTC 2012


Public bug reported:

As discussed in the thread "lxc template for RHEL?"
http://sourceforge.net/mailarchive/message.php?msg_id=29730103
lxc-start-ephemeral only knows how to tweak the hostname for ubuntu and debian,
and needs to be taught about where rhel and centos put hostname, something like this:

--- lxc-start-ephemeral.orig	2012-08-27 12:19:03.935513119 -0700
+++ lxc-start-ephemeral	2012-08-27 12:19:54.471514479 -0700
@@ -154,7 +154,19 @@
     LXC_MOUNTED=1

     # Update the ephemeral lxc's configuration to reflect the new
container name.
-    sudo sed -i -e "s/$LXC_BASE/$LXC_NAME/" $LXC_DIR/fstab $LXC_DIR/config $LXC_DIR/rootfs/etc/hostname $LXC_DIR/rootfs/etc/hosts
+    # Check all the places known distros keep hostnames.
+    # FIXME: should we sanity check the hostname to make sure it contains no bad chars?
+    for file in $LXC_DIR/fstab $LXC_DIR/config \
+                $LXC_DIR/rootfs/etc/hostname \
+                $LXC_DIR/rootfs/etc/hosts \
+                $LXC_DIR/rootfs/etc/sysconfig/network \
+                $LXC_DIR/rootfs/etc/sysconfig/network-scripts/ifcfg-eth0
+    do
+        if test -f "$file"
+        then
+            sudo sed -i -e "s/$LXC_BASE/$LXC_NAME/" $file
+        fi
+    done

     # Update the fstab to have all bind mounts be ephemeral.
     sudo cp $LXC_DIR/fstab $LXC_DIR/fstab.old

This affects 12.04 and the ppa for lxc, so probably also 12.10 alpha 3.

** Affects: lxc (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to lxc in Ubuntu.
https://bugs.launchpad.net/bugs/1042431

Title:
  lxc-start-ephemeral needs tweak to handle centos and fedora hostname
  setting

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1042431/+subscriptions



More information about the Ubuntu-server-bugs mailing list