From fd22e025f6ba5e5c23e5729df1857811cc743fcd Mon Sep 17 00:00:00 2001 From: Erik Garrison Date: Tue, 18 Nov 2008 00:59:18 -0500 Subject: [PATCH] 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 --- functions.sh | 10 ++++++++++ initchroot.sh | 2 ++ 2 files changed, 12 insertions(+) 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 -- 2.39.5