From: Michael H. Warfield Date: Tue, 12 Nov 2013 01:10:29 +0000 (-0500) Subject: Support files for systemd on Fedora. X-Git-Tag: lxc-1.0.0.beta1~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87ff951e680d7984cbfdc1c4ff378d47fe8a0f1d;p=thirdparty%2Flxc.git Support files for systemd on Fedora. 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 Signed-off-by: Serge Hallyn --- diff --git a/lxc.spec.in b/lxc.spec.in index a6c96a23d..3ef588118 100644 --- a/lxc.spec.in +++ b/lxc.spec.in @@ -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 index 000000000..3999ac89d --- /dev/null +++ b/src/lxc/lxc-devsetup @@ -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 index 000000000..aa20b91fb --- /dev/null +++ b/src/lxc/lxc.service @@ -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