[debian-edu-commits] r80048 - in branches/wheezy/debian-edu-config: debian etc/dhcp/dhclient-exit-hooks.d

pere at alioth.debian.org pere at alioth.debian.org
Fri May 10 20:55:45 UTC 2013


Author: pere
Date: 2013-05-10 20:55:44 +0000 (Fri, 10 May 2013)
New Revision: 80048

Modified:
   branches/wheezy/debian-edu-config/debian/changelog
   branches/wheezy/debian-edu-config/etc/dhcp/dhclient-exit-hooks.d/hostname
Log:
Rewrite dhclient-exit-hooks.d/hostname to only trigger on profiles
Workstation, Thin-Client-Server and Minimal, and to only print
messages and syslog when the host name is changed.

Modified: branches/wheezy/debian-edu-config/debian/changelog
===================================================================
--- branches/wheezy/debian-edu-config/debian/changelog	2013-05-10 18:16:14 UTC (rev 80047)
+++ branches/wheezy/debian-edu-config/debian/changelog	2013-05-10 20:55:44 UTC (rev 80048)
@@ -27,8 +27,9 @@
     set the client's hostname.
 
   [ Petter Reinholdtsen ]
-  * Adjust dhclient-exit-hooks.d/hostname script to syslog when the
-    hostname is updated.
+  * Rewrite dhclient-exit-hooks.d/hostname to only trigger on profiles
+    Workstation, Thin-Client-Server and Minimal, and to only print
+    messages and syslog when the host name is changed.
 
  -- Petter Reinholdtsen <pere at debian.org>  Wed, 08 May 2013 11:17:25 +0200
 

Modified: branches/wheezy/debian-edu-config/etc/dhcp/dhclient-exit-hooks.d/hostname
===================================================================
--- branches/wheezy/debian-edu-config/etc/dhcp/dhclient-exit-hooks.d/hostname	2013-05-10 18:16:14 UTC (rev 80047)
+++ branches/wheezy/debian-edu-config/etc/dhcp/dhclient-exit-hooks.d/hostname	2013-05-10 20:55:44 UTC (rev 80048)
@@ -1,20 +1,35 @@
-OD#!/bin/sh
+#!/bin/sh
 #
 # Purpose: Used by dhclient-script to set the hostname of the system
 # to match the DNS information for the host as provided by DHCP.
 #
-# This script was found on the web:
+# This script is based on code found on the web:
 # http://www.debian-administration.org/articles/447 and
 # http://nxhelp.com/blog/2013/01/24/automatically-set-hostname-from-dhcp/
 #
-if [ "$reason" != BOUND ] && [ "$reason" != RENEW ] \
- && [ "$reason" != REBIND ] && [ "$reason" != REBOOT ]
-then
-  return
+
+# Should not update hostname on Main-Server, Roaming-Workstation and Standalone
+if [ -r /etc/debian-edu/config ] ; then
+	. /etc/debian-edu/config
+	case "$PROFILE" in
+	Workstation|Thin-Client-Server|Minimal)
+		;;
+	*)
+		exit 0
+		;;
+	esac
+else
+	exit 0
 fi
-echo dhclient-exit-hooks.d/hostname: Dynamic IP address = $new_ip_address
-hostname=$(host $new_ip_address | cut -d ' ' -f 5 | cut -d '.' -f 1)
-echo $hostname > /etc/hostname
-hostname $hostname
-echo dhclient-exit-hooks.d/hostname: Dynamic Hostname = $hostname
-logger -t dhclient-exit-hooks.d/hostname "changing hostname to $hostname based on DHCP IP address $new_ip_address"
+case "$reason" in
+	BOUND|RENEW|REBIND|REBOOT)
+	hostname=$(host $new_ip_address | cut -d ' ' -f 5 | cut -d '.' -f 1)
+	if [ "$hostname" != "$(uname -n)" ] ; then
+		echo dhclient-exit-hooks.d/hostname: Dynamic IP address = $new_ip_address
+		echo $hostname > /etc/hostname
+		hostname $hostname
+		echo dhclient-exit-hooks.d/hostname: Dynamic Hostname = $hostname
+		logger -t dhclient-exit-hooks.d/hostname "changing hostname to $hostname based on DHCP IP address $new_ip_address"
+	fi
+	;;
+esac




More information about the debian-edu-commits mailing list