From f3ed9feaf70002cb14943e174fde7b5e48dd2a799010c430f284fd43f427f559 Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dmueller@suse.com>
Date: Tue, 29 Mar 2016 19:53:05 +0000
Subject: [PATCH] Accepting request 378276 from home:markoschandras:network

- Prevent systemd from autogenerating a service file for
  openvswitch-switch which conflicts with the opevswitch
  one. (bsc#966762)

OBS-URL: https://build.opensuse.org/request/show/378276
OBS-URL: https://build.opensuse.org/package/show/network/openvswitch?expand=0&rev=82
---
 openvswitch.changes |  7 +++++++
 openvswitch.service |  4 ++--
 openvswitch.spec    | 15 +++++++++++----
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/openvswitch.changes b/openvswitch.changes
index d3fcd0c..4bc62d9 100644
--- a/openvswitch.changes
+++ b/openvswitch.changes
@@ -1,3 +1,10 @@
+-------------------------------------------------------------------
+Tue Mar 22 18:06:40 UTC 2016 - mchandras@suse.de
+
+- Prevent systemd from autogenerating a service file for
+  openvswitch-switch which conflicts with the opevswitch
+  one. (bsc#966762)
+
 -------------------------------------------------------------------
 Fri Mar 18 10:20:02 UTC 2016 - kmroz@suse.com
 
diff --git a/openvswitch.service b/openvswitch.service
index ab2412d..c351d00 100644
--- a/openvswitch.service
+++ b/openvswitch.service
@@ -5,8 +5,8 @@ Before=network.service
 
 [Service]
 Type=oneshot
-ExecStart=/etc/init.d/openvswitch-switch start
-ExecStop=/etc/init.d/openvswitch-switch stop
+ExecStart=/usr/share/openvswitch/scripts/openvswitch-switch start
+ExecStop=/usr/share/openvswitch/scripts/openvswitch-switch stop
 RemainAfterExit=yes
 
 [Install]
diff --git a/openvswitch.spec b/openvswitch.spec
index 84b7c86..f8c6f5f 100644
--- a/openvswitch.spec
+++ b/openvswitch.spec
@@ -355,6 +355,7 @@ done
 pushd source
 
 %makeinstall
+install -d -m 755 %{buildroot}/%{_datadir}/%{name}/scripts
 install -d -m 755 %{buildroot}/%{_sysconfdir}/init.d
 install -d -m 755 %{buildroot}%{_localstatedir}/adm/fillup-templates
 
@@ -366,9 +367,13 @@ install -m 755 %{SOURCE8} \
          %{buildroot}/%{_sysconfdir}/init.d/%{name}-testcontroller
 
 %if 0%{?suse_version} > 1230
-ln -sf %_sbindir/service %{buildroot}%{_sbindir}/rc%{name}-switch
+ln -sf %_sbindir/service %{buildroot}%{_sbindir}/rc%{name}
 ln -sf %_sbindir/service %{buildroot}%{_sbindir}/rc%{name}-vtep
 ln -sf %_sbindir/service %{buildroot}%{_sbindir}/rc%{name}-testcontroller
+# Move the openvswitch-switch rc file to the scripts directory
+# to prevent systemd from autogenerating a unit file for us (bsc#966762)
+mv %{buildroot}/%{_sysconfdir}/init.d/%{name}-switch \
+   %{buildroot}/%{_datadir}/%{name}/scripts/%{name}-switch
 install -D -m 644 %{SOURCE7} \
         %{buildroot}%{_unitdir}/openvswitch.service
 install -D -m 644 %{SOURCE12} \
@@ -391,7 +396,6 @@ install -m 644 %{SOURCE4} \
          %{buildroot}/%{_sysconfdir}/logrotate.d/%{name}-switch
 install -d -m 755 %{buildroot}/%{_sysconfdir}/profile.d
 
-install -d -m 755 %{buildroot}/%{_datadir}/%{name}/scripts
 install -m 644 vswitchd/vswitch.ovsschema \
          %{buildroot}/%{_datadir}/%{name}/vswitch.ovsschema
 
@@ -577,8 +581,6 @@ rmdir %{buildroot}%{_datadir}/%{name}/python
 %{_datadir}/openvswitch/scripts/ovs-save
 %{_datadir}/openvswitch/vswitch.ovsschema
 %{_sysconfdir}/bash_completion.d/ovs-vsctl-bashcomp.bash
-%{_sysconfdir}/init.d/openvswitch-switch
-%{_sbindir}/rc%{name}-switch
 %config(noreplace) %{_sysconfdir}/logrotate.d/openvswitch-switch
 %{_mandir}/man8/ovs-dpctl.8.gz
 %{_mandir}/man1/ovs-tcpundump.1.gz
@@ -590,7 +592,12 @@ rmdir %{buildroot}%{_datadir}/%{name}/python
 %{_mandir}/man5/ovs-vswitchd.conf.db.5.gz
 %{_mandir}/man8/ovs-ctl.8.gz
 %if 0%{?suse_version} > 1230
+%{_sbindir}/rc%{name}
 %{_unitdir}/openvswitch.service
+%{_datadir}/openvswitch/scripts/openvswitch-switch
+%else
+%{_sbindir}/rc%{name}-switch
+%{_sysconfdir}/init.d/openvswitch-switch
 %endif
 %dir /var/log/openvswitch