-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61d8463
commit dc99d21
Showing
3 changed files
with
27 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
# Author: SHIN Company <[email protected]> | ||
# License: https://code.shin.company/php/blob/main/LICENSE | ||
################################################################################ | ||
if [ "$(id -u)" != "0" ]; then echo "Please run this container as the root user." >&2; exit 1; fi | ||
if [ "$(id -u)" != "0" ]; then debug-echo -e "!!! Please run this container as the root user !!!" >&2; exit 1; fi | ||
|
||
APP_PATH="$(app-path)" | ||
|
||
|
@@ -33,7 +33,10 @@ $ENV_CHECK | |
" >> ~/.bashrc; fi | ||
|
||
# export all env variables for PHP | ||
if is-true $ALLOW_RUNTIME_PHP_ENVVARS && has-cmd php-envvars; then php-envvars export_envvars 2>&1; fi | ||
if is-true $ALLOW_RUNTIME_PHP_ENVVARS && has-cmd php && has-cmd php-envvars; then | ||
debug-echo "Export all env variables for PHP" | ||
php-envvars export_envvars 2>&1 | ||
fi | ||
|
||
# change working directory | ||
if [ -d "$APP_PATH" ]; then cd "$APP_PATH"; fi | ||
|
@@ -43,6 +46,7 @@ if [ ! -z "$SUPERVISOR_PHP_COMMAND" ]; then | |
hook bootstrap | ||
|
||
# run custom command defined in $SUPERVISOR_PHP_COMMAND | ||
debug-echo "Start container with the command: $SUPERVISOR_PHP_COMMAND $@" | ||
exec with-env $SUPERVISOR_PHP_COMMAND "$@" | ||
else | ||
# run bootstrap hook to initialize the container | ||
|
@@ -55,6 +59,6 @@ else | |
if [ $# -eq 0 ]; then set -- /bin/sh; fi | ||
|
||
# start container with command | ||
debug-echo "Start container with command $@" | ||
debug-echo "Start container with the command: $@" | ||
exec with-env "$@" | ||
fi |
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,27 +1,31 @@ | ||
#!/usr/bin/env sh | ||
# colors | ||
NC='\033[0m' # no color | ||
|
||
NC='\033[0m' | ||
case "$1" in | ||
-e|--error) CL='\033[0;31m'; shift ;; | ||
-s|--success) CL='\033[0;32m'; shift ;; | ||
-w|--warn) CL='\033[0;33m'; shift ;; | ||
-i|--info) CL='\033[0;34m'; shift ;; | ||
-l|--log) CL='\033[0;90m'; shift ;; | ||
*) if ! is-debug; then exit 0; else CL='\033[0;90m'; fi ;; | ||
-c|--critical) CL='\033[0;31m'; shift ;; | ||
-e|--error) CL='\033[0;31m'; shift ;; | ||
-s|--success) CL='\033[0;32m'; shift ;; | ||
-w|--warn) CL='\033[0;33m'; shift ;; | ||
-i|--info) CL='\033[0;34m'; shift ;; | ||
-l|--log) CL='\033[0;90m'; shift ;; | ||
*) CL='\033[0;90m'; if ! is-debug; then exit 0; fi ;; | ||
esac | ||
|
||
if [ ! -t 1 ]; then | ||
NC= | ||
CL= | ||
fi | ||
|
||
colorize() { | ||
if [ -t 1 ] && [ ! -z "$CL" ]; then | ||
if [ -n "$@" ]; then | ||
echo -e "${CL}$@${NC}" | ||
else | ||
echo -e "$@" | ||
fi | ||
} | ||
|
||
if [ -t 0 ]; then | ||
colorize "$@" >&2 | ||
else | ||
while read line; do | ||
colorize "$@" | ||
|
||
if [ ! -t 0 ]; then | ||
while IFS= read -r line; do | ||
colorize "$line" | ||
done | ||
fi |