Commits

Bryan O'Sullivan committed 2d165ff

Fix RPM generation and sysconfig file twiddling.

  • Participants
  • Parent commits 1014cdb

Comments (0)

Files changed (1)

File netplug.spec

+%define version 1.0
+%define release 1
+%define sysconfig /etc/sysconfig/network-scripts
+
 Summary: Daemon that responds to network cables being plugged in and out
 Name: netplug
-Version: 1.0
-Release: 1
+Version: %{version}
+Release: %{release}
 License: GPL
 Group: System Environment/Base
 URL: http://www.serpentine.com/~bos/netplug
 %post
 /sbin/chkconfig --add netplugd
 
-%postun
+for cfg in %{sysconfig}/ifcfg-eth*; do
+    if echo "$cfg" | grep -q pre-netplug; then
+	continue
+    fi
+    if [ -f "$cfg.pre-netplug" ]; then
+	continue
+    fi
+    sed -e 's/^ONBOOT=yes/ONBOOT=no/' "$cfg" > "$cfg.new.$$"
+    if cmp -s "$cfg" "$cfg.new.$$"; then
+	true
+    else
+	cp "$cfg" "$cfg.pre-netplug"
+	cp "$cfg.new.$$" "$cfg"
+	ifname=`echo "$cfg" | sed 's!^.*/ifcfg-\(.*\)$!\1!'`
+	echo "Updated $ifname to be managed by netplug"
+    fi
+    rm "$cfg.new.$$"
+done
+
+%preun
 /sbin/chkconfig --del netplugd
 
+%postun
+for precfg in %{sysconfig}/*.pre-netplug; do
+    if [ ! -f "$precfg" ]; then
+	continue
+    fi
+    cfg=`echo "$precfg" | sed -e 's!\.pre-netplug$!!'`
+    sed -e 's/^ONBOOT=no/ONBOOT=yes/' "$cfg" > "$cfg.new.$$"
+    if cmp -s "$cfg" "$cfg.new.$$"; then
+	true
+    else
+	cp "$cfg.new.$$" "$cfg"
+        ifname=`echo "$cfg" | sed -e 's!^.*/ifcfg-\(.*\)$!\1!'`
+	echo "Restored $ifname to be brought up at boot time"
+    fi
+    rm "$cfg.new.$$" "$cfg.pre-netplug"
+done
 
 %changelog
 * Tue Aug 26 2003 Bryan O'Sullivan <bos@serpentine.com> -