[Lxc-users] [PATCH 1/1] lxc-fedora.in

rhanna at informatiq.org rhanna at informatiq.org
Sun Mar 4 18:39:45 UTC 2012


From: InformatiQ <rhanna at informatiq.org>

* fix cached rootfs update
* fix rootfs path
* add handling of systemd (aka >f15)


Signed-off-by: InformatiQ <rhanna at informatiq.org>
---
 templates/lxc-fedora.in |   33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in
index e7f42a6..1873373 100644
--- a/templates/lxc-fedora.in
+++ b/templates/lxc-fedora.in
@@ -69,11 +69,6 @@ EOF
 127.0.0.1 localhost $name
 EOF
 
-    sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit
-    sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit
-    chroot ${rootfs_path} chkconfig udev-post off
-    chroot ${rootfs_path} chkconfig network on
-
     dev_path="${rootfs_path}/dev"
     rm -rf $dev_path
     mkdir -p $dev_path
@@ -99,6 +94,21 @@ EOF
 
     return 0
 }
+configure_fedora_init()
+{
+    sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit
+    sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit
+    chroot ${rootfs_path} chkconfig udev-post off
+    chroot ${rootfs_path} chkconfig network on
+}
+
+configure_fedora_systemd()
+{
+    unlink ${rootfs_path}/etc/systemd/system/default.target
+    touch ${rootfs_path}/etc/fstab
+    chroot ${rootfs_path} ln -s /dev/null //etc/systemd/system/udev.service
+    chroot ${rootfs_path} ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
+}
 
 download_fedora()
 {
@@ -170,7 +180,8 @@ copy_fedora()
 
 update_fedora()
 {
-    chroot $cache/rootfs yum -y update
+    YUM="yum --installroot $cache/rootfs -y --nogpgcheck"
+    $YUM update
 }
 
 install_fedora()
@@ -353,7 +364,7 @@ if [ "$(id -u)" != "0" ]; then
 fi
 
 
-rootfs_path=$path/$name/rootfs
+rootfs_path=$path/rootfs
 config_path=$default_path/$name
 cache=$cache_base/$release
 
@@ -362,7 +373,7 @@ revert()
     echo "Interrupted, so cleaning up"
     lxc-destroy -n $name
     # maybe was interrupted before copy config
-    rm -rf $path/$name
+    rm -rf $path
     rm -rf $default_path/$name
     echo "exiting..."
     exit 1
@@ -388,6 +399,12 @@ if [ $? -ne 0 ]; then
     exit 1
 fi
 
+type /bin/systemd >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+    configure_fedora_init
+else
+    configure_fedora_systemd
+fi
 
 if [ ! -z $clean ]; then
     clean || exit 1
-- 
1.7.7.6





More information about the lxc-users mailing list