Commit f6144f0c by Serge Hallyn Committed by Daniel Lezcano

ubuntu template changes

Author: Stéphane Graber <stgraber@ubuntu.com> Use ubuntu/ubuntu instead of root/root by default. Stop removing tty[56].conf in Precise. Stop messing with dhclient.conf. Set devttydir on Precise to /dev/lxc to allow for clean upgrades. Signed-off-by: 's avatarStéphane Graber <stgraber@ubuntu.com> Signed-off-by: 's avatarSerge Hallyn <serge@hallyn.com> Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 7c6ef2a2
...@@ -32,6 +32,7 @@ configure_ubuntu() ...@@ -32,6 +32,7 @@ configure_ubuntu()
{ {
rootfs=$1 rootfs=$1
hostname=$2 hostname=$2
release=$3
# configure the network using the dhcp # configure the network using the dhcp
cat <<EOF > $rootfs/etc/network/interfaces cat <<EOF > $rootfs/etc/network/interfaces
...@@ -42,13 +43,6 @@ auto eth0 ...@@ -42,13 +43,6 @@ auto eth0
iface eth0 inet dhcp iface eth0 inet dhcp
EOF 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 # set the hostname
cat <<EOF > $rootfs/etc/hostname cat <<EOF > $rootfs/etc/hostname
$hostname $hostname
...@@ -58,16 +52,22 @@ EOF ...@@ -58,16 +52,22 @@ EOF
127.0.0.1 localhost $hostname 127.0.0.1 localhost $hostname
EOF EOF
# suppress log level output for udev if [ "$release" = "precise" ]; then
sed -i "s/=\"err\"/=0/" $rootfs/etc/udev/udev.conf group="sudo"
else
group="admin"
# remove jobs for consoles 5 and 6 since we only create 4 consoles in # suppress log level output for udev
# this template sed -i "s/=\"err\"/=0/" $rootfs/etc/udev/udev.conf
rm -f $rootfs/etc/init/tty{5,6}.conf
echo "Please change root-password !" # remove jobs for consoles 5 and 6 since we only create 4 consoles in
echo "root:root" | chroot $rootfs chpasswd # 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 return 0
} }
...@@ -217,7 +217,7 @@ copy_ubuntu() ...@@ -217,7 +217,7 @@ copy_ubuntu()
rootfs=$3 rootfs=$3
# make a local copy of the miniubuntu # make a local copy of the miniubuntu
echo -n "Copying rootfs to $rootfs ..." echo "Copying rootfs to $rootfs ..."
mkdir -p $rootfs mkdir -p $rootfs
rsync -a $cache/rootfs-$arch/ $rootfs/ || return 1 rsync -a $cache/rootfs-$arch/ $rootfs/ || return 1
return 0 return 0
...@@ -266,14 +266,21 @@ copy_configuration() ...@@ -266,14 +266,21 @@ copy_configuration()
rootfs=$2 rootfs=$2
name=$3 name=$3
arch=$4 arch=$4
release=$5
if [ $arch = "i386" ]; then if [ $arch = "i386" ]; then
arch="i686" arch="i686"
fi fi
ttydir=""
if [ $release = "precise" ]; then
ttydir=" lxc"
fi
cat <<EOF >> $path/config cat <<EOF >> $path/config
lxc.utsname = $name lxc.utsname = $name
lxc.devttydir = $ttydir
lxc.tty = 4 lxc.tty = 4
lxc.pts = 1024 lxc.pts = 1024
lxc.rootfs = $rootfs lxc.rootfs = $rootfs
...@@ -619,13 +626,13 @@ if [ $? -ne 0 ]; then ...@@ -619,13 +626,13 @@ if [ $? -ne 0 ]; then
exit 1 exit 1
fi fi
configure_ubuntu $rootfs $name configure_ubuntu $rootfs $name $release
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "failed to configure ubuntu $release for a container" echo "failed to configure ubuntu $release for a container"
exit 1 exit 1
fi fi
copy_configuration $path $rootfs $name $arch copy_configuration $path $rootfs $name $arch $release
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "failed write configuration file" echo "failed write configuration file"
exit 1 exit 1
...@@ -640,3 +647,10 @@ if [ ! -z $clean ]; then ...@@ -640,3 +647,10 @@ if [ ! -z $clean ]; then
clean $release || exit 1 clean $release || exit 1
exit 0 exit 0
fi 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 ""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment