[debian-edu-commits] r82652 - trunk/src/shutdown-at-night

mike-gabriel-guest at alioth.debian.org mike-gabriel-guest at alioth.debian.org
Wed Oct 23 10:55:59 UTC 2013


Author: mike-gabriel-guest
Date: 2013-10-23 10:55:58 +0000 (Wed, 23 Oct 2013)
New Revision: 82652

Added:
   trunk/src/shutdown-at-night/README.migrated2git
Removed:
   trunk/src/shutdown-at-night/Makefile
   trunk/src/shutdown-at-night/README
   trunk/src/shutdown-at-night/debian/
   trunk/src/shutdown-at-night/shutdown-at-night
   trunk/src/shutdown-at-night/wakeupclients
Log:
remove files, add README.migrated2git

Deleted: trunk/src/shutdown-at-night/Makefile
===================================================================
--- trunk/src/shutdown-at-night/Makefile	2013-10-23 09:14:31 UTC (rev 82651)
+++ trunk/src/shutdown-at-night/Makefile	2013-10-23 10:55:58 UTC (rev 82652)
@@ -1,22 +0,0 @@
-DESTDIR   =
-prefix    = /usr
-sbindir   = $(prefix)/sbin
-sysconfdir= /etc
-pkgsysconfdir= $(sysconfdir)/shutdown-at-night
-
-# Install scripts in lib/, to make it trivial to rewrite the internal tools
-# in any language, even compiled ones, without having to update the path used
-# by the callers.
-pkglibdir = $(prefix)/lib/shutdown-at-night
-
-INSTALL = install
-
-all:
-
-install:
-	$(INSTALL) -d $(DESTDIR)$(pkglibdir)/. $(DESTDIR)$(pkgsysconfdir)/.
-	$(INSTALL) shutdown-at-night $(DESTDIR)$(pkglibdir)/.
-	$(INSTALL) wakeupclients $(DESTDIR)$(pkglibdir)/.
-
-distclean: clean
-clean:

Deleted: trunk/src/shutdown-at-night/README
===================================================================
--- trunk/src/shutdown-at-night/README	2013-10-23 09:14:31 UTC (rev 82651)
+++ trunk/src/shutdown-at-night/README	2013-10-23 10:55:58 UTC (rev 82652)
@@ -1,68 +0,0 @@
-Saving power by turning off clients at night
-============================================
-
-It is possible to save power by turning off clients at night, and turn
-them automatically on in the morning.
-
-There are some considerations to make when doing this:
-
- - The clients should not be shut down when someone is using them.
-   This is done by checking the output from 'who', and as a special
-   case, checking for the LDM ssh connection command to work with LTSP
-   thin clients.
-
- - To avoid breaking fuses, it is a good idea to make sure all clients
-   do not start at the same time.
-
- - There are two different methods available to wake up clients.  One
-   uses a BIOS feature and require a working and correct hardware
-   clock, as well as a motherboard and BIOS version supported by
-   nvram-wakeup, The other require a server with knowledge about all
-   the clients to wake up and for all the clients to have support for
-   wake-on-lan.
-
-How to set it up
-----------------
-
-On clients that should turn off at night, touch
-/etc/shutdown-at-night/shutdown-at-night, or add the hostname (ie the
-output from 'uname -n' or 'hostname -s' on the client) to the netgroup
-"shutdown-at-night-hosts".  The clients might need to have wake-on-lan
-configured in the BIOS.  It is also important that the switches and
-routers used between the wake-on-lan server and the clients will pass
-the WOL packages to the clients even if the clients are turned off.
-Some switches fail to pass on packages to clients that are missing in
-the ARP table on the switch, and this block the WOL packages.
-
-To enable wake-on-lan on the server, add the clients to
-/etc/shutdown-at-night/clients, with one line per client, IP address
-first, and MAC address (ethernet address) next, with space between
-them, or create a script /etc/shutdown-at-night/clients-generator to
-generate the list of clients on the fly.
-
-Here is an example /etc/shutdown-at-night/clients-generator for use
-with sitesummary:
-
-  #!/bin/sh
-  PATH=/usr/sbin:$PATH
-  export PATH
-  sitesummary-nodes -w
-
-An alternative if the netgroup is used to activate shutdown-at-night
-on clients is this script using the netgroup tool from the ng-utils
-package:
-
-  #!/bin/sh
-  PATH=/usr/sbin:$PATH
-  export PATH
-  netgroup -h shutdown-at-night-hosts
-
-License
--------
-
-This package is licensed using GNU General Public License v2 or later.
-
-Bugreporting
-------------
-
-Report issues to the debian-edu at lists.debian.org mailing list.

Added: trunk/src/shutdown-at-night/README.migrated2git
===================================================================
--- trunk/src/shutdown-at-night/README.migrated2git	                        (rev 0)
+++ trunk/src/shutdown-at-night/README.migrated2git	2013-10-23 10:55:58 UTC (rev 82652)
@@ -0,0 +1,2 @@
+The shutdown-at-night tool has been migrated to Git on Alioth:
+http://anonscm.debian.org/gitweb/?p=debian-edu/pkg-team/shutdown-at-night.git

Deleted: trunk/src/shutdown-at-night/shutdown-at-night
===================================================================
--- trunk/src/shutdown-at-night/shutdown-at-night	2013-10-23 09:14:31 UTC (rev 82651)
+++ trunk/src/shutdown-at-night/shutdown-at-night	2013-10-23 10:55:58 UTC (rev 82652)
@@ -1,139 +0,0 @@
-#!/bin/bash
-# Using /bin/bash and not /bin/sh to get a shell with support for random number
-# generation.
-#
-# Automatically turn off computers at night, defined as 16:00 - 06:00.
-# Should schedule wakeup in the morning.
-
-# How do we decide if it should be enabled for this host?  Netgroup
-# membership?  LDAP search?  Flag file?
-
-#set -e
-
-wakeuptime="07:00"
-
-hostname="$(uname -n)"
-netgroupname="shutdown-at-night-hosts"
-
-# Hook directories to allow custom code to detect if a machine is used
-# or not.
-unuseddlist="/etc/shutdown-at-night/unused.d /usr/lib/shutdown-at-night/unused.d"
-
-in_netgroup() {
-    # Try both long and short name
-    for h in "$(uname -n)" "$(hostname -s)" ; do
-	if innetgr -h "$h" "$netgroupname" ; then
-	    return 0
-	fi
-    done
-    return 1
-}
-
-enabled_for_host() {
-    # Flag for now
-    if [ -f /etc/shutdown-at-night/shutdown-at-night ] || in_netgroup; then
-        return 0
-    fi
-    return 1
-}
-
-# Take wakeup hour:minute in local time zone and return wake up time
-# in seconds since EPOC UTC, radomized around the target wakeup time.
-whentowakeup() {
-    wakeuptime=$1
-    # Spread the BIOS wakeup time across a 20 minute period, to avoid
-    # all of them waking up at the same time, killing a fuse.
-
-    # Convert local target time in seconds since EPOC UTC
-    targettime=$(date +%s -d "tomorrow $wakeuptime $(date +%z)")
-    echo $(( $targettime - 600 + $RANDOM % 1200))
-}
-
-nvramwakeup() {
-# http://www.vdr-portal.de/board/thread.php?threadid=75582&sid=b7aced20e710aef12ffa56b5197fe168
-    wakeuptime=$1
-    when=$(whentowakeup $wakeuptime)
-
-    # Make sure HW clock is correct, as it is used to decide when to
-    # wake up.
-    /etc/init.d/hwclock.sh stop > /dev/null
-
-    # Make sure /dev/nvram is available
-    modprobe nvram
-
-    # This require a supported motherboard
-    if nvram-wakeup -s $when > /dev/null ; then
-        logger -t shutdown-at-night "scheduled $hostname to turn itself on at $wakeuptime using nvram-wakeup."
-        return 0
-    else
-        return 1
-    fi
-}
-
-# This method might not work if the hardware clock is updated during
-# shutdown.  Changing /etc/default/hwclock to list HWCLOCKACCESS=yes
-# to disable it.
-acpiwakeup() {
-    wakeuptime="$1"
-    if [ -e /sys/class/rtc/rtc0/wakealarm ] ; then
-	when=$(whentowakeup $wakeuptime)
-
-        # First reset alarm
-	echo 0 > /sys/class/rtc/rtc0/wakealarm
-
-        # Next, set it to our selected time
-	echo $when > /sys/class/rtc/rtc0/wakealarm
-	logger -t shutdown-at-night "scheduled $hostname to turn itself on at $wakeuptime using /sys/class/rtc/rtc0/wakealarm."
-	return 0
-    else
-	return 1
-    fi
-}
-
-prepare_wakeonlan() {
-    interface="$(/sbin/route -n | awk '/^0\.0\.0\.0 / { print $8 }')"
-    ethtool -s $interface wol g
-}
-
-is_host_unused() {
-    # Logged in users, or ldm connection to a remote server
-    if [ "$(who)" ] ||  ps -efwww | egrep -q ' ssh .*LTSP_CLIEN[T]' ; then
-	return 1
-    fi
-    # Uptime is less than one hour
-    if (( $(cat /proc/uptime  | awk '{print int($1)}') < 3600 )) ; then
-        return 1
-    fi
-    for dir in $unuseddlist ; do
-	if [ -d $dir ] ; then
-            for f in $dir/* ; do
-		if [ -x $f ] && ! $f ; then
-                    return 1
-		fi
-            done
-	fi
-    done
-    return 0
-}
-
-fatal() {
-    logger -t shutdown-at-night "$1"
-    exit 1
-}
-
-if enabled_for_host ; then
-    if is_host_unused; then
-	logger -t shutdown-at-night "turning off unused client $hostname."
-	if type nvram-wakeup >/dev/null 2>&1 ; then
-	    nvramwakeup $wakeuptime
-	fi
-	acpiwakeup $waketime
-	prepare_wakeonlan || fatal "unable to enable wake-on-lan - aborting shutdown."
-	shutdown -h 5 "Unused host being turned off for the night (cron)." < /dev/null > /dev/null 2>&1 &
-    else 
-      logger -t shutdown-at-night "client $hostname is in use; shutdown sequence will NOT be initiated."
-    fi
-else
-    logger -t shutdown-at-night "shutdown-at-night is not enabled for client $hostname."
-fi
-

Deleted: trunk/src/shutdown-at-night/wakeupclients
===================================================================
--- trunk/src/shutdown-at-night/wakeupclients	2013-10-23 09:14:31 UTC (rev 82651)
+++ trunk/src/shutdown-at-night/wakeupclients	2013-10-23 10:55:58 UTC (rev 82652)
@@ -1,74 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-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;
-
-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);
-    }
-}
-
-my %alive;
-map { $alive{$_} = 1; } get_alive_list(keys %hwaddrs);
-
-# Calculate when to start, assuming 20-30 seconds between each host
-#my $duration = $delay * scalar keys %hwaddrs;
-#my $allup = time();
-
-# Start sending wakeup calls
-for my $ip (sort keys %hwaddrs) {
-    if (! defined $alive{$ip}) {
-        logmsg("sending wake-on-lan to $ip [$hwaddrs{$ip}]");
-        wakeup($ip, $hwaddrs{$ip});
-        sleep $delay;
-    } else {
-        logmsg("not sending wake-on-lan to already awake $ip [$hwaddrs{$ip}]");
-    }
-}
-
-# exit
-exit 0;
-
-sub wakeup {
-    my ($ip, $hwaddr) = @_;
-    `wakeonlan $hwaddr`;
-}
-
-sub get_alive_list {
-    my @addresses = @_;
-    return split(/\s+/, `fping -a @addresses 2>/dev/null`);
-}
-
-sub logmsg {
-    my $msg = shift;
-    openlog("wakeupclients", undef, 'user');
-    syslog(LOG_NOTICE, "%s", $msg);
-    closelog;
-}




More information about the debian-edu-commits mailing list