]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Support files for systemd on Fedora.
authorMichael H. Warfield <mhw@WittsEnd.com>
Tue, 12 Nov 2013 01:10:29 +0000 (20:10 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 21 Nov 2013 17:25:35 +0000 (11:25 -0600)
Added a file "lxc.service" for a systemd service file.

Added a file "lxc-devsetup" to setup /dev/ on startup to support autodev
in containers.

Service file references lxc-devsetup as an ExecStartPre command.  The
lxc-devsetup script is not dependent on systemd or Fedora and can
be used at bootup on any system.

Modified lxc.spec.in to install the two new files on Fedora.  The systemd
specific code in the lxc.spec file may need some review and conditionalize
for systemd on non-systemd rpm-based systems.

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
lxc.spec.in
src/lxc/lxc-devsetup [new file with mode: 0755]
src/lxc/lxc.service [new file with mode: 0644]

index a6c96a23df40f239f904f43758aee58da3fc8f74..3ef588118b9e679b3d19fecae21fbd6dc89a7b9f 100644 (file)
@@ -102,6 +102,11 @@ rm -rf %{buildroot}
 make install DESTDIR=%{buildroot}
 find %{buildroot} -type f -name '*.la' -exec rm -f {} ';'
 
+# Install some of our systemd stuff...
+install -d -m 755 %{buildroot}/lib/systemd/system
+install -c -m 644 src/lxc/lxc.service %{buildroot}/lib/systemd/system
+install -c -m 755 src/lxc/lxc-devsetup %{buildroot}/%{_libexecdir}/%{name}
+
 %clean
 rm -rf %{buildroot}
 
@@ -131,6 +136,8 @@ rm -rf %{buildroot}
 %{_datadir}/lxc/*
 %config(noreplace) %{_sysconfdir}/lxc/*
 
+/lib/systemd/system/*
+
 %files libs
 %defattr(-,root,root)
 %{_libdir}/*.so.*
@@ -140,6 +147,7 @@ rm -rf %{buildroot}
 %endif
 %{_localstatedir}/*
 %attr(4555,root,root) %{_libexecdir}/%{name}/lxc-init
+%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
 
 %if %{with_lua}
 %files lua
diff --git a/src/lxc/lxc-devsetup b/src/lxc/lxc-devsetup
new file mode 100755 (executable)
index 0000000..3999ac8
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh -
+
+# lxc.devsetup - Setup host /dev for container /dev subdirectories.
+
+if [[ ! -d /dev/.lxc ]]
+then
+    echo "Creating /dev/.lxc"
+    mkdir /dev/.lxc
+    chmod 755 /dev/.lxc
+fi
+
+if grep -q "/dev devtmpfs " /proc/self/mounts
+then
+    echo "/dev is devtmpfs"
+else
+    echo "/dev is not devtmpfs - mounting tmpfs on .lxc"
+    mount -t tmpfs tmpfs /dev/.lxc
+fi
+
+if [[ ! -d /dev/.lxc/user ]]
+then
+    echo "Creating /dev/.lxc/user"
+    mkdir /dev/.lxc/user
+    chmod 1777 /dev/.lxc/user
+fi
diff --git a/src/lxc/lxc.service b/src/lxc/lxc.service
new file mode 100644 (file)
index 0000000..aa20b91
--- /dev/null
@@ -0,0 +1,17 @@
+[Unit]
+Description=LXC Container Initialization and Autoboot Code
+After=syslog.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStartPre=/usr/libexec/lxc/lxc-devsetup
+ExecStart=/usr/libexec/lxc/lxc-startup start
+ExecStop=/usr/libexec/lxc/lxc-startup stop
+# Environment=BOOTUP=serial
+# Environment=CONSOLETYPE=serial
+StandardOutput=syslog
+StandardError=syslog
+
+[Install]
+WantedBy=multi-user.target