--- /dev/null
+#!/bin/sh
+#
+# Container hypervisor and a new user experience for LXC
+#
+# chkconfig: 345 20 80
+#
+# processname: lxd
+# pidfile: /var/run/lxd.pid
+#
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
+
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+ if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+ msg_network_down "lxd"
+ exit 1
+ fi
+else
+ exit 0
+fi
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/lxd ] && . /etc/sysconfig/lxd
+OPTIONS="$OPTIONS --group lxd --logfile /var/log/lxd/lxd.log"
+
+pidfile="/var/run/lxd.pid"
+
+start() {
+ if status --pidfile $pidfile lxd lxd >/dev/null; then
+ msg_already_running "lxd"
+ return
+ fi
+
+ msg_starting "lxd"
+ daemon --fork --waitforname lxd /usr/sbin/lxd daemon $OPTIONS
+
+ # lxd does not write pidfile, so create one
+ show "Checking lxd daemon status"
+ busy
+ pid=""
+ ntry=0
+ while [ -z "$pid" -a $ntry -lt 5 ]; do
+ [ -z "$pid" ] && sleep 1
+ pid=$(lxc info 2>/dev/null | grep serverpid: | awk '{print $2}')
+ echo $pid > $pidfile
+ ntry=$(expr $ntry+1)
+ done
+
+ if [ -n "$pid" ]; then
+ touch /var/lock/subsys/lxd
+ ok
+ RETVAL=0
+ else
+ fail
+ RETVAL=1
+ fi
+}
+
+stop() {
+ if [ ! -f /var/lock/subsys/lxd ]; then
+ msg_not_running "lxd"
+ return
+ fi
+
+ # Stop daemons.
+ msg_stopping "lxd"
+ /usr/sbin/lxd shutdown
+ busy
+ sleep 1
+ if status --pidfile $pidfile lxd lxd >/dev/null; then
+ killproc --pidfile $pidfile lxd
+ else
+ ok
+ fi
+ rm -f /var/lock/subsys/lxd
+}
+
+condrestart() {
+ if [ ! -f /var/lock/subsys/lxd ]; then
+ msg_not_running "lxd"
+ RETVAL=$1
+ return
+ fi
+
+ stop
+ start
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ try-restart)
+ condrestart 0
+ ;;
+ force-reload)
+ condrestart 7
+ ;;
+ status)
+ status --pidfile $pidfile lxd lxd
+ RETVAL=$?
+ ;;
+ *)
+ msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+ exit 3
+esac
+
+exit $RETVAL
Summary: Fast, dense and secure container management
Name: lxd
-Version: 2.0.3
+Version: 2.1
Release: 0.1
License: Apache v2.0
-Group: Applications/Networking
-URL: https://linuxcontainers.org/lxd/introduction/
+Group: Applications/System
+Source0: https://linuxcontainers.org/downloads/%{name}/%{name}-%{version}.tar.gz
+# Source0-md5: 7990440b022e93f3e7036bcfd12970f2
+Source1: %{name}.service
+Source2: %{name}.init
+Source3: %{name}.sysconfig
+URL: http://linuxcontainers.org
+BuildRequires: golang >= 1.6
+BuildRequires: rpmbuild(macros) >= 1.228
+Requires(post,preun): /sbin/chkconfig
+Requires(postun): /usr/sbin/groupdel
+Requires(pre): /usr/bin/getgid
+Requires(pre): /usr/sbin/groupadd
+Requires: rc-scripts >= 0.4.0.10
+Requires: squashfs
+Requires: uname(release) >= 4.1
+Provides: group(lxd)
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+# binary stripped or something
+%define _enable_debug_packages 0
+
%description
LXD is a container "hypervisor" and a new user experience for LXC.
-Specifically, it's made of three components:
+Specifically, it is made of three components:
- A system-wide daemon (lxd)
- A command line client (lxc)
- An OpenStack Nova plugin (nova-compute-lxd)
powerful tool to manage all your containers. It can handle connect to
multiple container hosts and easily give you an overview of all the
containers on your network, let you create some more where you want
-them and even move them around while they're running.
+them and even move them around while they are running.
The OpenStack plugin then allows you to use your lxd hosts as compute
nodes, running workloads on containers rather than virtual machines.
%setup -q
%build
+export GOPATH=$(pwd)/dist
+cd $GOPATH/src/github.com/lxc/lxd/
+go install -v ./lxd
+go install -v ./lxc
%install
rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT{%{_bindir},%{_sbindir},%{_mandir}/man1,/etc/{rc.d/init.d,sysconfig},%{systemdunitdir}} \
+ $RPM_BUILD_ROOT/var/lib/%{name} \
+ $RPM_BUILD_ROOT/var/log/%{name}
+
+install -p dist/bin/lxd $RPM_BUILD_ROOT%{_sbindir}/
+install -p dist/bin/lxc $RPM_BUILD_ROOT%{_bindir}/
+
+cp -p %{SOURCE1} $RPM_BUILD_ROOT%{systemdunitdir}
+install -p %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
+cp -p %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
+
+%pre
+%groupadd -g 297 %{name}
+
+%post
+/sbin/chkconfig --add %{name}
+%service -n %{name} restart
+%systemd_post %{name}.service
+
+%preun
+if [ "$1" = "0" ]; then
+ %service -q %{name} stop
+ /sbin/chkconfig --del %{name}
+fi
+%systemd_preun %{name}.service
+
+%postun
+if [ "$1" = "0" ]; then
+ %groupremove %{name}
+fi
+%systemd_reload
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
+%doc README.md CONTRIBUTING.md AUTHORS
+%config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
+%attr(754,root,root) /etc/rc.d/init.d/%{name}
+%attr(755,root,root) %{_bindir}/lxc
+%attr(755,root,root) %{_sbindir}/%{name}
+%{systemdunitdir}/%{name}.service
+%dir %attr(700,root,root) /var/lib/%{name}
+%dir %attr(750,root,logs) /var/log/%{name}