-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from wayofdev/ci/e2e-testing
- Loading branch information
Showing
2 changed files
with
54 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,60 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ ! -f .env ] | ||
then | ||
echo "[Warning] .env file not found. Please generate it using make env command!" | ||
exit 1; | ||
else | ||
set -a | ||
source <(cat .env | sed -e '/^#/d;/^\s*$/d' -e "s/'/'\\\''/g" -e "s/=\(.*\)/='\1'/g") | ||
set +a | ||
TLS_DOMAINS=${TLS_DOMAINS%\"} | ||
# Function to check if mkcert is installed | ||
check_mkcert_installed() { | ||
if ! command -v mkcert &> /dev/null; then | ||
echo "[Error] mkcert is not installed. Please install mkcert first." | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Function to install mkcert CA | ||
install_mkcert_ca() { | ||
echo "[Info] Installing mkcert CA..." | ||
mkcert -install | ||
} | ||
|
||
# Function to load environment variables from .env file | ||
load_env() { | ||
if [ ! -f .env ]; then | ||
echo "[Warning] .env file not found. Please generate it using make env command!" | ||
exit 1 | ||
else | ||
set -a | ||
# shellcheck disable=SC2002 | ||
source <(cat .env | sed -e '/^#/d;/^\s*$/d' -e "s/'/'\\\''/g" -e "s/=\(.*\)/='\1'/g") | ||
set +a | ||
fi | ||
} | ||
|
||
# Function to display domains to be loaded | ||
display_domains() { | ||
local DOMAINS | ||
local DOMAIN | ||
|
||
DOMAINS=$(echo "$TLS_DOMAINS" | sed -e 's/^"//' -e 's/"$//') | ||
|
||
echo "[Info] Domains to load:" | ||
for DOMAIN in ${TLS_DOMAINS#\"}; do | ||
for DOMAIN in $DOMAINS; do | ||
echo " - ${DOMAIN}" | ||
done | ||
fi | ||
} | ||
|
||
# Function to generate certificates | ||
generate_certs() { | ||
local DOMAINS | ||
DOMAINS=$(echo "$TLS_DOMAINS" | sed -e 's/^"//' -e 's/"$//') | ||
# shellcheck disable=SC2086 | ||
mkcert -key-file traefik/certs/key.pem -cert-file traefik/certs/cert.pem $DOMAINS | ||
} | ||
|
||
# Main script execution | ||
main() { | ||
check_mkcert_installed | ||
install_mkcert_ca | ||
load_env | ||
display_domains | ||
generate_certs | ||
} | ||
|
||
mkcert -key-file traefik/certs/key.pem -cert-file traefik/certs/cert.pem ${TLS_DOMAINS#\"} | ||
main |