Adding service handling for systemd containers.
authorDaniel Baumann <mail@daniel-baumann.ch>
Fri, 19 Apr 2013 13:22:13 +0000 (15:22 +0200)
committerDaniel Baumann <mail@daniel-baumann.ch>
Fri, 19 Apr 2013 13:22:19 +0000 (15:22 +0200)
scripts/debconfig/0040-systemd
scripts/debconfig/0040-systemd.templates

index 386d7c9..984d771 100755 (executable)
@@ -25,6 +25,7 @@ Defaults ()
 {
        _LXC_ENABLE="${_LXC_ENABLE:-false}"
        _LXC_CONSOLES="${_LXC_CONSOLES:-6}"
+       _LXC_DISABLE_SERVICES="${_LXC_DISABLE_SERVICES:-checkroot.service dev-hugepages.mount dev-mqueue.mount proc-sys-fs-binfmt_misc.automount remount-rootfs.service run-lock.mount run-user.mount swap.target sys-kernel-debug.mount sys-kernel-security.mount systemd-modules-load.service systemd-remount-api-vfs.service systemd-sysctl.service systemd-update-utmp-runlevel.service udev.service udev-settle.service udev-trigger.service user.mount var-lock.mount systemd-update-utmp-runlevel.service}"
 }
 
 db_get live-debconfig/systemd/lxc-enable
@@ -33,6 +34,9 @@ _LXC_ENABLE="${RET}" # boolean
 db_get live-debconfig/systemd/lxc-consoles
 _LXC_CONSOLES="${RET}" # string (w/o empty)
 
+db_get live-debconfig/systemd/lxc-disable-services
+_LXC_DISABLE_SERVICES="${RET}" # string (w/o empty)
+
 Defaults
 
 db_set live-debconfig/systemd/lxc-enable "${_LXC_ENABLE}"
@@ -41,6 +45,9 @@ db_fset live-debconfig/systemd/lxc-enable seen false
 db_set live-debconfig/systemd/lxc-consoles "${_LXC_CONSOLES}"
 db_fset live-debconfig/systemd/lxc-consoles seen false
 
+db_set live-debconfig/systemd/lxc-disable-services "${_LXC_DISABLE_SERVICES}"
+db_fset live-debconfig/systemd/lxc-disable-services seen false
+
 db_settitle live-debconfig/title
 db_input high live-debconfig/systemd/lxc-enable || true
 db_go
@@ -57,6 +64,9 @@ case "${_LXC_ENABLE}" in
                db_get live-debconfig/systemd/lxc-consoles
                _LXC_CONSOLES="${RET}" # string (w/o empty)
 
+               db_get live-debconfig/systemd/lxc-disable-services
+               _LXC_DISABLE_SERVICES="${RET}" # string (w/o empty)
+
                Defaults
                ;;
 
@@ -109,9 +119,11 @@ case "${_LXC_ENABLE}" in
                        fi
                done
 
-               # FIXME
-               systemctl disable systemd-journald.service
-               systemctl disable systemd-update-utmp-runlevel.service
+               # Remove uneeded services in a container
+               for _SERVICE in ${_LXC_DISABLE_SERVICES}
+               do
+                       systemctl disable ${_SERVICE}
+               done
                ;;
 
        false)
@@ -136,5 +148,11 @@ case "${_LXC_ENABLE}" in
                then
                        rm -f /etc/systemd/system/sigpwr.target
                fi
+
+               # Renable services
+               for _SERVICE in ${_LXC_DISABLE_SERVICES}
+               do
+                       systemctl enable ${_SERVICE}
+               done
                ;;
 esac
index 4656eb6..bd038e5 100644 (file)
@@ -17,3 +17,16 @@ Description: live-debconfig: How many consoles for LXC?
  How many concurrent consoles should the current container provide?
  .
  This defaults to 6 and will result in six getty processes per container.
+
+Template: live-debconfig/systemd/lxc-disable-services
+Type: string
+Default:
+Description: live-debconfig: Which services to disable for LXC?
+ Some services are not useful in containers and should be disabled.
+ .
+ This defaults to checkroot.service dev-hugepages.mount dev-mqueue.mount
+ proc-sys-fs-binfmt_misc.automount remount-rootfs.service run-lock.mount
+ run-user.mount swap.target sys-kernel-debug.mount sys-kernel-security.mount
+ systemd-modules-load.service systemd-remount-api-vfs.service
+ systemd-sysctl.service systemd-update-utmp-runlevel.service udev.service
+ udev-settle.service udev-trigger.service user.mount var-lock.mount.