[debian-edu-commits] debian-edu/ 02/02: Add signal trapping in run-at-firstboot script to log an error: string if it terminates unexpectedly.

Petter Reinholdtsen pere at moszumanska.debian.org
Fri Sep 12 10:19:29 UTC 2014


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

pere pushed a commit to branch master
in repository debian-edu-config.

commit 3f0dba6f72e95d5a36add5666115f16f5f01b835
Author: Petter Reinholdtsen <pere at hungry.com>
Date:   Fri Sep 12 12:19:24 2014 +0200

    Add signal trapping in run-at-firstboot script to log an error: string if it terminates unexpectedly.
---
 debian/changelog                               |  2 ++
 share/debian-edu-config/tools/run-at-firstboot | 17 ++++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 8a1ccd4..5f0e123 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ debian-edu-config (1.728) UNRELEASED; urgency=low
 
   * Improve log messages from run-at-firstboot, to make it clearer what
     is going on.
+  * Add signal trapping in run-at-firstboot script to log an error:
+    string if it terminates unexpectedly.
 
  -- Petter Reinholdtsen <pere at debian.org>  Fri, 12 Sep 2014 09:20:57 +0200
 
diff --git a/share/debian-edu-config/tools/run-at-firstboot b/share/debian-edu-config/tools/run-at-firstboot
index 46679e1..e7641b1 100755
--- a/share/debian-edu-config/tools/run-at-firstboot
+++ b/share/debian-edu-config/tools/run-at-firstboot
@@ -7,7 +7,16 @@ if [ -f /etc/debian-edu/config ] ; then
     . /etc/debian-edu/config
 fi
 
-logger -t debian-edu-config "Executing run-at-firstboot script."
+log() { logger -t debian-edu-config "$@"; }
+info() { log "info: $@"; }
+error() { log "error: $@"; }
+at_exit() {
+    error "script $0 terminated unexpectedly."
+}
+disable_exception() { trap - INT TERM EXIT; }
+trap at_exit INT TERM EXIT
+
+info "Executing run-at-firstboot script."
 
 # fix for skolelinux bug #1355:
 # make sure /opt/ltsp/*/etc/ssh/ssh_known_hosts is created
@@ -71,11 +80,13 @@ fi
 if [ -x /usr/sbin/update-apt-xapian-index ] ; then
     dpkg-reconfigure apt-xapian-index
 else
-    logger -t debian-edu-config "info: apt-xapian-index/goplay is not installed"
+    info "apt-xapian-index/goplay is not installed"
 fi
 
 if [ -x /usr/bin/etckeeper ] ; then
     etckeeper commit "End of first boot" > /dev/null 2>&1 || true
 fi
 
-logger -t debian-edu-config "done executing run-at-firstboot script."
+info "done executing run-at-firstboot script."
+
+disable_exception

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/debian-edu-config.git



More information about the debian-edu-commits mailing list