fi
# remove pointless services in a container
- chroot $rootfs /usr/sbin/update-rc.d -f checkroot.sh remove
- chroot $rootfs /usr/sbin/update-rc.d -f umountfs remove
- chroot $rootfs /usr/sbin/update-rc.d -f hwclock.sh remove
- chroot $rootfs /usr/sbin/update-rc.d -f hwclockfirst.sh remove
+ chroot $rootfs /usr/sbin/update-rc.d -f checkroot.sh disable
+ chroot $rootfs /usr/sbin/update-rc.d -f umountfs disable
+ chroot $rootfs /usr/sbin/update-rc.d -f hwclock.sh disable
+ chroot $rootfs /usr/sbin/update-rc.d -f hwclockfirst.sh disable
# generate new SSH keys
if [ -x $rootfs/var/lib/dpkg/info/openssh-server.postinst ]; then
{
path=$1
rootfs=$2
+
init="$(chroot ${rootfs} dpkg-query --search /sbin/init | cut -d : -f 1)"
- if [ "$init" != "systemd-sysv" ]; then
- # systemd is not PID 1
- return
+ if [ "$init" = "systemd-sysv" ]; then
+ # only appropiate when systemd is PID 1
+ echo 'lxc.autodev = 1' >> "$path/config"
+ echo 'lxc.kmsg = 0' >> "$path/config"
+ fi
+
+ # this only works if we have getty@.service to manipulate
+ if [ -f ${rootfs}/lib/systemd/system/getty\@.service ]; then
+ sed -e 's/^ConditionPathExists=/# ConditionPathExists=/' \
+ -e 's/After=dev-%i.device/After=/' \
+ < ${rootfs}/lib/systemd/system/getty\@.service \
+ > ${rootfs}/etc/systemd/system/getty\@.service
fi
- echo 'lxc.autodev = 1' >> "$path/config"
- echo 'lxc.kmsg = 0' >> "$path/config"
+ # just in case systemd is not installed
+ mkdir -p ${rootfs}/{lib,etc}/systemd/system
+ mkdir -p ${rootfs}/etc/systemd/system/getty.target.wants
# This function has been copied and adapted from lxc-fedora
rm -f ${rootfs}/etc/systemd/system/default.target
touch ${rootfs}/etc/fstab
- chroot ${rootfs} ln -s /dev/null /etc/systemd/system/udev.service
+ chroot ${rootfs} ln -s /dev/null /etc/systemd/system/systemd-udevd.service
chroot ${rootfs} ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
# Make systemd honor SIGPWR
chroot ${rootfs} ln -s /lib/systemd/system/halt.target /etc/systemd/system/sigpwr.target
- sed -e 's/^ConditionPathExists=/# ConditionPathExists=/' \
- -e 's/After=dev-%i.device/After=/' \
- < ${rootfs}/lib/systemd/system/getty\@.service \
- > ${rootfs}/etc/systemd/system/getty\@.service
# Setup getty service on the 4 ttys we are going to allow in the
# default config. Number should match lxc.tty
( cd ${rootfs}/etc/systemd/system/getty.target.wants