]> git.pld-linux.org Git - packages/ucarp.git/commitdiff
rel 4; systemd support auto/th/ucarp-1.5.2-4
authorMariusz Mazur <mmazur@axeos.com>
Mon, 2 Feb 2015 23:10:57 +0000 (23:10 +0000)
committerMariusz Mazur <mmazur@axeos.com>
Mon, 2 Feb 2015 23:10:57 +0000 (23:10 +0000)
ucarp-service-generator [new file with mode: 0644]
ucarp.spec
ucarp.target [new file with mode: 0644]
ucarp@.service [new file with mode: 0644]

diff --git a/ucarp-service-generator b/ucarp-service-generator
new file mode 100644 (file)
index 0000000..a2d03f0
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+destunitdir=${1:-/tmp}
+
+# Do nothing if target is disabled
+[ -e /etc/systemd/system/multi-user.target.wants/ucarp.target ] || exit 0
+
+[ -f /etc/sysconfig/ucarp ] && . /etc/sysconfig/ucarp
+
+if [ -d $destunitdir/ucarp.target.wants ]; then
+       rm -f $destunitdir/ucarp.target.wants/ucarp@*.service
+else
+       mkdir -p $destunitdir/ucarp.target.wants
+fi
+
+for ip in $VIRTUAL_IPS; do
+       [ -L $destunitdir/ucarp.target.wants/ucarp@$ip.service ] && \
+               continue
+       ln -s /lib/systemd/system/ucarp@.service \
+               $destunitdir/ucarp.target.wants/ucarp@$ip.service
+done
index 86bae9319275a3e52440c0aa4ca8ba38f496511e..121c77245011eef285cb9a374d25d0f5d43bb6d6 100644 (file)
@@ -2,7 +2,7 @@ Summary:        Common Address Redundancy Protocol (CARP) for Unix
 Summary(pl.UTF-8):     CARP (Common Address Redundancy Protocol) dla Uniksa
 Name:          ucarp
 Version:       1.5.2
-Release:       3
+Release:       4
 License:       BSD
 Group:         Applications/Networking
 Source0:       ftp://ftp.ucarp.org/pub/ucarp/%{name}-%{version}.tar.gz
@@ -11,12 +11,20 @@ Source1:    %{name}.init
 Source2:       %{name}.sysconfig
 Source3:       %{name}.config.template
 Source4:       %{name}.tmpfiles
+Source5:    ucarp-service-generator
+Source6:    ucarp.target
+Source7:    ucarp@.service
 URL:           http://www.ucarp.org/
 BuildRequires: autoconf
 BuildRequires: automake
 BuildRequires: gettext-tools
 BuildRequires: libpcap-devel
 BuildRequires: libtool
+BuildRequires:  rpmbuild(macros) >= 1.671
+BuildRequires:  systemd-devel
+Requires(post,preun):   /sbin/chkconfig
+Requires(post,preun,postun):    systemd-units >= 38
+Requires:   systemd-units >= 38
 BuildRoot:     %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %description
@@ -60,7 +68,9 @@ rm -rf $RPM_BUILD_ROOT
 install -d $RPM_BUILD_ROOT%{_sysconfdir}/%{name} \
        $RPM_BUILD_ROOT/etc/{rc.d/init.d,sysconfig} \
        $RPM_BUILD_ROOT%{_varrun}/%{name} \
-       $RPM_BUILD_ROOT/usr/lib/tmpfiles.d
+       $RPM_BUILD_ROOT/usr/lib/tmpfiles.d \
+    $RPM_BUILD_ROOT{%{systemdtmpfilesdir},%{systemdunitdir}} \
+    $RPM_BUILD_ROOT/lib/systemd/system-generators
 
 %{__make} install \
        DESTDIR=$RPM_BUILD_ROOT
@@ -73,23 +83,37 @@ install -p examples/linux/vip-up.sh $RPM_BUILD_ROOT%{_sysconfdir}/%{name}
 
 install %{SOURCE4} $RPM_BUILD_ROOT/usr/lib/tmpfiles.d/%{name}.conf
 
+install -p %{SOURCE5} $RPM_BUILD_ROOT/lib/systemd/system-generators/ucarp-service-generator
+install -p %{SOURCE6} $RPM_BUILD_ROOT%{systemdunitdir}/ucarp.target
+install -p %{SOURCE7} $RPM_BUILD_ROOT%{systemdunitdir}/ucarp@.service
+ln -s /dev/null $RPM_BUILD_ROOT%{systemdunitdir}/ucarp.service
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 %post
 /sbin/chkconfig --add ucarp
 %service ucarp restart "UCARP"
+%systemd_post ucarp.target
 
 %preun
 if [ "$1" = "0" ]; then
        %service ucarp stop
        /sbin/chkconfig --del ucarp
 fi
+%systemd_preun ucarp.target
+
+%postun
+%systemd_reload
 
 %files
 %defattr(644,root,root,755)
 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
 %attr(754,root,root) /etc/rc.d/init.d/%{name}
+%attr(755,root,root) /lib/systemd/system-generators/%{name}-service-generator
+%{systemdunitdir}/%{name}.service
+%{systemdunitdir}/%{name}.target
+%{systemdunitdir}/%{name}@.service
 %attr(755,root,root) %{_sbindir}/*
 %dir %{_sysconfdir}/%{name}
 %{_sysconfdir}/%{name}/config.template
diff --git a/ucarp.target b/ucarp.target
new file mode 100644 (file)
index 0000000..5ff6b84
--- /dev/null
@@ -0,0 +1,7 @@
+[Unit]
+Description=Start ucarp sessions
+After=network.target
+Wants=network.target
+
+[Install]
+WantedBy=multi-user.target
diff --git a/ucarp@.service b/ucarp@.service
new file mode 100644 (file)
index 0000000..ba1a16b
--- /dev/null
@@ -0,0 +1,12 @@
+[Unit]
+Description=CARP ip %I
+Requires=ucarp.target
+After=ucarp.target
+
+[Service]
+Type=simple
+EnvironmentFile=/etc/ucarp/%i.conf
+ExecStart=/usr/sbin/ucarp --addr %i $UCARP_OPTS
+
+[Install]
+WantedBy=ucarp.target
This page took 0.070323 seconds and 4 git commands to generate.