[debian-edu-commits] debian-edu/ 01/01: WoL for Debian Edu clients: Make shutdown and wake-up procedure of Debian Edu clients configurable separately. (Closes: #801741).

Mike Gabriel sunweaver at debian.org
Wed Oct 14 07:31:54 UTC 2015


This is an automated email from the git hooks/post-receive script.

sunweaver pushed a commit to branch master
in repository debian-edu-config.

commit ca419516812d18762683d9ffe14cbd3512748301
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Wed Oct 14 09:31:01 2015 +0200

    WoL for Debian Edu clients: Make shutdown and wake-up procedure of Debian Edu clients configurable separately. (Closes: #801741).
    
      We now have four NIS netgroups available that allow configuration
      of wake-up and shutdown behaviour:
      - shutdown-at-night-hosts: hosts to wake-up and shutdown.
      - no-shutdown-at-night-hosts: blacklist of hosts not to wake-up nor
        to shutdown.
      - wakeup-in-the-morning-hosts: hosts to wake-up in the morning, overrides
        hostlist given via shutdown-at-night-hosts NIS netgroup, this also expects
        host blacklisting to be handled via the below NIS netgroup.
      - no-wakeup-in-the-morning-hosts: blacklist of hosts that are not
        to be woken up in the morning.
---
 debian/changelog                        | 12 ++++++++++++
 etc/shutdown-at-night/clients-generator | 31 +++++++++++++++++++++++++++----
 2 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 03b9946..2adbc0c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,18 @@ debian-edu-config (1.819) UNRELEASED; urgency=low
   [ Mike Gabriel ]
   * Add quotes around DNs when evoking kadmin.local in gosa-create and
     gosa-create-host. (Closes: #792042).
+  * WoL for Debian Edu clients: Make shutdown and wake-up procedure of
+    Debian Edu clients configurable separately. (Closes: #801741).
+    We now have four NIS netgroups available that allow configuration
+    of wake-up and shutdown behaviour:
+    - shutdown-at-night-hosts: hosts to wake-up and shutdown.
+    - no-shutdown-at-night-hosts: blacklist of hosts not to wake-up nor
+      to shutdown.
+    - wakeup-in-the-morning-hosts: hosts to wake-up in the morning, overrides
+      hostlist given via shutdown-at-night-hosts NIS netgroup, this also expects
+      host blacklisting to be handled via the below NIS netgroup.
+    - no-wakeup-in-the-morning-hosts: blacklist of hosts that are not
+      to be woken up in the morning.
 
  -- Petter Reinholdtsen <pere at debian.org>  Sat, 16 May 2015 23:12:06 +0200
 
diff --git a/etc/shutdown-at-night/clients-generator b/etc/shutdown-at-night/clients-generator
index 94ded9d..e5d11a3 100755
--- a/etc/shutdown-at-night/clients-generator
+++ b/etc/shutdown-at-night/clients-generator
@@ -9,9 +9,32 @@ use SiteSummary;
 use vars qw(%hostmap);
 
 $ENV{PATH} .= ':/usr/sbin';
-my @hostlist = `netgroup -h shutdown-at-night-hosts`;
-chomp @hostlist;
-map { $hostmap{$_} = 1; } @hostlist;
+
+my @host_whitelist = `netgroup -h shutdown-at-night-hosts 2>/dev/null || true`;
+my @host_blacklist = `netgroup -h no-shutdown-at-night-hosts 2>/dev/null || true`;
+
+my @wakeup_host_whitelist = `netgroup -h wakeup-in-the-morning-hosts 2>/dev/null || printf "NETGROUP-NOT-FOUND" `;
+if((exists $wakeup_host_whitelist[0]) && ($wakeup_host_whitelist[0] ne "NETGROUP-NOT-FOUND")) {
+    @host_whitelist = @wakeup_host_whitelist;
+    # when wakeup-in-the-morning-hosts netgroup is used, expect its own blacklist pendant (i.e., netgroup no-wakeup-in-the-morning-hosts)
+    @host_blacklist = ();
+}
+
+# only use the no-wakeup-in-the-morning
+my @wakeup_host_blacklist = `netgroup -h no-wakeup-in-the-morning-hosts 2>/dev/null || printf "NETGROUP-NOT-FOUND"`;
+if((exists $wakeup_host_blacklist[0]) && ($wakeup_host_blacklist[0] ne "NETGROUP-NOT-FOUND")) {
+    @host_blacklist = @wakeup_host_blacklist;
+}
+
+chomp @host_whitelist;
+chomp @host_blacklist;
+map { $hostmap{$_} = 1; } @host_whitelist;
+foreach my $blacklisted_host (@host_blacklist) {
+    if($blacklisted_host) { $hostmap{$blacklisted_host} = 0; }
+}
+
+# comment out for better debugging...
+#print STDERR "$_ $hostmap{$_}\n" for (keys %hostmap);
 
 for_all_hosts(\&host_handler);
 exit(0);
@@ -22,7 +45,7 @@ sub host_handler {
     my $fqdn = scalar gethostbyaddr(inet_aton($ipaddr), AF_INET);
     if ($fqdn) {
         my $mac = (get_ether_hwaddr($hostid))[0];
-        if (exists $hostmap{$fqdn}) {
+        if ((exists $hostmap{$fqdn}) && ($hostmap{$fqdn} == 1)) {
             print "$fqdn $mac\n";
         }
     }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/debian-edu-config.git



More information about the debian-edu-commits mailing list