File tree Expand file tree Collapse file tree 2 files changed +54
-13
lines changed
Expand file tree Collapse file tree 2 files changed +54
-13
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,6 @@ override-create: ## Generate override file from dist
127127.PHONY : override-create
128128
129129cert-install : # # Run mkcert to install CA into system storage and generate default certs for traefik
130- mkcert -install
131130 bash mkcert.sh
132131.PHONY : cert-install
133132
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
3- if [ ! -f .env ]
4- then
5- echo " [Warning] .env file not found. Please generate it using make env command!"
6- exit 1;
7- else
8- set -a
9- source <( cat .env | sed -e ' /^#/d;/^\s*$/d' -e " s/'/'\\ \''/g" -e " s/=\(.*\)/='\1'/g" )
10- set +a
11- TLS_DOMAINS=${TLS_DOMAINS% \" }
3+ # Function to check if mkcert is installed
4+ check_mkcert_installed () {
5+ if ! command -v mkcert & > /dev/null; then
6+ echo " [Error] mkcert is not installed. Please install mkcert first."
7+ exit 1
8+ fi
9+ }
10+
11+ # Function to install mkcert CA
12+ install_mkcert_ca () {
13+ echo " [Info] Installing mkcert CA..."
14+ mkcert -install
15+ }
16+
17+ # Function to load environment variables from .env file
18+ load_env () {
19+ if [ ! -f .env ]; then
20+ echo " [Warning] .env file not found. Please generate it using make env command!"
21+ exit 1
22+ else
23+ set -a
24+ # shellcheck disable=SC2002
25+ source <( cat .env | sed -e ' /^#/d;/^\s*$/d' -e " s/'/'\\ \''/g" -e " s/=\(.*\)/='\1'/g" )
26+ set +a
27+ fi
28+ }
29+
30+ # Function to display domains to be loaded
31+ display_domains () {
32+ local DOMAINS
33+ local DOMAIN
34+
35+ DOMAINS=$( echo " $TLS_DOMAINS " | sed -e ' s/^"//' -e ' s/"$//' )
36+
1237 echo " [Info] Domains to load:"
13- for DOMAIN in ${TLS_DOMAINS # \" } ; do
38+ for DOMAIN in $DOMAINS ; do
1439 echo " - ${DOMAIN} "
1540 done
16- fi
41+ }
42+
43+ # Function to generate certificates
44+ generate_certs () {
45+ local DOMAINS
46+ DOMAINS=$( echo " $TLS_DOMAINS " | sed -e ' s/^"//' -e ' s/"$//' )
47+ # shellcheck disable=SC2086
48+ mkcert -key-file traefik/certs/key.pem -cert-file traefik/certs/cert.pem $DOMAINS
49+ }
50+
51+ # Main script execution
52+ main () {
53+ check_mkcert_installed
54+ install_mkcert_ca
55+ load_env
56+ display_domains
57+ generate_certs
58+ }
1759
18- mkcert -key-file traefik/certs/key.pem -cert-file traefik/certs/cert.pem ${TLS_DOMAINS # \" }
60+ main
You can’t perform that action at this time.
0 commit comments