summaryrefslogtreecommitdiffstats
path: root/source.local/n/NetworkManager/doinst.sh
diff options
context:
space:
mode:
Diffstat (limited to 'source.local/n/NetworkManager/doinst.sh')
-rw-r--r--source.local/n/NetworkManager/doinst.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/source.local/n/NetworkManager/doinst.sh b/source.local/n/NetworkManager/doinst.sh
new file mode 100644
index 0000000..6769a72
--- /dev/null
+++ b/source.local/n/NetworkManager/doinst.sh
@@ -0,0 +1,52 @@
+
+config() {
+ NEW="$1"
+ OLD="$(dirname $NEW)/$(basename $NEW .new)"
+ # If there's no config file by that name, mv it over:
+ if [ ! -r $OLD ]; then
+ mv $NEW $OLD
+ elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
+ # toss the redundant copy
+ rm $NEW
+ fi
+ # Otherwise, we leave the .new copy for the admin to consider...
+}
+
+preserve_perms() {
+ NEW="$1"
+ OLD="$(dirname ${NEW})/$(basename ${NEW} .new)"
+ if [ -e ${OLD} ]; then
+ cp -a ${OLD} ${NEW}.incoming
+ cat ${NEW} > ${NEW}.incoming
+ mv ${NEW}.incoming ${NEW}
+ fi
+ mv ${NEW} ${OLD}
+}
+
+if [ -e etc/HOSTNAME ]; then
+ sed -i "s,yourhostname,$(cat etc/HOSTNAME | cut -f1 -d .)," \
+ etc/NetworkManager/NetworkManager.conf.new
+fi
+
+# Preserve permissions, but move this into place. Otherwise the net
+# connection could be lost at a remote location.
+preserve_perms etc/rc.d/rc.networkmanager.new
+config etc/NetworkManager/NetworkManager.conf.new
+
+# Since the .pid file may have relocated, we need to check both places
+# and restart if NetworkManager is in use:
+if [ -x /etc/rc.d/rc.networkmanager ]; then
+ # Shut down any DHCP connections, otherwise the processes will be orphaned
+ # and the connections will not come up when NetworkManager restarts.
+ if ps ax | grep /sbin/dhcpcd | grep -q libexec/nm-dhcp ; then
+ ps ax | grep /sbin/dhcpcd | grep libexec/nm-dhcp | while read line ; do
+ kill -HUP $(echo $line | cut -b 1-5)
+ done
+ fi
+ killall NetworkManager 2> /dev/null
+ rm -f /var/run/NetworkManager/NetworkManager.pid
+ rm -f /var/run/NetworkManager.pid
+ sleep 5
+ sh /etc/rc.d/rc.networkmanager start
+fi
+