From 2304f9fd8f87fb18c80a5897312d8906a6c8b0e4 Mon Sep 17 00:00:00 2001 From: casjay Date: Thu, 16 Mar 2023 01:04:48 -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 | 10 +++++----- rootfs/usr/local/etc/docker/functions/entrypoint.sh | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/rootfs/usr/local/bin/entrypoint.sh b/rootfs/usr/local/bin/entrypoint.sh index 5897892..55d58f2 100755 --- a/rootfs/usr/local/bin/entrypoint.sh +++ b/rootfs/usr/local/bin/entrypoint.sh @@ -195,7 +195,7 @@ if [ -n "$DEFAULT_TEMPLATE_DIR" ]; then create_template_name="$(basename "$create_config_template")" if [ -d "$create_config_template" ]; then mkdir -p "/config/$create_template_name/" - [ -e "/config/$create_template_name" ] || cp -Rf "$create_config_template/." "/config/$create_template_name/" 2>/dev/null + __is_dir_empty "/config/$create_template_name" || cp -Rf "$create_config_template/." "/config/$create_template_name/" 2>/dev/null elif [ -e "$create_config_template" ]; then [ -e "/config/$create_template_name" ] || cp -Rf "$create_config_template" "/config/$create_template_name" 2>/dev/null fi @@ -214,7 +214,7 @@ if [ -n "$DEFAULT_CONF_DIR" ]; then if [ -n "$create_config_template" ]; then if [ -d "$create_config_template" ]; then mkdir -p "/config/$create_config_name" - [ -e "/config/$create_config_name" ] || cp -Rf "$create_config_template/." "/config/$create_config_name/" 2>/dev/null + __is_dir_empty "/config/$create_config_name" || cp -Rf "$create_config_template/." "/config/$create_config_name/" 2>/dev/null elif [ -e "$create_config_template" ]; then [ -e "/config/$create_config_name" ] || cp -Rf "$create_config_template" "/config/$create_config_name" 2>/dev/null fi @@ -233,7 +233,7 @@ if [ -d "/data" ]; then if [ -n "$create_data_template" ]; then if [ -d "$create_data_template" ]; then mkdir -p "/data/$create_data_name" - [ -e "/data/$create_data_name" ] || cp -Rf "$create_data_template/." "/data/$create_data_name/" 2>/dev/null + __is_dir_empty "/data/$create_data_name" || cp -Rf "$create_data_template/." "/data/$create_data_name/" 2>/dev/null elif [ -e "$create_data_template" ]; then [ -e "/data/$create_data_name" ] || cp -Rf "$create_data_template" "/data/$create_data_name" 2>/dev/null fi @@ -265,14 +265,14 @@ fi # Copy html files if [ "$DATA_DIR_INITIALIZED" = "false" ] && [ -n "$WWW_ROOT_DIR" ]; then if [ -d "$DEFAULT_DATA_DIR/data/htdocs" ]; then - [ "$(ls -A "$WWW_ROOT_DIR/" 2>/dev/null | wc -l)" -ne 0 ] || cp -Rf "$DEFAULT_DATA_DIR/data/htdocs/." "$WWW_ROOT_DIR/" 2>/dev/null + __is_dir_empty "$WWW_ROOT_DIR/" || cp -Rf "$DEFAULT_DATA_DIR/data/htdocs/." "$WWW_ROOT_DIR/" 2>/dev/null fi fi if [ -n "$WWW_ROOT_DIR" ]; then if [ -d "$DEFAULT_DATA_DIR/htdocs/www" ] && [ ! -d "$WWW_ROOT_DIR" ]; then mkdir -p "$WWW_ROOT_DIR" cp -Rf "$DEFAULT_DATA_DIR/htdocs/www/" "$WWW_ROOT_DIR" - [ -f "$WWW_ROOT_DIR/htdocs/www/server-health" ] || echo "OK" >"$WWW_ROOT_DIR/htdocs/www/server-health" + [ -f "$WWW_ROOT_DIR/htdocs/www/health/index.txt" ] || echo "OK" >"$WWW_ROOT_DIR/htdocs/www/health/index.txt" fi fi # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/rootfs/usr/local/etc/docker/functions/entrypoint.sh b/rootfs/usr/local/etc/docker/functions/entrypoint.sh index 55fbd40..66d833a 100644 --- a/rootfs/usr/local/etc/docker/functions/entrypoint.sh +++ b/rootfs/usr/local/etc/docker/functions/entrypoint.sh @@ -5,6 +5,7 @@ __rm() { [ -f "$1" ] && rm -Rf "${1:?}"; } __cd() { [ -d "$1" ] && builtin cd "$1" || return 1; } __netstat() { [ -f "$(type -P netstat)" ] && netstat "$@" || return 10; } +__is_dir_empty() { [ "$(ls -A "$1" 2>/dev/null | wc -l)" -ne 0 ] || return 1; } __curl() { curl -q -sfI --max-time 3 -k -o /dev/null "$@" &>/dev/null || return 10; } __find() { find "$1" -mindepth 1 -type ${2:-f,d} 2>/dev/null | grep '^' || return 10; } __no_exit() { exec /bin/sh -c "trap : TERM INT; (while true; do tail -qf /data/logs/entrypoint.log /data/logs/*/*log 2>/dev/null||sleep 20; done) & wait"; }