]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
templates: CentOS fixes
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 7 Feb 2018 10:39:19 +0000 (11:39 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 7 Feb 2018 11:06:54 +0000 (12:06 +0100)
Issues fixed:
- lxc-centos died about a missing /run directory
- lxc-centos complained about some config files it couldn't modify
- the new container got stuck at startup time for a minute
  (literally), waiting for systemd-remount-fs startup script

Of course it still works for RHEL 6, CentOS 6 and 7 as well. I did not
verify earlier CentOS or RHEL releases.

Signed-off-by: Harald Dunkel <harald.dunkel@aixigo.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
templates/lxc-centos.in

index fc2da193746adcff0b22eb596fbe326351a86c81..949d576744f2b343f2573ec1a724b2816f03f3fb 100644 (file)
@@ -351,7 +351,7 @@ EOF
     # prevent mingetty from calling vhangup(2) since it fails with userns.
     # Same issue as oracle template: prevent mingetty from calling vhangup(2)
     # commit 2e83f7201c5d402478b9849f0a85c62d5b9f1589.
-    sed -i 's|mingetty|mingetty --nohangup|' $rootfs_path/etc/init/tty.conf
+    test -f $rootfs_path/etc/init/tty.conf && sed -i 's|mingetty|mingetty --nohangup|' $rootfs_path/etc/init/tty.conf
 
     if [ ${root_display_password} = "yes" ]
     then
@@ -381,13 +381,18 @@ EOF
 
 configure_centos_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
+    test -f ${rootfs_path}/etc/rc.sysinit && sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.sysinit
+    test -f ${rootfs_path}/etc/rc.d/rc.sysinit && sed -i 's|.sbin.start_udev||' ${rootfs_path}/etc/rc.d/rc.sysinit
     if [ "$release" = "6" ]; then
         chroot ${rootfs_path} chkconfig udev-post off
     fi
     chroot ${rootfs_path} chkconfig network on
 
+    if [ "$release" = "7" ]; then
+       # don't wait for the timeout
+       chroot ${rootfs_path} chkconfig systemd-remount-fs off
+    fi
+
     if [ -d ${rootfs_path}/etc/init ]
     then
        # This is to make upstart honor SIGPWR
@@ -462,6 +467,9 @@ EOF
     force_mknod 666 $INSTALL_ROOT/dev/null c 1 3
     force_mknod 666 $INSTALL_ROOT/dev/urandom c 1 9
 
+    # create /run directory, just in case it is missing (e.g. RHEL7)
+    mkdir -p $INSTALL_ROOT/run
+
     $YUM install $PKG_LIST
 
     # create symlink for /var/run -> ../run