Skip to content

Commit 7d861ff

Browse files
committed
Create function to check if vars exist
1 parent 152145a commit 7d861ff

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docker-entrypoint.sh

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ set -e
33

44
echoerr() { echo "$@" 1>&2; }
55

6+
check_vars_exist() {
7+
var_names=("$@")
8+
9+
for var_name in "${var_names[@]}"; do
10+
if [ -z "${!var_name}" ]; then
11+
echoerr "error: missing ${var_name} environment variable"
12+
exit 1
13+
fi
14+
done
15+
}
16+
617
# Split out host and port from DB_HOST env variable
718
IFS=":" read -r DB_HOST_NAME DB_PORT <<< "$DB_HOST"
819
DB_PORT=${DB_PORT:-3306}

0 commit comments

Comments
 (0)