40 lines
1.1 KiB
Bash
Executable file
40 lines
1.1 KiB
Bash
Executable file
#!/bin/bash
|
|
# Scripts runner
|
|
|
|
set -euo pipefail;
|
|
|
|
export HL_ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd );
|
|
export HL_AGE_IDENTITY="${HL_AGE_IDENTITY:-$HL_ROOT_DIR/ident}";
|
|
export HL_LIB="$HL_ROOT_DIR/_lib.sh";
|
|
|
|
# create private temp dir
|
|
export HL_TMP_DIR="$(mktemp -d)";
|
|
chmod a-rwx,u+rwx "$HL_TMP_DIR";
|
|
|
|
pushd "$HL_ROOT_DIR" > /dev/null;
|
|
for var in "$@"; do
|
|
sudo whoami > /dev/null # pre-authorize sudo
|
|
pushd scripts/$var > /dev/null;
|
|
if [ "${DONT_HIDE:-0}" -eq "1" ]; then
|
|
echo "" | bash script.sh;
|
|
else
|
|
TEMP_OUT=$(mktemp);
|
|
chmod a-rwx,u+rw "$TEMP_OUT";
|
|
echo -n "scripts/base... ";
|
|
OK=0
|
|
echo "" | bash script.sh > "$TEMP_OUT" 2>&1 || OK=1;
|
|
if [ $OK -eq 0 ]; then
|
|
echo -e "\033[32mOK\033[0m";
|
|
else
|
|
echo -e "\033[1;31mFAILED\033[0m";
|
|
tail -n 10 "$TEMP_OUT" | sed 's/^/ /';
|
|
echo -e "\n\033[1mfull log:\033[0m $TEMP_OUT";
|
|
echo "temp dir not removed $HL_TMP_DIR";
|
|
fi;
|
|
fi;
|
|
popd > /dev/null;
|
|
done
|
|
popd > /dev/null
|
|
|
|
# remove temp dir
|
|
rm -r "$HL_TMP_DIR"
|