From 235a87fedca9353e12362119a4d6e0c284b4430c Mon Sep 17 00:00:00 2001 From: casjay Date: Sun, 3 Sep 2023 22:30:58 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Committing=20everything?= =?UTF-8?q?=20that=20changed=20=F0=9F=97=83=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rootfs/usr/local/bin/entrypoint.sh rootfs/usr/local/etc/docker/functions/entrypoint.sh --- rootfs/usr/local/bin/entrypoint.sh | 4 ++-- rootfs/usr/local/etc/docker/functions/entrypoint.sh | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/rootfs/usr/local/bin/entrypoint.sh b/rootfs/usr/local/bin/entrypoint.sh index 55f8ab1..b845aab 100755 --- a/rootfs/usr/local/bin/entrypoint.sh +++ b/rootfs/usr/local/bin/entrypoint.sh @@ -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 diff --git a/rootfs/usr/local/etc/docker/functions/entrypoint.sh b/rootfs/usr/local/etc/docker/functions/entrypoint.sh index 67feac5..b34cf72 100755 --- a/rootfs/usr/local/etc/docker/functions/entrypoint.sh +++ b/rootfs/usr/local/etc/docker/functions/entrypoint.sh @@ -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"