[debian-edu-commits] debian-edu/ 05/64: Improve shutdown script.
Mike Gabriel
sunweaver at debian.org
Wed Oct 23 09:51:48 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 775e09aa9f0089bd8ad8901056d4c5956a0695a8
Author: Petter Reinholdtsen <pere at hungry.com>
Date: Sun Jun 8 16:11:53 2008 +0000
Improve shutdown script.
git-svn-id: svn+ssh://svn.debian.org/svn/debian-edu/trunk/src/shutdown-at-night@41394 6e500793-9bee-0310-a5b0-9d0909bd054d
---
shutdown-at-night | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/shutdown-at-night b/shutdown-at-night
index b00c9a0..2dced23 100755
--- a/shutdown-at-night
+++ b/shutdown-at-night
@@ -4,8 +4,11 @@
# Should schedule wakeup in the morning.
# How do we decide if it should be enabled for this host? Netgroup
-# membership? LDAP search? Flag file?
+# membership? LDAP search? Flag file?
+wakeuptime="07:00"
+
+hostname=$(uname -n)
enabled_for_host() {
# Flag for now
@@ -19,29 +22,26 @@ netgroup_lookup() {
innetgr -h $hostname host-shutdown-at-night
}
-ldap_lookup() {
- ldapsearch -LLL -w public \
- -D "cn=svc.adbind,ou=servicekonti,ou=brukere,ou=i2-drift,dc=skolen,dc=local" \
- -b "dc=skolen,dc=local" \
- -x "(&(&(objectClass=user)(uidNumber=*))(samaccountname=slxtest0101))" unixhomedirectory
-}
-
nvramwakeup() {
# http://www.vdr-portal.de/board/thread.php?threadid=75582&sid=b7aced20e710aef12ffa56b5197fe168
wakeuptime=$1
when=$(date +%s -d 'tomorrow $wakeuptime')
- # Make sure HW clock is correct, as it is used to decide when to wake up.
+ # Make sure HW clock is correct, as it is used to decide when to
+ # wake up.
/etc/init.d/hwclock.sh stop
+
# Make sure /dev/nvram is available
modprobe nvram
+
# This require a supported motherboard
nvram-wakeup -s $when
+ logger -t shutdown-at-night "Scheduled $hostname to turn itself on at $wakeuptime."
}
-wolwakeup() {
- if=eth1
- ethtool -s $if wol g
+prepare_wakeonlan() {
+ interface="(/sbin/route -n | awk '/^0\.0\.0\.0 / { print $8 }')"
+ ethtool -s $interface wol g
}
is_host_unused() {
@@ -53,12 +53,12 @@ is_host_unused() {
}
if enabled_for_host ; then
- wakeuptime="07:00"
if is_host_unused; then
- logger -t shutdown-at-night "Turning off unused client $hostname, turn on at $wakeuptime."
+ logger -t shutdown-at-night "Turning off unused client $hostname."
if type nvram-wakeup 2>/dev/null ; then
nvramwakeup $wakeuptime
fi
- shutdown -h now "Unused host being turned off for the night (cron)."
+ prepare_wakeonlan
+ shutdown -h 5 "Unused host being turned off for the night (cron)."
fi
fi
--
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