]> spindle.queued.net Git - xodist/commitdiff
initchroot: use tee to log to $ROOTDIR.log
authorErik Garrison <erik@laptop.org>
Tue, 18 Nov 2008 05:59:18 +0000 (00:59 -0500)
committerAndres Salomon <dilinger@debian.org>
Tue, 18 Nov 2008 05:59:18 +0000 (00:59 -0500)
Make a named pipe (which we clean up on exit or script death), set our
stdout/stderr to it, and pipe it tee so we can see what's happening and
log at the same time.

Signed-off-by: Andres Salomon <dilinger@debian.org>
functions.sh
initchroot.sh

index 46705f6f3787ba635bcc9ae19af0d61ce2692ec5..b6714e57ec86b28f71ccc9ee155226c293baffe9 100644 (file)
@@ -114,3 +114,13 @@ chroot_internal_umounts()
     umount ${root_dir}/dev/pts
     umount ${root_dir}/var/cache/apt/cache
 }
+
+start_logging()
+{
+    logpipe="$1".pipe
+    trap "rm -f $logpipe" 0
+    mknod $logpipe p
+    tee "$1".log <$logpipe &
+    trap "kill $!; rm -f $logpipe" 0
+    exec >$logpipe 2>&1
+}
index 7c84e1df134cd25ee1b9a571731bca0d8287905e..05af90f30f97f163d4aba2becc773ff7c4fd3541 100755 (executable)
@@ -85,6 +85,8 @@ if [ -d "${ROOT_DIR}" ]; then
        usage
 fi
 
+start_logging $ROOT_DIR
+
 check_for_cmds debootstrap || exit 1
 
 if [ -z "${LOCAL_APT_MIRROR}" ]; then