Skip to content

Commit c954ae4

Browse files
authored
Create entrypoint-adm.sh
1 parent 2cc7a7a commit c954ae4

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

phpmyadmin/entrypoint-adm.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (C) 2024 Hasan CALISIR <hasan.calisir@psauxit.com>
4+
# Distributed under the GNU General Public License, version 2.0.
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
19+
# SCRIPT DESCRIPTION:
20+
# -------------------
21+
# NPP (Nginx Cache Purge & Preload for WordPress) Dockerized entrypoint
22+
# https://github.com/psaux-it/nginx-fastcgi-cache-purge-and-preload
23+
# https://wordpress.org/plugins/fastcgi-cache-purge-and-preload-nginx/
24+
25+
set -Eeuo pipefail
26+
27+
# Define color codes
28+
COLOR_RESET='\033[0m'
29+
COLOR_GREEN='\033[0;32m'
30+
COLOR_YELLOW='\033[0;33m'
31+
COLOR_RED='\033[0;31m'
32+
COLOR_CYAN='\033[0;36m'
33+
COLOR_BOLD='\033[1m'
34+
COLOR_WHITE='\033[0;97m'
35+
COLOR_BLACK='\033[0;30m'
36+
COLOR_LIGHT_CYAN='\033[0;96m'
37+
38+
# Check if required environment variables are set
39+
for var in \
40+
WORDPRESS_DB_USER \
41+
WORDPRESS_DB_PASSWORD \
42+
WORDPRESS_DB_NAME; do
43+
if [[ -z "${!var:-}" ]]; then
44+
echo -e "${COLOR_RED}${COLOR_BOLD}NPP-WP-FATAL:${COLOR_RESET} Missing required environment variable(s): ${COLOR_LIGHT_CYAN}${var}${COLOR_RESET} - ${COLOR_RED}Exiting...${COLOR_RESET}"
45+
exit 1
46+
fi
47+
done
48+
49+
# Wait for the 'wordpress-db' to be ready
50+
until mysql -h wordpress-db -u"${WORDPRESS_DB_USER}" -p"${WORDPRESS_DB_PASSWORD}" "${WORDPRESS_DB_NAME}" -e "SELECT 1" > /dev/null 2>&1; do
51+
echo -e "${COLOR_YELLOW}${COLOR_BOLD}NPP-ADM:${COLOR_RESET} The ${COLOR_LIGHT_CYAN}MySQL database${COLOR_RESET} is not available yet. Retrying..."
52+
sleep 6
53+
done
54+
echo -e "${COLOR_GREEN}${COLOR_BOLD}NPP-ADM:${COLOR_RESET} The ${COLOR_LIGHT_CYAN}MySQL database${COLOR_RESET} is ready! Proceeding..."
55+
56+
# Start Apache
57+
exec /docker-entrypoint.sh "$@"

0 commit comments

Comments
 (0)