[debian-edu-commits] debian-edu/ 17/64: * Add support in wakeupclients to run a script /etc/shutdown-at-night/clients-generator to extract the clients to wake up dynamically.

Mike Gabriel sunweaver at debian.org
Wed Oct 23 09:51:50 UTC 2013


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

sunweaver pushed a commit to branch master
in repository shutdown-at-night.

commit c1fa6b35ed41260779d9a9a4140fd5dd67866a37
Author: Petter Reinholdtsen <pere at hungry.com>
Date:   Fri Jun 13 08:57:37 2008 +0000

      * Add support in wakeupclients to run a script
        /etc/shutdown-at-night/clients-generator to extract the clients to
        wake up dynamically.
    
    git-svn-id: svn+ssh://svn.debian.org/svn/debian-edu/trunk/src/shutdown-at-night@41450 6e500793-9bee-0310-a5b0-9d0909bd054d
---
 debian/changelog |    3 +++
 wakeupclients    |   30 +++++++++++++++++++++++-------
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 4ec8e6b..1889c7c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,9 @@ shutdown-at-night (0.3) UNRELEASED; urgency=low
   * Convert wakeupclients to use syslog.
   * Add suggests on sitesummary (>= 0.0.41) to suggest a version that
     can generate the client list automatically.
+  * Add support in wakeupclients to run a script
+    /etc/shutdown-at-night/clients-generator to extract the clients to
+    wake up dynamically.
 
  -- Petter Reinholdtsen <pere at debian.org>  Fri, 13 Jun 2008 09:33:08 +0200
 
diff --git a/wakeupclients b/wakeupclients
index 4ffaa15..5139c13 100755
--- a/wakeupclients
+++ b/wakeupclients
@@ -7,17 +7,33 @@ use Sys::Syslog qw(openlog syslog closelog LOG_NOTICE);
 
 my $delay = 5;
 my $wakeuplist = "/etc/shutdown-at-night/clients";
+my $wakeupgenerator = "/etc/shutdown-at-night/clients-generator";
 
 my %hwaddrs;
 
-# Locate hosts to wake up
-open(CLIENTS, "<", $wakeuplist) || exit 0;
-while (<CLIENTS>) {
-    chomp;
-    my ($ip, $hwaddr) = split(/\s+/);
-    $hwaddrs{$ip} = $hwaddr;
+sub load_clients {
+    my $fh = shift;
+    while (<$fh>) {
+        chomp;
+        my ($ip, $hwaddr) = split(/\s+/);
+        $hwaddrs{$ip} = $hwaddr;
+    }
+}
+
+# Locate hosts to wake up, from file
+if ( -f $wakeuplist ) {
+    if (open(CLIENTS, "<", $wakeuplist)) {
+        load_clients(*CLIENTS);
+        close(CLIENTS);
+    }
+}
+# Or using a dynamic script
+if ( -x $wakeupgenerator ) {
+    if (open(CLIENTS, "$wakeupgenerator |")) {
+        load_clients(*CLIENTS);
+        close(CLIENTS);
+    }
 }
-close(CLIENTS);
 
 my %alive;
 map { $alive{$_} = 1; } get_alive_list(keys %hwaddrs);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/pkg-team/shutdown-at-night.git



More information about the debian-edu-commits mailing list