[debian-edu-commits] debian-edu/ 01/05: Rewrite logic checking if a host is unused to look for the KDM login screen to confirm the X sessions are unused (Closes: #729553).

Petter Reinholdtsen pere at moszumanska.debian.org
Thu Nov 21 09:01:29 UTC 2013


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

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

commit 102c95642ddc23f2583707799c24e24ea0c527de
Author: Petter Reinholdtsen <pere at hungry.com>
Date:   Wed Nov 20 11:08:57 2013 +0100

    Rewrite logic checking if a host is unused to look for the KDM login screen to confirm the X sessions are unused (Closes: #729553).
---
 debian/changelog  |    5 +++++
 shutdown-at-night |   37 +++++++++++++++++++++++++++++++++++--
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 4b3d320..9106012 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,6 @@
 shutdown-at-night (0.13) UNRELEASED; urgency=low
 
+  [ Mike Gabriel ]
   * Package becomes team-maintained: Debian Edu Packaging Team.
   * debian/control:
     + Package migrated to Git. Update Vcs-*: fields and point to
@@ -10,6 +11,10 @@ shutdown-at-night (0.13) UNRELEASED; urgency=low
   * debian/source/format:
     + Add file. Use format 1.0 to match capabilities of Debian Edu's dak.
 
+  [ Petter Reinholdtsen ]
+  * Rewrite logic checking if a host is unused to look for the KDM login
+    screen to confirm the X sessions are unused (Closes: #729553).
+
  -- Mike Gabriel <sunweaver at debian.org>  Wed, 23 Oct 2013 11:39:21 +0200
 
 shutdown-at-night (0.12) unstable; urgency=low
diff --git a/shutdown-at-night b/shutdown-at-night
index 652564d..d1208c8 100755
--- a/shutdown-at-night
+++ b/shutdown-at-night
@@ -96,9 +96,43 @@ 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/run/xauth/* \
+	/run/xauth/*; do
+	if [ -e "$s" ] ; then
+	    if XAUTHORITY="$s" DISPLAY=:0 xlsclients | egrep -q 'kdmgreet' ; 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
@@ -137,4 +171,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