From: Erik Garrison Date: Tue, 18 Nov 2008 05:59:18 +0000 (-0500) Subject: initchroot: use tee to log to $ROOTDIR.log X-Git-Tag: v0.4~3 X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd22e025f6ba5e5c23e5729df1857811cc743fcd;p=xodist initchroot: use tee to log to $ROOTDIR.log 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 --- diff --git a/functions.sh b/functions.sh index 46705f6..b6714e5 100644 --- a/functions.sh +++ b/functions.sh @@ -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 +} diff --git a/initchroot.sh b/initchroot.sh index 7c84e1d..05af90f 100755 --- a/initchroot.sh +++ b/initchroot.sh @@ -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