Description: Use ubuntu/ubuntu instead of root/root by default.
             Also stop removing tty[56].conf in Precise.
             Stop messing with dhclient.conf (default behavior is identical)
             Set devttydir on Precise to /dev/lxc to allow for clean upgrades.
Author: Stéphane Graber <stgraber@ubuntu.com>

Index: lxc/templates/lxc-ubuntu.in
===================================================================
--- lxc.orig/templates/lxc-ubuntu.in	2012-02-10 22:30:22.188422468 -0500
+++ lxc/templates/lxc-ubuntu.in	2012-02-10 23:23:23.521324942 -0500
@@ -34,6 +34,7 @@
 {
     rootfs=$1
     hostname=$2
+    release=$3
 
    # configure the network using the dhcp
     cat <<EOF > $rootfs/etc/network/interfaces
@@ -44,13 +45,6 @@
 iface eth0 inet dhcp
 EOF
 
-    # so you can 'ssh $hostname.' or 'ssh $hostname.local'
-    if [ -f $rootfs/etc/dhcp/dhclient.conf ]; then
-        sed -i "s/<hostname>/$hostname/" $rootfs/etc/dhcp/dhclient.conf
-    elif [ -f $rootfs/etc/dhcp3/dhclient.conf ]; then
-        sed -i "s/<hostname>/$hostname/" $rootfs/etc/dhcp3/dhclient.conf
-    fi
-
     # set the hostname
     cat <<EOF > $rootfs/etc/hostname
 $hostname
@@ -60,16 +54,22 @@
 127.0.0.1 localhost $hostname
 EOF
 
-    # suppress log level output for udev
-    sed -i "s/=\"err\"/=0/" $rootfs/etc/udev/udev.conf
+    if [ "$release" = "precise" ]; then
+        group="sudo"
+    else
+        group="admin"
 
-    # remove jobs for consoles 5 and 6 since we only create 4 consoles in
-    # this template
-    rm -f $rootfs/etc/init/tty{5,6}.conf
+        # suppress log level output for udev
+        sed -i "s/=\"err\"/=0/" $rootfs/etc/udev/udev.conf
 
-    echo "Please change root-password !"
-    echo "root:root" | chroot $rootfs chpasswd
+        # remove jobs for consoles 5 and 6 since we only create 4 consoles in
+        # this template
+        rm -f $rootfs/etc/init/tty{5,6}.conf
+    fi
 
+    chroot $rootfs groupadd --system $group >/dev/null 2>&1 || true
+    chroot $rootfs useradd --create-home -s /bin/bash -G $group ubuntu
+    echo "ubuntu:ubuntu" | chroot $rootfs chpasswd
     return 0
 }
 
@@ -191,7 +191,7 @@
     rootfs=$3
 
     # make a local copy of the miniubuntu
-    echo -n "Copying rootfs to $rootfs ..."
+    echo "Copying rootfs to $rootfs ..."
     mkdir -p $rootfs
     rsync -a $cache/rootfs-$arch/ $rootfs/ || return 1
     return 0
@@ -247,14 +247,21 @@
     rootfs=$2
     name=$3
     arch=$4
+    release=$5
 
     if [ $arch = "i386" ]; then
         arch="i686"
     fi
 
+    ttydir=""
+    if [ $release = "precise" ]; then
+        ttydir=" lxc"
+    fi
+
     cat <<EOF >> $path/config
 lxc.utsname = $name
 
+lxc.devttydir = $ttydir
 lxc.tty = 4
 lxc.pts = 1024
 lxc.rootfs = $rootfs
@@ -577,13 +584,13 @@
     exit 1
 fi
 
-configure_ubuntu $rootfs $name
+configure_ubuntu $rootfs $name $release
 if [ $? -ne 0 ]; then
     echo "failed to configure ubuntu $release for a container"
     exit 1
 fi
 
-copy_configuration $path $rootfs $name $arch
+copy_configuration $path $rootfs $name $arch $release
 if [ $? -ne 0 ]; then
     echo "failed write configuration file"
     exit 1
@@ -593,3 +600,10 @@
 if [ ! -z $bindhome ]; then
 	do_bindhome $rootfs $bindhome
 fi
+
+echo ""
+echo "##"
+echo "# The default user is 'ubuntu' with password 'ubuntu'!"
+echo "# Use the 'sudo' command to run tasks as root in the container."
+echo "##"
+echo ""
