Skip to content

Commit

Permalink
WIP: Avoid FD juggling in scriptlets
Browse files Browse the repository at this point in the history
  • Loading branch information
vpodzime committed Nov 30, 2018
1 parent 79e2b98 commit 4471936
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions packaging/common/script-templates/script-common-header-last.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,12 @@ is_nova()
test "$PROJECT_TYPE" = "cfengine-nova" || test "$PROJECT_TYPE" = "cfengine-nova-hub"
}

INSTLOG=/var/log/CFEngineHub-Install.log
mkdir -p "$(dirname "$INSTLOG")"
CONSOLE=7
# Redirect most output to log file, but keep console around for custom output.
case "$SCRIPT_TYPE" in
pre*)
eval "exec $CONSOLE>&1 > $INSTLOG 2>&1"
;;
*)
eval "exec $CONSOLE>&1 >> $INSTLOG 2>&1"
;;
esac
echo "$SCRIPT_TYPE:"

# Output directly to console, bypassing log.
cf_console()
{
# Use subshell to prevent "set +x" from leaking out into the rest of the
# execution.
(
set +x
"$@" 1>&$CONSOLE 2>&$CONSOLE
)
"$@"
}

set -x

0 comments on commit 4471936

Please sign in to comment.