Commit cb26f1a5 by Stéphane Graber

Various fedora template improvements

1. don't add network segment to config 2. check for 'curl' 3. don't add $name to $path, it's already in there 4. don't add devpts to fstab, that's wrong. 5. $UTSNAME doesn't exist 6. set root pwd to root instead of rooter. 7. install fedora-release package. 8. add a console on /dev/console. 9. create empty fstab 10. don't mount devpts in rc.sysinit. Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 337e1471
...@@ -29,9 +29,7 @@ ...@@ -29,9 +29,7 @@
arch=$(arch) arch=$(arch)
cache_base=/var/cache/lxc/fedora/$arch cache_base=/var/cache/lxc/fedora/$arch
default_path=/var/lib/lxc default_path=/var/lib/lxc
root_password=rooter root_password=root
lxc_network_type=veth
lxc_network_link=virbr0
# is this fedora? # is this fedora?
[ -f /etc/fedora-release ] && is_fedora=true [ -f /etc/fedora-release ] && is_fedora=true
...@@ -52,7 +50,7 @@ configure_fedora() ...@@ -52,7 +50,7 @@ configure_fedora()
DEVICE=eth0 DEVICE=eth0
BOOTPROTO=dhcp BOOTPROTO=dhcp
ONBOOT=yes ONBOOT=yes
HOSTNAME=${UTSNAME} HOSTNAME=${name}
NM_CONTROLLED=no NM_CONTROLLED=no
TYPE=Ethernet TYPE=Ethernet
MTU=${MTU} MTU=${MTU}
...@@ -61,7 +59,7 @@ EOF ...@@ -61,7 +59,7 @@ EOF
# set the hostname # set the hostname
cat <<EOF > ${rootfs_path}/etc/sysconfig/network cat <<EOF > ${rootfs_path}/etc/sysconfig/network
NETWORKING=yes NETWORKING=yes
HOSTNAME=${UTSNAME} HOSTNAME=${name}
EOF EOF
# set minimal hosts # set minimal hosts
...@@ -92,12 +90,26 @@ EOF ...@@ -92,12 +90,26 @@ EOF
echo "setting root passwd to $root_password" echo "setting root passwd to $root_password"
echo "root:$root_password" | chroot $rootfs_path chpasswd echo "root:$root_password" | chroot $rootfs_path chpasswd
# specifying this in the initial packages doesn't always work.
echo "installing fedora-release package"
chroot ${rootfs_path} yum --releasever=${release} -y install fedora-release
# silence some needless startup errors
touch ${rootfs_path}/etc/fstab
# give us a console on /dev/console
sed -i 's/ACTIVE_CONSOLES=.*$/ACTIVE_CONSOLES="\/dev\/console \/dev\/tty[1-4]"/' \
${rootfs_path}/etc/sysconfig/init
return 0 return 0
} }
configure_fedora_init() configure_fedora_init()
{ {
sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit
sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit
# don't mount devpts, for pete's sake
sed -i 's/^.*dev.pts.*$/#\0/' ${rootfs_path}/etc/rc.sysinit
sed -i 's/^.*dev.pts.*$/#\0/' ${rootfs_path}/etc/rc.d/rc.sysinit
chroot ${rootfs_path} chkconfig udev-post off chroot ${rootfs_path} chkconfig udev-post off
chroot ${rootfs_path} chkconfig network on chroot ${rootfs_path} chkconfig network on
} }
...@@ -126,7 +138,7 @@ download_fedora() ...@@ -126,7 +138,7 @@ download_fedora()
# download a mini fedora into a cache # download a mini fedora into a cache
echo "Downloading fedora minimal ..." echo "Downloading fedora minimal ..."
YUM="yum --installroot $INSTALL_ROOT -y --nogpgcheck" YUM="yum --installroot $INSTALL_ROOT -y --nogpgcheck"
PKG_LIST="yum initscripts passwd rsyslog vim-minimal dhclient chkconfig rootfiles policycoreutils" PKG_LIST="yum initscripts passwd rsyslog vim-minimal dhclient chkconfig rootfiles policycoreutils fedora-release"
MIRRORLIST_URL="http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$release&arch=$arch" MIRRORLIST_URL="http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$release&arch=$arch"
DOWNLOAD_OK=no DOWNLOAD_OK=no
...@@ -241,12 +253,6 @@ lxc.mount = $config_path/fstab ...@@ -241,12 +253,6 @@ lxc.mount = $config_path/fstab
# When using LXC with apparmor, uncomment the next line to run unconfined: # When using LXC with apparmor, uncomment the next line to run unconfined:
#lxc.aa_profile = unconfined #lxc.aa_profile = unconfined
#networking
lxc.network.type = $lxc_network_type
lxc.network.flags = up
lxc.network.link = $lxc_network_link
lxc.network.name = eth0
lxc.network.mtu = 1500
#cgroups #cgroups
lxc.cgroup.devices.deny = a lxc.cgroup.devices.deny = a
# /dev/null and zero # /dev/null and zero
...@@ -268,7 +274,6 @@ EOF ...@@ -268,7 +274,6 @@ EOF
cat <<EOF > $config_path/fstab cat <<EOF > $config_path/fstab
proc proc proc nodev,noexec,nosuid 0 0 proc proc proc nodev,noexec,nosuid 0 0
devpts dev/pts devpts defaults 0 0
sysfs sys sysfs defaults 0 0 sysfs sys sysfs defaults 0 0
EOF EOF
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
...@@ -345,9 +350,21 @@ if [ ! -z "$clean" -a -z "$path" ]; then ...@@ -345,9 +350,21 @@ if [ ! -z "$clean" -a -z "$path" ]; then
exit 0 exit 0
fi fi
needed_pkgs=""
type yum >/dev/null 2>&1 type yum >/dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "'yum' command is missing" needed_pkgs="yum $needed_pkgs"
exit 1
fi
type curl >/dev/null 2>&1
if [ $? -ne 0 ]; then
needed_pkgs="curl $needed_pkgs"
fi
if [ -n "$needed_pkgs" ]; then
echo "Missing commands: $needed_pkgs"
echo "Please install these using \"sudo apt-get install $needed_pkgs\""
exit 1 exit 1
fi fi
...@@ -370,7 +387,11 @@ if [ "$(id -u)" != "0" ]; then ...@@ -370,7 +387,11 @@ if [ "$(id -u)" != "0" ]; then
fi fi
rootfs_path=$path/rootfs rootfs_path=$path/$name/rootfs
# check for 'lxc.rootfs' passed in through default config by lxc-create
if grep -q '^lxc.rootfs' $path/config 2>/dev/null ; then
rootfs_path=`grep 'lxc.rootfs =' $path/config | awk -F= '{ print $2 }'`
fi
config_path=$default_path/$name config_path=$default_path/$name
cache=$cache_base/$release cache=$cache_base/$release
...@@ -417,4 +438,3 @@ if [ ! -z $clean ]; then ...@@ -417,4 +438,3 @@ if [ ! -z $clean ]; then
exit 0 exit 0
fi fi
echo "container rootfs and config created" echo "container rootfs and config created"
echo "container is configured for lxc.network.type=veth and lxc.network.link=virbr0 (which is default if you have libvirt runnig)"
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