AM_CONDITIONAL([HAVE_DEBIAN], [test x"$with_distro" = "xdebian" -o x"$with_distro" = "xubuntu"])
AM_CONDITIONAL([DISTRO_UBUNTU], [test "x$with_distro" = "xubuntu"])
+# Check for init system type
+AC_MSG_CHECKING([for init system type])
+AC_ARG_WITH([init-script],
+ [AC_HELP_STRING([--with-init-script@<:@=TYPE@:>@],
+ [Type of init script to install: sysv, systemd, upstart,
+ distro, none @<:@default=distro@:>@])],[],[with_init_script=distro])
+case "$with_init_script" in
+ sysv)
+ init_script=sysv
+ ;;
+ systemd)
+ init_script=systemd
+ ;;
+ upstart)
+ init_script=upstart
+ ;;
+ none)
+ ;;
+ distro)
+ case $with_distro in
+ fedora)
+ init_script=systemd
+ ;;
+ redhat|centos|oracle|oracleserver)
+ init_script=sysv
+ ;;
+ ubuntu)
+ init_script=upstart
+ ;;
+ *)
+ echo -n "Linux distribution init system unknown, defaulting to sysv"
+ init_script=sysv
+ ;;
+ esac
+ ;;
+ *)
+ AC_MSG_ERROR([Unknown init system type $with_init_script])
+ ;;
+esac
+AM_CONDITIONAL([INIT_SCRIPT_SYSV], test "$init_script" = "sysv")
+AM_CONDITIONAL([INIT_SCRIPT_SYSTEMD], test "$init_script" = "systemd")
+AM_CONDITIONAL([INIT_SCRIPT_UPSTART], test "$init_script" = "upstart")
+AC_MSG_RESULT($init_script)
+
# Allow disabling rpath
AC_ARG_ENABLE([rpath],
[AC_HELP_STRING([--enable-rpath], [set rpath in executables [default=no]])],
Environment:
- compiler: $CC
- distribution: $with_distro
+ - init script type: $init_script
- rpath: $enable_rpath
- GnuTLS: $enable_gnutls
%global with_python %{?_with_python: 1} %{?!_with_python: 0}
%global with_lua %{?_with_lua: 1} %{?!_with_lua: 0}
+# Set with_systemd on distros that use it, so we can install the service
+# file, otherwise the sysvinit script will be installed
+%if 0%{?fedora} >= 14 || 0%{?rhel} >= 7 || 0%{?suse_version} >= 1210
+%global with_systemd 1
+%define init_script systemd
+BuildRequires: systemd-units
+%else
+%global with_systemd 0
+%define init_script sysv
+%endif
+
# RPM needs alpha/beta/rc in Release: not Version: to ensure smooth
# package upgrades from alpha->beta->rc->release. For more info see:
# http://fedoraproject.org/wiki/Packaging%3aNamingGuidelines#NonNumericRelease
%if %{with_python}
--enable-python \
%endif
- --disable-rpath
+ --disable-rpath \
+ --with-init-script=%{init_script}
make %{?_smp_mflags}
%install
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}
%{_datadir}/lxc/*
%config(noreplace) %{_sysconfdir}/lxc/*
-/lib/systemd/system/*
+%if %{with_systemd}
+%{_unitdir}/lxc.service
+%else
+%{_sysconfdir}/rc.d/init.d/lxc
+%endif
%files libs
%defattr(-,root,root)
%endif
%{_localstatedir}/*
%attr(4555,root,root) %{_libexecdir}/%{name}/lxc-init
+%if %{with_systemd}
%attr(555,root,root) %{_libexecdir}/%{name}/lxc-devsetup
+%endif
%if %{with_python}
%{_libdir}/python3.3/site-packages/_lxc*
lxc-devsetup \
lxc-ls \
lxc-top \
- lxc.service
+ lxc.service \
+ lxc.sysvinit
if ENABLE_PYTHON
bin_SCRIPTS += lxc-device
pkglibexec_PROGRAMS = \
lxc-init
+if INIT_SCRIPT_SYSV
+install-init: lxc.sysvinit
+ $(MKDIR_P) $(DESTDIR)$(sysconfdir)/rc.d/init.d
+ $(INSTALL_SCRIPT) lxc.sysvinit $(DESTDIR)$(sysconfdir)/rc.d/init.d/lxc
+
+uninstall-init:
+ rm -f $(DESTDIR)$(sysconfdir)/rc.d/init.d/lxc
+ rmdir $(DESTDIR)$(sysconfdir)/rc.d/init.d || :
+else
+install-init:
+uninstall-init:
+endif
+
+if INIT_SCRIPT_SYSTEMD
+SYSTEMD_UNIT_DIR = /usr/lib/systemd/system
+install-systemd: lxc.service lxc-devsetup
+ $(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR)
+ $(INSTALL_DATA) lxc.service $(DESTDIR)$(SYSTEMD_UNIT_DIR)/
+
+uninstall-systemd:
+ rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/lxc.service
+ rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) || :
+pkglibexec_SCRIPTS = lxc-devsetup
+else
+install-systemd:
+uninstall-systemd:
+endif
+
+if INIT_SCRIPT_UPSTART
+# FIXME: install/uninstall upstart script here
+install-upstart:
+uninstall-upstart:
+else
+install-upstart:
+uninstall-upstart:
+endif
+
AM_LDFLAGS = -Wl,-E
if ENABLE_RPATH
AM_LDFLAGS += -Wl,-rpath -Wl,$(libdir)
lxc_usernsexec_SOURCES = lxc_usernsexec.c
lxc_user_nic_SOURCES = lxc_user_nic.c network.c network.h
+install-data-local: install-init install-systemd install-upstart
+
+uninstall-local: uninstall-init uninstall-systemd uninstall-upstart
+
install-exec-local: install-soPROGRAMS
mkdir -p $(DESTDIR)$(datadir)/lxc
install -c -m 644 lxc.functions $(DESTDIR)$(datadir)/lxc
--- /dev/null
+#!/bin/sh
+#
+# lxc Start/Stop LXC autoboot containers
+#
+# chkconfig: 345 99 01
+# description: Starts/Stops all LXC containers configured for autostart.
+#
+### BEGIN INIT INFO
+# Provides: lxc
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bring up/down LXC autostart containers
+# Description: Bring up/down LXC autostart containers
+### END INIT INFO
+
+# Source function library.
+. /etc/init.d/functions
+
+# Check for needed utility program
+[ -x /usr/bin/lxc-autostart ] || exit 1
+
+# If libvirtd is providing the bridge, it might not be
+# immediately available, so wait a bit for it before starting
+# up the containers or else any that use the bridge will fail
+# to start
+wait_for_bridge()
+{
+ [ -f /etc/lxc/default.conf ] || { return 0; }
+
+ BRNAME=`grep lxc.network.link /etc/lxc/default.conf |awk '{print $3}'`
+ [ -n $BRNAME ] || { return 0; }
+
+ for try in `seq 1 30`; do
+ ifconfig -a |grep "^$BRNAME" >/dev/null 2>&1
+ if [ $? = 0 ]; then
+ return
+ fi
+ sleep 1
+ done
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ [ ! -f /var/lock/subsys/lxc ] || { exit 0; }
+
+ # Start containers
+ wait_for_bridge
+ action $"Starting LXC containers: " /usr/bin/lxc-autostart
+ touch /var/lock/subsys/lxc
+ ;;
+ stop)
+ action $"Stopping LXC containers: " /usr/bin/lxc-autostart -s
+ rm -f /var/lock/subsys/lxc
+ ;;
+ restart|reload|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
return 1
fi
return 0
- ) 200> @LOCALSTATEDIR@/lock/subsys/lxc
+ ) 200> @LOCALSTATEDIR@/lock/subsys/lxc-plamo
}
configure_plamo() {
rm -rf --one-file-system $dlcache $rtcache || return 1
echo "Done."
return 0
- ) 200> @LOCALSTATEDIR@/lock/subsys/lxc
+ ) 200> @LOCALSTATEDIR@/lock/subsys/lxc-plamo
}
usage() {