[debian-edu-commits] debian-edu/ 01/02: Backport from unstable version 0.13 to fix RC bug.

Petter Reinholdtsen pere at moszumanska.debian.org
Mon Mar 24 09:07:08 UTC 2014


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

pere pushed a commit to branch wheezy-updates
in repository shutdown-at-night.

commit bfd3c69dfb95c3b1009c0efeabad3a26eb6c263e
Author: Petter Reinholdtsen <pere at hungry.com>
Date:   Mon Mar 24 10:03:23 2014 +0100

    Backport from unstable version 0.13 to fix RC bug.
    
    * Backport from unstable version 0.13 to fix RC bug.
    * Rewrite logic checking if a host is unused to look for the KDM,
      Gnome or lightdm login screen to confirm the X sessions are unused
      (Closes: #729553).
    * Add depend on x11-utils for the xlsclients tool used to check unused
      X sessions.
---
 debian/changelog  | 11 +++++++++++
 debian/control    |  2 +-
 shutdown-at-night | 38 ++++++++++++++++++++++++++++++++++++--
 3 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 02dc18b..d607233 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,14 @@
+shutdown-at-night (0.10+deb7u2) UNRELEASED; urgency=low
+
+  * Backport from unstable version 0.13 to fix RC bug.
+  * Rewrite logic checking if a host is unused to look for the KDM,
+    Gnome or lightdm login screen to confirm the X sessions are unused
+    (Closes: #729553).
+  * Add depend on x11-utils for the xlsclients tool used to check unused
+    X sessions.
+
+ -- Petter Reinholdtsen <pere at debian.org>  Mon, 24 Mar 2014 10:00:15 +0100
+
 shutdown-at-night (0.10+deb7u1) wheezy; urgency=low
 
   * Quiet down cron job to wake up client to not complain when fping
diff --git a/debian/control b/debian/control
index abdcf0b..3847689 100644
--- a/debian/control
+++ b/debian/control
@@ -10,7 +10,7 @@ Vcs-Browser: http://svn.debian.org/wsvn/debian-edu/trunk/src/shutdown-at-night
 Package: shutdown-at-night
 Architecture: all
 Depends: ${misc:Depends}, ${perl:Depends},  cron | fcron,
- wakeonlan, ng-utils, fping, ethtool
+ wakeonlan, ng-utils, fping, ethtool, x11-utils
 Recommends: nvram-wakeup
 Suggests: sitesummary (>= 0.0.41)
 Description: System to shut down clients at night, and wake them in the morning
diff --git a/shutdown-at-night b/shutdown-at-night
index c9c97c1..bd6651f 100755
--- a/shutdown-at-night
+++ b/shutdown-at-night
@@ -61,9 +61,44 @@ prepare_wakeonlan() {
     ethtool -s $interface wol g
 }
 
+# Return true if local user is logged in, false otherwise
+is_local_user() {
+    if [ "$(who)" ] ; then
+	return 0
+    else
+	return 1
+    fi
+}
+
+# Return true if ldm login is active
+is_active_ldm_session() {
+    if ps -efwww | egrep -q ' ssh .*LTSP_CLIEN[T]' ; then
+	return 0
+    else
+	return 1
+    fi
+}
+
+# Return false if X session is confirmed unused (ie login screen is
+# shown).  If not sure, claim it is used to be safe.
+is_xsession_used() {
+    for s in \
+	/var/run/gdm3/auth-for-Debian-gdm-*/database \
+	/var/lib/lightdm/.Xauthority \
+	/var/run/xauth/* \
+	/run/xauth/*; do
+	if [ -e "$s" ] ; then
+	    if XAUTHORITY="$s" DISPLAY=:0 xlsclients | egrep -q 'kdmgreet|lightdm-gtk-greeter|razor-lightdm-greeter|lightdm-kde-greeter|gdm-simple-greeter' ; then
+		return 1
+	    fi
+	fi
+    done
+    return 0
+}
+
 is_host_unused() {
     # Logged in users, or ldm connection to a remote server
-    if [ "$(who)" ] ||  ps -efwww | egrep -q ' ssh .*LTSP_CLIEN[T]' ; then
+    if is_xsession_used || is_local_user || is_active_ldm_session; then
 	return 1
     fi
     # Uptime is less than one hour
@@ -92,4 +127,3 @@ if enabled_for_host ; then
 else
     logger -t shutdown-at-night "shutdown-at-night is not enabled for client $hostname."
 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