🗃️ Committing everything that changed 🗃️

rootfs/usr/local/bin/entrypoint.sh
rootfs/usr/local/etc/docker/functions/entrypoint.sh
This commit is contained in:
casjay 2023-09-03 22:30:58 -04:00
parent 0bd3b77311
commit 235a87fedc
Signed by untrusted user who does not match committer: jason
GPG Key ID: 1AB309F42A764145
2 changed files with 10 additions and 7 deletions

View File

@ -1,13 +1,13 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202309032228-git
##@Version : 202309032229-git
# @@Author : Jason Hempstead
# @@Contact : jason@casjaysdev.pro
# @@License : WTFPL
# @@ReadME : docker-entrypoint --help
# @@Copyright : Copyright: (c) 2023 Jason Hempstead, Casjays Developments
# @@Created : Sunday, Sep 03, 2023 22:28 EDT
# @@Created : Sunday, Sep 03, 2023 22:29 EDT
# @@File : docker-entrypoint
# @@Description :
# @@Changelog : New script

View File

@ -41,8 +41,8 @@ __is_dir_empty() { [ "$(ls -A "$1" 2>/dev/null | wc -l)" -eq 0 ] && return 0 ||
__pcheck() { [ -n "$(which pgrep 2>/dev/null)" ] && pgrep -o "$1" &>/dev/null || return 10; }
__file_exists_with_content() { [ -n "$1" ] && [ -f "$1" ] && [ -s "$1" ] && return 0 || return 2; }
__sed() { sed -i 's|'$1'|'$2'|g' "$3" &>/dev/null || sed -i "s|$1|$2|g" "$3" &>/dev/null || return 1; }
__ps() { [ -f "$(type -P ps)" ] && ps "$@" 2>/dev/null | grep -Fw " ${1:-$postgres}" || return 10; }
__pgrep() { __pcheck "${1:-postgres}" || __ps "${1:-$postgres}" | grep -qv ' grep' || return 10; }
__ps() { [ -f "$(type -P ps)" ] && ps "$@" 2>/dev/null | grep -Fw " ${1:-$SERVICE_NAME}" || return 10; }
__pgrep() { __pcheck "${1:-SERVICE_NAME}" || __ps "${1:-$SERVICE_NAME}" | grep -qv ' grep' || return 10; }
__get_ip6() { ip a 2>/dev/null | grep -w 'inet6' | awk '{print $2}' | grep -vE '^::1|^fe' | sed 's|/.*||g' | head -n1 | grep '^' || echo ''; }
__get_ip4() { ip a 2>/dev/null | grep -w 'inet' | awk '{print $2}' | grep -vE '^127.0.0' | sed 's|/.*||g' | head -n1 | grep '^' || echo '127.0.0.1'; }
__find_file_relative() { find "$1"/* -not -path '*env/*' -not -path '.git*' -type f 2>/dev/null | sed 's|'$1'/||g' | sort -u | grep -v '^$' | grep '^' || false; }
@ -265,8 +265,8 @@ __cron() {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__replace() {
[ $# -eq 3 ] && [ -e "$3" ] || return 1
grep -s -qFR -- "$1" "$3" &>/dev/null && __sed "$1" "$2" "$3" || return 0
grep -s -qFR -- "$2" "$3" && printf '%s\n' "Changed $1 to $2 in $3" && return 0 || {
grep -s -qR -- "$1" "$3" &>/dev/null && __sed "$1" "$2" "$3" || return 0
grep -s -qR -- "$2" "$3" && printf '%s\n' "Changed $1 to $2 in $3" && return 0 || {
printf '%s\n' "Failed to change $1 in $3" >&2 && return 2
}
}
@ -323,7 +323,9 @@ __file_copy() {
__generate_random_uids() {
local set_random_uid="$(seq 3000 50000 | sort -R | head -n 1)"
while :; do
if ! grep -qs "x:.*:$set_random_uid:" "/etc/group" && ! grep -sq "x:$set_random_uid:.*:" "/etc/passwd"; then
if grep -qs "x:.*:$set_random_uid:" "/etc/group" && ! grep -sq "x:$set_random_uid:.*:" "/etc/passwd"; then
set_random_uid=$((set_random_uid + 1))
else
echo "$set_random_uid"
break
fi
@ -649,6 +651,7 @@ __initialize_replace_variables() {
__find_replace "REPLACE_WWW_USER" "${SERVICE_USER:-${RUNAS_USER:-root}}" "$set_dir"
__find_replace "REPLACE_APP_GROUP" "${SERVICE_GROUP:-${SERVICE_USER:-${RUNAS_USER:-root}}}" "$set_dir"
__find_replace "REPLACE_WWW_GROUP" "${SERVICE_GROUP:-${SERVICE_USER:-${RUNAS_USER:-root}}}" "$set_dir"
__find_replace "REPLACE_SERVICE_USER" "${SERVICE_USER:-${RUNAS_USER:-root}}" "$set_dir"
[ -n "$SERVICE_PORT" ] && __find_replace "REPLACE_SERVER_PORT" "${SERVICE_PORT:-80}" "$set_dir"
[ -n "$HOSTNAME" ] && __find_replace "REPLACE_SERVER_NAME" "${FULL_DOMAIN_NAME:-$HOSTNAME}" "$set_dir"
[ -n "$CONTAINER_NAME" ] && __find_replace "REPLACE_SERVER_SOFTWARE" "${CONTAINER_NAME:-docker}" "$set_dir"