From 277be5ed064caaa86b9582d27bbb0472779edf3a Mon Sep 17 00:00:00 2001 From: "David Kaspar [Dee'Kej]" Date: Wed, 30 May 2018 14:17:42 +0200 Subject: network-scripts: ifup & ifdown -- use alternatives system This installs the real scripts into /etc/sysconfig/network-scripts while leaving the management of the launchers in /usr/sbin to the alternatives system. This allows coexistence with alternative implementations of ifup and ifdown, notably NetworkManager. A priority of 90 is chosen rather arbitrarily, NetworkManager will use a lower one (50) so that our implementation takes precedence over NetworkManaager in case both are installed. In an unlikely event the user will want to switch to NetworkManager implementations when both are installed they can override the default with: $ update-alternatives --config ifup --- Makefile | 4 ---- initscripts.spec | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index cec6c103..c5b6d3a4 100644 --- a/Makefile +++ b/Makefile @@ -74,10 +74,6 @@ install-network-scripts: install-usr install-etc install -m 0755 -d $(DESTDIR)$(sysconfdir)/sysconfig/network-scripts cp -a network-scripts/* $(DESTDIR)$(sysconfdir)/sysconfig/network-scripts/ (cd $(DESTDIR)$(sysconfdir)/sysconfig/network-scripts; \ - mv ifup $(DESTDIR)$(sbindir)/; \ - mv ifdown $(DESTDIR)$(sbindir)/; \ - ln -sf $(sbindir)/ifup . ; \ - ln -sf $(sbindir)/ifdown . ; \ ln -sf ifup-ippp ifup-isdn ; \ ln -sf ifdown-ippp ifdown-isdn ; \ ) diff --git a/initscripts.spec b/initscripts.spec index 4113b649..fda9d6c8 100644 --- a/initscripts.spec +++ b/initscripts.spec @@ -41,7 +41,10 @@ Requires: util-linux >= 2.16 Requires(pre): shadow-utils Requires(post): chkconfig Requires(post): coreutils +Requires(post): %{_sbindir}/update-alternatives + Requires(preun): chkconfig +Requires(postun): %{_sbindir}/update-alternatives BuildRequires: filesystem >= 3 BuildRequires: gcc @@ -121,6 +124,10 @@ network interfaces, some utilities, and other legacy files. ln -s %{_mandir}/man8/ifup.8 %{buildroot}%{_mandir}/man8/ifdown.8 +# We are now using alternatives approach to better co-exist with NetworkManager: +touch %{buildroot}%{_sbindir}/ifup +touch %{buildroot}%{_sbindir}/ifdown + # --------------- %post @@ -129,6 +136,12 @@ ln -s %{_mandir}/man8/ifup.8 %{buildroot}%{_mandir}/man8/ifdown.8 chkconfig --add network > /dev/null 2>&1 || : chkconfig --add netconsole > /dev/null 2>&1 || : +[ -L %{_sbindir}/ifup ] || rm -f %{_sbindir}/ifup +[ -L %{_sbindir}/ifdown ] || rm -f %{_sbindir}/ifdown + +%{_sbindir}/update-alternatives --install %{_sbindir}/ifup ifup %{_sysconfdir}/sysconfig/network-scripts/ifup 90 \ + --slave %{_sbindir}/ifdown ifdown %{_sysconfdir}/sysconfig/network-scripts/ifdown + # --------------- %preun @@ -137,6 +150,7 @@ chkconfig --add netconsole > /dev/null 2>&1 || : if [ $1 -eq 0 ]; then chkconfig --del network > /dev/null 2>&1 || : chkconfig --del netconsole > /dev/null 2>&1 || : + %{_sbindir}/update-alternatives --remove ifup %{_sysconfdir}/sysconfig/network-scripts/ifup fi # --------------- @@ -193,14 +207,15 @@ fi # --------------- %{_bindir}/* -%{_sbindir}/ifup -%{_sbindir}/ifdown %{_sbindir}/consoletype %{_sbindir}/genhostid %{_sbindir}/service %{_sbindir}/sushell %{_sbindir}/sys-unconfig +%ghost %{_sbindir}/ifup +%ghost %{_sbindir}/ifdown + %attr(2755,root,root) %{_sbindir}/netreport %attr(4755,root,root) %{_sbindir}/usernetctl -- cgit v1.2.1