[debian-edu-commits] debian-edu/ 10/64: * Change wakeupclients to log progress, and to check if a client is up before trying to wake it.

Mike Gabriel sunweaver at debian.org
Wed Oct 23 09:51:49 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 86faa6df4b138fce8622ee90a3e1d83a23de70c0
Author: Petter Reinholdtsen <pere at hungry.com>
Date:   Thu Jun 12 07:16:31 2008 +0000

      * Change wakeupclients to log progress, and to check if a client is up
        before trying to wake it.
    
    git-svn-id: svn+ssh://svn.debian.org/svn/debian-edu/trunk/src/shutdown-at-night@41442 6e500793-9bee-0310-a5b0-9d0909bd054d
---
 debian/changelog |    2 ++
 wakeupclients    |   22 +++++++++++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index d0db804..0704346 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,8 @@
 shutdown-at-night (0.2) UNRELEASED; urgency=low
 
   * Add server side cron job to start waking up clients at 06:30.
+  * Change wakeupclients to log progress, and to check if a client is up
+    before trying to wake it.
 
  -- Petter Reinholdtsen <pere at debian.org>  Sun,  8 Jun 2008 18:18:53 +0200
 
diff --git a/wakeupclients b/wakeupclients
index 683e531..40fe44f 100755
--- a/wakeupclients
+++ b/wakeupclients
@@ -22,9 +22,14 @@ close(CLIENTS);
 #my $allup = time();
 
 # Start sending wakeup calls
-for my $ip (keys %hwaddrs) {
-    wakeup($ip, $hwaddrs{$ip});
-    sleep $delay;
+for my $ip (sort keys %hwaddrs) {
+    if (!alive($ip)) {
+        syslog("sending wake-on-lan package to $ip [$hwaddrs{$ip}]");
+        wakeup($ip, $hwaddrs{$ip});
+        sleep $delay;
+    } else {
+        syslog("not sending wake-on-lan package to already awake $ip [$hwaddrs{$ip}]");
+    }
 }
 
 # exit
@@ -34,3 +39,14 @@ sub wakeup {
     my ($ip, $hwaddr) = @_;
     `wakeonlan -i $ip $hwaddr`;
 }
+
+sub alive {
+    my $address = shift;
+    my $retval = system("ping -q -q -c 3 $address >/dev/null");
+    return (0 == $retval);
+}
+
+sub syslog {
+    my $msg = shift;
+    print "$msg\n";
+}

-- 
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