Summary(pl.UTF-8): Narzędzia do kontenerów linuksowych (LXC)
Name: lxc
Version: 1.0.7
-Release: 1
+Release: 2
License: LGPL v2.1+
Group: Applications/System
Source0: https://www.linuxcontainers.org/downloads/%{name}-%{version}.tar.gz
# Source0-md5: b48f468a9bef0e4e140dd723f0a65ad0
Source1: %{name}-pld.in.sh
Source2: %{name}.init
+Source3: %{name}_macvlan.init
+Source4: %{name}_macvlan.sysconfig
Patch1: %{name}-pld.patch
URL: https://www.linuxcontainers.org/
BuildRequires: autoconf >= 2.50
%install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT{%{configpath},%{configpath}snap,/var/{cache,log}/lxc} \
- -d $RPM_BUILD_ROOT/etc/rc.d/init.d
-
+ -d $RPM_BUILD_ROOT/etc/{rc.d/init.d,sysconfig}
%{__make} install \
SYSTEMD_UNIT_DIR=%{systemdunitdir} \
%{__rm} $RPM_BUILD_ROOT%{_datadir}/%{name}/lxc-patch.py
install -p %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/lxc
+install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/lxc_macvlan
+install -p %{SOURCE4} $RPM_BUILD_ROOT/etc/sysconfig/lxc_macvlan
%if %{with python}
%py3_comp $RPM_BUILD_ROOT%{py3_sitedir}/lxc
rm -rf $RPM_BUILD_ROOT
%post -p /sbin/ldconfig
+/sbin/chkconfig --add lxc
+/sbin/chkconfig --add lxc_macvlan
+
+# %service lxc restart
+
+%preun
+if [ "$1" = "0" ]; then
+ %service lxc stop
+ /sbin/chkconfig --del lxc
+ %service lxc_macvlan stop
+ /sbin/chkconfig --del lxc_macvlan
+fi
+
%postun -p /sbin/ldconfig
+
%files
%defattr(644,root,root,755)
%doc AUTHORS CONTRIBUTING MAINTAINERS README doc/FAQ.txt doc/examples/*.conf
%attr(755,root,root) %{_libdir}/liblxc.so.*.*.*
%attr(755,root,root) %ghost %{_libdir}/liblxc.so.1
%attr(754,root,root) /etc/rc.d/init.d/lxc
+%attr(754,root,root) /etc/rc.d/init.d/lxc_macvlan
+
%{systemdunitdir}/lxc.service
%dir %{_libdir}/%{name}
%dir %{_libdir}/%{name}/rootfs
%attr(755,root,root) %{_libdir}/%{name}/lxc-user-nic
%attr(755,root,root) %{_libdir}/%{name}/lxc-autostart-helper
%dir %{_sysconfdir}/lxc
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/lxc_macvlan
%config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/lxc/default.conf
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/lxc.functions
--- /dev/null
+#!/bin/sh
+#
+# lxc_macvlan Start/Stop LXC MACVLAN interface
+#
+# chkconfig: 345 98 02
+# description: Starts/Stops LXC MACVLAN interface.
+#
+### BEGIN INIT INFO
+# Provides: lxc_macvlan
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Start/Stop LXC MACVLAN interface
+# Description: Start/Stop LXC MACVLAN interface
+### END INIT INFO
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Source any configurable options
+test ! -r /etc/sysconfig/lxc_macvlan ||
+ . /etc/sysconfig/lxc_macvlan
+
+# Tests for data provided in /etc/sysconfig/lxc_macvlan
+if [ -z "$MACVLAN_DEV" ]; then
+ echo "MACVLAN_DEV not set is /etc/sysconfig/lxc_macvlan"
+ exit 6
+fi
+
+if [ -z "$MACVLAN_NAME" ]; then
+ echo "MACVLAN_NAME not set is /etc/sysconfig/lxc_macvlan"
+ exit 6
+fi
+
+if [ -z "$MACVLAN_ADDRESS" ]; then
+ echo "MACVLAN_ADDRESS not set is /etc/sysconfig/lxc_macvlan"
+ exit 6
+fi
+
+# If not defined MACVLAN_HWADDRESS, calculate it from MACVLAN_ADDRESS
+if [ -z "$MACVLAN_HWADDRESS" ]; then
+ MACVLAN_HWADDRESS=`echo $MACVLAN_ADDRESS | awk -F "/" '{print $1}' | awk -F "." '{ printf "00:16:3e:%x:%x:%x\n", $2, $3, $4 }'`
+ echo "MACVLAN_HWADDRESS not set, using calculated from MACVLAN_ADDRESS=${MACVLAN_ADDRESS} value: ${MACVLAN_HWADDRESS}";
+fi
+
+
+start() {
+ msg_starting "LXC macvlan interface"
+ ip link add link $MACVLAN_DEV name $MACVLAN_NAME address $MACVLAN_HWADDRESS type macvlan mode bridge
+ ip link set $MACVLAN_NAME up
+ ip address add $MACVLAN_ADDRESS brd + dev $MACVLAN_NAME
+ # TODO: check if works:
+ # cat /sys/class/net/macv0/address
+ # 00:13:00:00:20:14
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && ok || fail
+}
+
+stop() {
+ msg_stopping "LXC macvlan interface"
+ ip link set $MACVLAN_NAME down
+ ip link del $MACVLAN_NAME
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && ok || fail
+}
+
+
+RETVAL=0
+
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+
+ stop)
+ stop
+ ;;
+ restart|reload|force-reload)
+ stop
+ start
+ ;;
+ status)
+ ;;
+ *)
+
+ msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
+ exit 3
+esac
+
+exit $RETVAL
--- /dev/null
+# LXC MACVLAN device config
+
+# Logical interface name
+MACVLAN_NAME=macv0
+
+# Physical device name where logcial interfaces will be created
+MACVLAN_DEV=eth0
+
+# Host address in MACVLAN network
+MACVLAN_ADDRESS=10.0.0.1/23
+
+# Optional MAC address, must be unique.
+# If not set, will be calculated to 00:16:3e:xx:xx:xx where last six octets will be last six octets from MACVLAN_ADDRESS
+# MACVLAN_HWADDRESS=00:16:3e:00:00:01