diff options
author | Niklas Halle <niklas@niklashalle.net> | 2024-02-10 11:42:03 +0100 |
---|---|---|
committer | Niklas Halle <niklas@niklashalle.net> | 2024-02-10 11:42:03 +0100 |
commit | cc7c4bb3383e4358050dccb56a49dd0dbcec43dc (patch) | |
tree | 71c84de6feaf3d50acc9e71972ee55368cfc5d48 /load_common_and_env.sh | |
download | server_scripts-cc7c4bb3383e4358050dccb56a49dd0dbcec43dc.tar.gz server_scripts-cc7c4bb3383e4358050dccb56a49dd0dbcec43dc.zip |
inital
Diffstat (limited to 'load_common_and_env.sh')
-rwxr-xr-x | load_common_and_env.sh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/load_common_and_env.sh b/load_common_and_env.sh new file mode 100755 index 0000000..442c59c --- /dev/null +++ b/load_common_and_env.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -euo pipefail +trap 'if [ $? -ne 0 ]; then echo "FAILED ($?): Last command to run: $BASH_COMMAND"; fi' EXIT + +# Load environment variables +if [ -f .env ]; then + while IFS= read -r line || [[ -n "$line" ]]; do + if [[ $line != \#* && $line != '' ]]; then + export "$line" + fi + done < .env +else + echo ".env file not found" + exit 1 +fi |