-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·34 lines (26 loc) · 1.05 KB
/
entrypoint.sh
File metadata and controls
executable file
·34 lines (26 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
set -euo pipefail
if [[ ! -e ./entrypoint_functions.sh ]]; then
echo "This script should be run from the top of the microservices repo" >&2
exit 2
fi
source ./entrypoint_functions.sh
ensure_required_variables "MICROSERVICE"
# Validate MICROSERVICE is a safe directory name
if [[ ! "${MICROSERVICE}" =~ ^[a-zA-Z0-9_-]+$ ]]; then
echo "ERROR: MICROSERVICE must contain only alphanumeric characters, hyphens, and underscores" >&2
exit 2
fi
microservice_dir="$(pwd)/${MICROSERVICE}"
# Verify entrypoint.sh exists in target service
if [[ ! -e "${microservice_dir}/entrypoint.sh" ]]; then
echo "This script sees the MICROSERVICE environment variable set to \"${MICROSERVICE}\" but is unable to find the corresponding entrypoint script \"${microservice_dir}/entrypoint.sh\"" >&2
exit 2
fi
# Verify entrypoint.sh is executable
if [[ ! -x "${microservice_dir}/entrypoint.sh" ]]; then
echo "${microservice_dir}/entrypoint.sh is not executable" >&2
exit 2
fi
cd "${microservice_dir}" || exit 2
exec "${microservice_dir}/entrypoint.sh"