Commit 01a85736 authored by Mattia Rizzolo's avatar Mattia Rizzolo

move code under a subshell

Signed-off-by: Mattia Rizzolo's avatarMattia Rizzolo <mapreri@ubuntu.com>
parent fb685486
......@@ -10,15 +10,14 @@ if [[ "$(whoami)" != "ubuntu-it" ]]; then
exit 1
fi
# Try to deploy all the websites
for script in "${base}/scripts/"*; do
run_script() (
if [[ ! -x "${script}" ]]; then
continue
echo "$(basename "$script"): not executable, skipping"
return
fi
# Create a temporary build directory
build_dir="$(mktemp -d deploy-XXXXXXXXX -p /tmp)"
trap 'rm -rfv "$build_dir"' RETURN
# Switch to the temporary build directory
cd "${build_dir}"
......@@ -29,8 +28,10 @@ for script in "${base}/scripts/"*; do
# Execute the deploy script
# Capture the output and print it only if the script fails
"$script" > "$output"
if [[ $? -ne 0 ]]; then
ret=$?
if [[ "$ret" -ne 0 ]]; then
echo "Deploy script $(basename "${script}") failed!"
echo "Return code: $?"
echo "Script output"
echo "============="
cat "${output}"
......@@ -40,8 +41,10 @@ for script in "${base}/scripts/"*; do
# Restore the old home
cd "${base}"
export HOME="${base}"
)
# Remove the temporary directory
rm -rf "${build_dir}"
done
# Try to deploy all the websites
for script in "${base}/scripts/"*; do
run_script "$script"
done
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment