🗃️ Committing everything that changed 🗃️

.claude/
Dockerfile
rootfs/usr/local/bin/entrypoint.sh
rootfs/usr/local/etc/docker/functions/entrypoint.sh
rootfs/usr/local/etc/docker/init.d/01-lenpaste.sh
This commit is contained in:
casjay
2025-09-11 03:31:30 -04:00
parent 549a3b8e06
commit 5eabfa3a71
5 changed files with 63 additions and 46 deletions

View File

@@ -0,0 +1,17 @@
{
"permissions": {
"allow": [
"WebFetch(domain:github.com)",
"WebFetch(domain:paste.lcomrade.su)",
"Bash(docker build:*)",
"Bash(docker run:*)",
"Bash(docker logs:*)",
"Bash(curl:*)",
"Bash(docker exec:*)",
"Bash(docker stop:*)",
"Bash(docker search:*)"
],
"deny": [],
"ask": []
}
}

View File

@@ -24,12 +24,12 @@ ARG IMAGE_REPO="casjaysdevdocker/lenpaste"
ARG IMAGE_VERSION="latest" ARG IMAGE_VERSION="latest"
ARG CONTAINER_VERSION="" ARG CONTAINER_VERSION=""
ARG PULL_URL="casjaysdev/alpine" ARG PULL_URL="casjaysdev/debian"
ARG DISTRO_VERSION="${IMAGE_VERSION}" ARG DISTRO_VERSION="${IMAGE_VERSION}"
ARG BUILD_VERSION="${BUILD_DATE}" ARG BUILD_VERSION="${BUILD_DATE}"
FROM tianon/gosu:latest AS gosu FROM tianon/gosu:latest AS gosu
FROM ghcr.io/lcomrade/lenpaste:${LENPATE_VERSION:-1.3.1} AS lenpaste FROM ghcr.io/lcomrade/lenpaste:${LENPASTE_VERSION:-1.3.1} AS lenpaste
FROM ${PULL_URL}:${DISTRO_VERSION} AS build FROM ${PULL_URL}:${DISTRO_VERSION} AS build
ARG TZ ARG TZ
ARG USER ARG USER

View File

@@ -460,7 +460,7 @@ ports)
# show running processes # show running processes
procs) procs)
shift 1 shift 1
ps="$(__ps axco command | grep -vE 'COMMAND|grep|ps' | sort -u || grep '^' || echo '')" ps="$(__ps axco command | grep -avE 'COMMAND|grep|ps' | sort -u || grep -a '^' || echo '')"
[ -n "$ps" ] && printf '%s\n%s\n' "Found the following processes" "$ps" | tr '\n' ' ' [ -n "$ps" ] && printf '%s\n%s\n' "Found the following processes" "$ps" | tr '\n' ' '
exit $? exit $?
;; ;;

View File

@@ -39,26 +39,26 @@ __printf_space() {
} }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__rm() { [ -n "$1" ] && [ -e "$1" ] && rm -Rf "${1:?}"; } __rm() { [ -n "$1" ] && [ -e "$1" ] && rm -Rf "${1:?}"; }
__grep_test() { grep -sh "$1" "$2" | grep -qwF "${3:-$1}" || return 1; } __grep_test() { grep -ash "$1" "$2" | grep -aqwF "${3:-$1}" || return 1; }
__netstat() { [ -f "$(type -P netstat)" ] && netstat "$@" || return 10; } __netstat() { [ -f "$(type -P netstat)" ] && netstat "$@" || return 10; }
__cd() { { [ -d "$1" ] || mkdir -p "$1"; } && builtin cd "$1" || return 1; } __cd() { { [ -d "$1" ] || mkdir -p "$1"; } && builtin cd "$1" || return 1; }
__is_in_file() { [ -e "$2" ] && grep -Rsq "$1" "$2" && return 0 || return 1; } __is_in_file() { [ -e "$2" ] && grep -aRsq "$1" "$2" && return 0 || return 1; }
__curl() { curl -q -sfI --max-time 3 -k -o /dev/null "$@" &>/dev/null || return 10; } __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; } __find() { find "$1" -mindepth 1 -type ${2:-f,d} 2>/dev/null | grep '^' || return 10; }
__pcheck() { [ -n "$(which pgrep 2>/dev/null)" ] && pgrep -o "$1$" &>/dev/null || return 10; } __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; } __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; } __sed() { sed -i 's|'$1'|'$2'|g' "$3" &>/dev/null || sed -i "s|$1|$2|g" "$3" &>/dev/null || return 1; }
__pgrep() { __pcheck "${1:-SERVICE_NAME}" || __ps "${1:-$SERVICE_NAME}" | grep -qv ' grep' || return 10; } __pgrep() { __pcheck "${1:-SERVICE_NAME}" || __ps "${1:-$SERVICE_NAME}" | grep -av ' grep' || return 10; }
__ps() { [ -f "$(type -P ps)" ] && ps "$@" 2>/dev/null | sed 's|:||g' | grep -Fw " ${1:-$SERVICE_NAME}$" || return 10; } __ps() { [ -f "$(type -P ps)" ] && ps "$@" 2>/dev/null | sed 's|:||g' | grep -aFw " ${1:-$SERVICE_NAME}$" || return 10; }
__is_dir_empty() { if [ -n "$1" ]; then [ "$(ls -A "$1" 2>/dev/null | wc -l)" -eq 0 ] && return 0 || return 1; else return 1; fi; } __is_dir_empty() { if [ -n "$1" ]; then [ "$(ls -A "$1" 2>/dev/null | wc -l)" -eq 0 ] && return 0 || return 1; else return 1; fi; }
__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_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'; } __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; } __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; }
__find_directory_relative() { find "$1"/* -not -path '*env/*' -not -path '.git*' -type d 2>/dev/null | sed 's|'$1'/||g' | sort -u | grep -v '^$' | grep '^' || false; } __find_directory_relative() { find "$1"/* -not -path '*env/*' -not -path '.git*' -type d 2>/dev/null | sed 's|'$1'/||g' | sort -u | grep -v '^$' | grep '^' || false; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__pid_exists() { ps -ax --no-header | sed 's/^[[:space:]]*//g' | awk -F' ' '{print $1}' | sed 's|:||g' | grep '[0-9]' | sort -uV | grep "^$1$" && return 0 || return 1; } __pid_exists() { ps -ax --no-header | sed 's/^[[:space:]]*//g' | awk -F' ' '{print $1}' | sed 's|:||g' | grep -a '[0-9]' | sort -uV | grep -a "^$1$" && return 0 || return 1; }
__is_running() { ps -eo args --no-header | awk '{print $1,$2,$3}' | sed 's|:||g' | sort -u | grep -vE 'grep|COMMAND|awk|tee|ps|sed|sort|tail' | grep "$1" | grep -q "${2:-^}" && return 0 || return 1; } __is_running() { ps -eo args --no-header | awk '{print $1,$2,$3}' | sed 's|:||g' | sort -u | grep -avE 'grep|COMMAND|awk|tee|ps|sed|sort|tail' | grep -a "$1" | grep -aq "${2:-^}" && return 0 || return 1; }
__get_pid() { ps -ax --no-header | sed 's/^[[:space:]]*//g;s|;||g;s|:||g' | awk '{print $1,$5}' | sed 's|:||g' | grep "$1$" | grep -v 'grep' | awk -F' ' '{print $1}' | grep '[0-9]' | sort -uV | head -n1 | grep '^' && return 0 || return 1; } __get_pid() { ps -ax --no-header | sed 's/^[[:space:]]*//g;s|;||g;s|:||g' | awk '{print $1,$5}' | sed 's|:||g' | grep -a "$1$" | grep -av 'grep' | awk -F' ' '{print $1}' | grep -a '[0-9]' | sort -uV | head -n1 | grep -a '^' && return 0 || return 1; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__format_variables() { printf '%s\n' "${@//,/ }" | tr ' ' '\n' | sort -RVu | grep -v '^$' | tr '\n' ' ' | __clean_variables | grep '^' || return 3; } __format_variables() { printf '%s\n' "${@//,/ }" | tr ' ' '\n' | sort -RVu | grep -v '^$' | tr '\n' ' ' | __clean_variables | grep '^' || return 3; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@@ -146,7 +146,7 @@ user_pass="${LENPASTE_USER_PASS_WORD:-}" # normal user password
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Additional variables # Additional variables
LENPASTE_ADDRESS="${LENPASTE_ADDRESS:-}" # ADDRESS:PORT for HTTP server. LENPASTE_ADDRESS="${LENPASTE_ADDRESS:-:$SERVICE_PORT}" # ADDRESS:PORT for HTTP server.
DATABASE_DIR="${DATABASE_DIR:-/data/db/sqlite}" # Database location DATABASE_DIR="${DATABASE_DIR:-/data/db/sqlite}" # Database location
LENPASTE_DB_DRIVER="${LENPASTE_DB_DRIVER:-sqlite3}" # Currently supported drivers: 'sqlite3' and 'postgres'. LENPASTE_DB_DRIVER="${LENPASTE_DB_DRIVER:-sqlite3}" # Currently supported drivers: 'sqlite3' and 'postgres'.
LENPASTE_DB_SOURCE="${LENPASTE_DB_SOURCE:-$DATABASE_DIR}" # DB source. LENPASTE_DB_SOURCE="${LENPASTE_DB_SOURCE:-$DATABASE_DIR}" # DB source.
@@ -164,7 +164,7 @@ LENPASTE_NEW_PASTES_PER_5MIN="${LENPASTE_NEW_PASTES_PER_5MIN:-15}" # Maximu
LENPASTE_NEW_PASTES_PER_15MIN="${LENPASTE_NEW_PASTES_PER_15MIN:-30}" # Maximum number of pastes that can be CREATED in 15 minutes from one IP. If 0 disable rate-limit. LENPASTE_NEW_PASTES_PER_15MIN="${LENPASTE_NEW_PASTES_PER_15MIN:-30}" # Maximum number of pastes that can be CREATED in 15 minutes from one IP. If 0 disable rate-limit.
LENPASTE_NEW_PASTES_PER_1HOUR="${LENPASTE_NEW_PASTES_PER_1HOUR:-40}" # Maximum number of pastes that can be CREATED in 1 hour from one IP. If 0 disable rate-limit. LENPASTE_NEW_PASTES_PER_1HOUR="${LENPASTE_NEW_PASTES_PER_1HOUR:-40}" # Maximum number of pastes that can be CREATED in 1 hour from one IP. If 0 disable rate-limit.
LENPASTE_ADMIN_NAME="${LENPASTE_ADMIN_NAME:-}" # Name of the administrator of this server. LENPASTE_ADMIN_NAME="${LENPASTE_ADMIN_NAME:-}" # Name of the administrator of this server.
LENPASTE_ADMIN_NAME="${LENPASTE_ADMIN_NAME:-}" # Email of the administrator of this server. LENPASTE_ADMIN_MAIL="${LENPASTE_ADMIN_MAIL:-}" # Email of the administrator of this server.
LENPASTE_UI_DEFAULT_LIFETIME="${LENPASTE_UI_DEFAULT_LIFETIME:--1}" # Lifetime of paste will be set by default in WEB interface. Examples: 10min, 1h, 1d, 2w, 6mon, 1y. LENPASTE_UI_DEFAULT_LIFETIME="${LENPASTE_UI_DEFAULT_LIFETIME:--1}" # Lifetime of paste will be set by default in WEB interface. Examples: 10min, 1h, 1d, 2w, 6mon, 1y.
LENPASTE_UI_DEFAULT_THEME="${LENPASTE_UI_DEFAULT_THEME:-dark}" # Sets the default theme for the WEB interface. Examples: dark, light. LENPASTE_UI_DEFAULT_THEME="${LENPASTE_UI_DEFAULT_THEME:-dark}" # Sets the default theme for the WEB interface. Examples: dark, light.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -184,7 +184,7 @@ ADDITIONAL_CONFIG_DIRS=""
CMD_ENV="" CMD_ENV=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Overwrite based on file/directory # Overwrite based on file/directory
if ! echo "$LENPASTE_ADDRESS" | grep -q ':[0-9][0-9]'; then if ! echo "$LENPASTE_ADDRESS" | grep -aq ':[0-9][0-9]'; then
LENPASTE_ADDRESS="${LENPASTE_ADDRESS:-$HOSTNAME}:$SERVICE_PORT" LENPASTE_ADDRESS="${LENPASTE_ADDRESS:-$HOSTNAME}:$SERVICE_PORT"
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -246,86 +246,86 @@ __update_conf_files() {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# define actions # define actions
if [ -n "$LENPASTE_ADDRESS" ]; then if [ -n "$LENPASTE_ADDRESS" ]; then
RUN_CMD+="-address $LENPASTE_ADDRESS," RUN_CMD+="-address $LENPASTE_ADDRESS "
fi fi
[ -d "$DATA_DIR/html" ] || mkdir -p "$DATA_DIR/html" [ -d "$DATA_DIR/html" ] || mkdir -p "$DATA_DIR/html"
if [ -f "/config/secure/auth/root/lenpasswd" ]; then if [ -f "/config/secure/auth/root/lenpasswd" ]; then
RUN_CMD+="-lenpasswd-file /config/secure/auth/root/lenpasswd," RUN_CMD+="-lenpasswd-file /config/secure/auth/root/lenpasswd "
fi fi
if [ "$LENPASTE_DB_DRIVER" = "postgres" ]; then if [ "$LENPASTE_DB_DRIVER" = "postgres" ]; then
RUN_CMD+="-db-driver postgres," RUN_CMD+="-db-driver postgres "
elif [ "$LENPASTE_DB_DRIVER" = "" ] || [ "$LENPASTE_DB_DRIVER" = "sqlite" ] || [ "$LENPASTE_DB_DRIVER" = "sqlite3" ]; then elif [ "$LENPASTE_DB_DRIVER" = "" ] || [ "$LENPASTE_DB_DRIVER" = "sqlite" ] || [ "$LENPASTE_DB_DRIVER" = "sqlite3" ]; then
RUN_CMD+="-db-driver sqlite3," RUN_CMD+="-db-driver sqlite3 "
fi fi
if [ -z "$LENPASTE_DB_DRIVER" ] || [ "$LENPASTE_DB_DRIVER" = "sqlite3" ]; then if [ -z "$LENPASTE_DB_DRIVER" ] || [ "$LENPASTE_DB_DRIVER" = "sqlite3" ]; then
RUN_CMD+="-db-source ${DATABASE_SQLITE_FILE:-/data/lenpaste/database.db}," RUN_CMD+="-db-source ${DATABASE_SQLITE_FILE:-/data/lenpaste/database.db} "
else else
RUN_CMD+="-db-source $LENPASTE_DB_SOURCE," RUN_CMD+="-db-source $LENPASTE_DB_SOURCE "
fi fi
if [ -n "$LENPASTE_DB_MAX_OPEN_CONNS" ]; then if [ -n "$LENPASTE_DB_MAX_OPEN_CONNS" ]; then
RUN_CMD+="-db-max-open-conns $LENPASTE_DB_MAX_OPEN_CONNS," RUN_CMD+="-db-max-open-conns $LENPASTE_DB_MAX_OPEN_CONNS "
fi fi
if [ -n "$LENPASTE_DB_MAX_IDLE_CONNS" ]; then if [ -n "$LENPASTE_DB_MAX_IDLE_CONNS" ]; then
RUN_CMD+="-db-max-idle-conns $LENPASTE_DB_MAX_IDLE_CONNS," RUN_CMD+="-db-max-idle-conns $LENPASTE_DB_MAX_IDLE_CONNS "
fi fi
if [ -n "$LENPASTE_DB_CLEANUP_PERIOD" ]; then if [ -n "$LENPASTE_DB_CLEANUP_PERIOD" ]; then
RUN_CMD+="-db-cleanup-period $LENPASTE_DB_CLEANUP_PERIOD," RUN_CMD+="-db-cleanup-period $LENPASTE_DB_CLEANUP_PERIOD "
fi fi
if [ "$LENPASTE_ROBOTS_DISALLOW" = "true" ]; then if [ "$LENPASTE_ROBOTS_DISALLOW" = "true" ]; then
RUN_CMD+="-robots-disallow," RUN_CMD+="-robots-disallow "
fi fi
if [ -n "$LENPASTE_TITLE_MAX_LENGTH" ]; then if [ -n "$LENPASTE_TITLE_MAX_LENGTH" ]; then
RUN_CMD+="-title-max-length $LENPASTE_TITLE_MAX_LENGTH," RUN_CMD+="-title-max-length $LENPASTE_TITLE_MAX_LENGTH "
fi fi
if [ -n "$LENPASTE_BODY_MAX_LENGTH" ]; then if [ -n "$LENPASTE_BODY_MAX_LENGTH" ]; then
RUN_CMD+="-body-max-length $LENPASTE_BODY_MAX_LENGTH," RUN_CMD+="-body-max-length $LENPASTE_BODY_MAX_LENGTH "
fi fi
if [ -n "$LENPASTE_MAX_PASTE_LIFETIME" ]; then if [ -n "$LENPASTE_MAX_PASTE_LIFETIME" ]; then
RUN_CMD+="-max-paste-lifetime $LENPASTE_MAX_PASTE_LIFETIME," RUN_CMD+="-max-paste-lifetime $LENPASTE_MAX_PASTE_LIFETIME "
fi fi
if [ -n "$LENPASTE_GET_PASTES_PER_5MIN" ]; then if [ -n "$LENPASTE_GET_PASTES_PER_5MIN" ]; then
RUN_CMD+="-get-pastes-per-5min $LENPASTE_GET_PASTES_PER_5MIN," RUN_CMD+="-get-pastes-per-5min $LENPASTE_GET_PASTES_PER_5MIN "
fi fi
if [ -n "$LENPASTE_GET_PASTES_PER_15MIN" ]; then if [ -n "$LENPASTE_GET_PASTES_PER_15MIN" ]; then
RUN_CMD+="-get-pastes-per-15min $LENPASTE_GET_PASTES_PER_15MIN," RUN_CMD+="-get-pastes-per-15min $LENPASTE_GET_PASTES_PER_15MIN "
fi fi
if [ -n "$LENPASTE_GET_PASTES_PER_1HOUR" ]; then if [ -n "$LENPASTE_GET_PASTES_PER_1HOUR" ]; then
RUN_CMD+="-get-pastes-per-1hour $LENPASTE_GET_PASTES_PER_1HOUR," RUN_CMD+="-get-pastes-per-1hour $LENPASTE_GET_PASTES_PER_1HOUR "
fi fi
if [ -n "$LENPASTE_NEW_PASTES_PER_5MIN" ]; then if [ -n "$LENPASTE_NEW_PASTES_PER_5MIN" ]; then
RUN_CMD+="-new-pastes-per-5min $LENPASTE_NEW_PASTES_PER_5MIN," RUN_CMD+="-new-pastes-per-5min $LENPASTE_NEW_PASTES_PER_5MIN "
fi fi
if [ -n "$LENPASTE_NEW_PASTES_PER_15MIN" ]; then if [ -n "$LENPASTE_NEW_PASTES_PER_15MIN" ]; then
RUN_CMD+="-new-pastes-per-15min $LENPASTE_NEW_PASTES_PER_15MIN," RUN_CMD+="-new-pastes-per-15min $LENPASTE_NEW_PASTES_PER_15MIN "
fi fi
if [ -n "$LENPASTE_NEW_PASTES_PER_1HOUR" ]; then if [ -n "$LENPASTE_NEW_PASTES_PER_1HOUR" ]; then
RUN_CMD+="-new-pastes-per-1hour $LENPASTE_NEW_PASTES_PER_1HOUR," RUN_CMD+="-new-pastes-per-1hour $LENPASTE_NEW_PASTES_PER_1HOUR "
fi fi
if [ -n "$LENPASTE_ADMIN_NAME" ]; then if [ -n "$LENPASTE_ADMIN_NAME" ]; then
RUN_CMD+="-admin-name \"$LENPASTE_ADMIN_NAME\"," RUN_CMD+="-admin-name $LENPASTE_ADMIN_NAME "
fi fi
if [ -n "$LENPASTE_ADMIN_MAIL" ]; then if [ -n "$LENPASTE_ADMIN_MAIL" ]; then
RUN_CMD+="-admin-mail $LENPASTE_ADMIN_MAIL," RUN_CMD+="-admin-mail $LENPASTE_ADMIN_MAIL "
fi fi
if [ -n "$LENPASTE_UI_DEFAULT_LIFETIME" ]; then if [ -n "$LENPASTE_UI_DEFAULT_LIFETIME" ]; then
RUN_CMD+="-ui-default-lifetime $LENPASTE_UI_DEFAULT_LIFETIME," RUN_CMD+="-ui-default-lifetime $LENPASTE_UI_DEFAULT_LIFETIME "
fi fi
if [ -n "$LENPASTE_UI_DEFAULT_THEME" ]; then if [ -n "$LENPASTE_UI_DEFAULT_THEME" ]; then
RUN_CMD+="-ui-default-theme $LENPASTE_UI_DEFAULT_THEME," RUN_CMD+="-ui-default-theme $LENPASTE_UI_DEFAULT_THEME "
fi fi
if [ -f "/data/lenpaste/html/about" ]; then if [ -f "/data/lenpaste/html/about" ]; then
RUN_CMD+="-server-about /data/lenpaste/html/about," RUN_CMD+="-server-about /data/lenpaste/html/about "
fi fi
if [ -f "/data/lenpaste/html/rules" ]; then if [ -f "/data/lenpaste/html/rules" ]; then
RUN_CMD+="-server-rules /data/lenpaste/html/rules," RUN_CMD+="-server-rules /data/lenpaste/html/rules "
fi fi
if [ -f "/data/lenpaste/html/terms" ]; then if [ -f "/data/lenpaste/html/terms" ]; then
RUN_CMD+="-server-terms /data/lenpaste/html/terms," RUN_CMD+="-server-terms /data/lenpaste/html/terms "
fi fi
if [ -d "/data/lenpaste/html/themes" ]; then if [ -d "/data/lenpaste/html/themes" ]; then
RUN_CMD+="-ui-themes-dir /data/lenpaste/html/themes," RUN_CMD+="-ui-themes-dir /data/lenpaste/html/themes "
fi fi
LENPASTE_RUN_COMMANDS="${RUN_CMD//,/ }" LENPASTE_RUN_COMMANDS="$RUN_CMD"
# exit function # exit function
return $exitCode return $exitCode
} }
@@ -387,7 +387,7 @@ __post_execute() {
) 2>"/dev/stderr" | tee -p -a "$LOG_DIR/init.txt" & ) 2>"/dev/stderr" | tee -p -a "$LOG_DIR/init.txt" &
pid=$! pid=$!
# set exitCode # set exitCode
ps ax | awk '{print $1}' | grep -v grep | grep -q "$execPid$" && retVal=0 || retVal=10 ps ax | awk '{print $1}' | grep -av grep | grep -aq "$execPid$" && retVal=0 || retVal=10
return $retVal return $retVal
} }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -491,7 +491,7 @@ __run_start_script() {
__post_execute 2>"/dev/stderr" | tee -p -a "$LOG_DIR/init.txt" & __post_execute 2>"/dev/stderr" | tee -p -a "$LOG_DIR/init.txt" &
if [ "$RESET_ENV" = "yes" ]; then if [ "$RESET_ENV" = "yes" ]; then
env_command="$(echo "env -i HOME=\"$home\" LC_CTYPE=\"$lc_type\" PATH=\"$path\" HOSTNAME=\"$sysname\" USER=\"${SERVICE_USER:-$RUNAS_USER}\" $extra_env")" env_command="$(echo "env -i HOME=\"$home\" LC_CTYPE=\"$lc_type\" PATH=\"$path\" HOSTNAME=\"$sysname\" USER=\"${SERVICE_USER:-$RUNAS_USER}\" $extra_env")"
execute_command="$(__trim "$su_exec $env_command $cmd_exec")" execute_command="$su_exec $env_command $cmd_exec"
if [ ! -f "$START_SCRIPT" ]; then if [ ! -f "$START_SCRIPT" ]; then
cat <<EOF >"$START_SCRIPT" cat <<EOF >"$START_SCRIPT"
#!/usr/bin/env bash #!/usr/bin/env bash
@@ -505,7 +505,7 @@ SERVICE_PID_FILE="$SERVICE_PID_FILE"
$execute_command 2>"/dev/stderr" >>"$LOG_DIR/$SERVICE_NAME.log" & $execute_command 2>"/dev/stderr" >>"$LOG_DIR/$SERVICE_NAME.log" &
execPid=\$! execPid=\$!
sleep 10 sleep 10
checkPID="\$(ps ax | awk '{print \$1}' | grep -v grep | grep "\$execPid$" || false)" checkPID="\$(ps ax | awk '{print \$1}' | grep -av grep | grep -a "\$execPid$" || false)"
[ -n "\$execPid" ] && [ -n "\$checkPID" ] && echo "\$execPid" >"\$SERVICE_PID_FILE" && retVal=0 || retVal=10 [ -n "\$execPid" ] && [ -n "\$checkPID" ] && echo "\$execPid" >"\$SERVICE_PID_FILE" && retVal=0 || retVal=10
[ "\$retVal" = 0 ] && echo "\$cmd has been started" || echo "\$cmd has failed to start - args: $args" >&2 [ "\$retVal" = 0 ] && echo "\$cmd has been started" || echo "\$cmd has failed to start - args: $args" >&2
exit \$retVal exit \$retVal
@@ -514,7 +514,7 @@ EOF
fi fi
else else
if [ ! -f "$START_SCRIPT" ]; then if [ ! -f "$START_SCRIPT" ]; then
execute_command="$(__trim "$su_exec $cmd_exec")" execute_command="$su_exec $cmd_exec"
cat <<EOF >"$START_SCRIPT" cat <<EOF >"$START_SCRIPT"
#!/usr/bin/env bash #!/usr/bin/env bash
trap 'exitCode=\$?;[ \$exitCode -ne 0 ] && [ -f "\$SERVICE_PID_FILE" ] && rm -Rf "\$SERVICE_PID_FILE";exit \$exitCode' EXIT trap 'exitCode=\$?;[ \$exitCode -ne 0 ] && [ -f "\$SERVICE_PID_FILE" ] && rm -Rf "\$SERVICE_PID_FILE";exit \$exitCode' EXIT
@@ -527,7 +527,7 @@ SERVICE_PID_FILE="$SERVICE_PID_FILE"
$execute_command 2>>"/dev/stderr" >>"$LOG_DIR/$SERVICE_NAME.log" & $execute_command 2>>"/dev/stderr" >>"$LOG_DIR/$SERVICE_NAME.log" &
execPid=\$! execPid=\$!
sleep 10 sleep 10
checkPID="\$(ps ax | awk '{print \$1}' | grep -v grep | grep "\$execPid$" || false)" checkPID="\$(ps ax | awk '{print \$1}' | grep -av grep | grep -a "\$execPid$" || false)"
[ -n "\$execPid" ] && [ -n "\$checkPID" ] && echo "\$execPid" >"\$SERVICE_PID_FILE" && retVal=0 || retVal=10 [ -n "\$execPid" ] && [ -n "\$checkPID" ] && echo "\$execPid" >"\$SERVICE_PID_FILE" && retVal=0 || retVal=10
[ "\$retVal" = 0 ] && echo "\$cmd has been started" || echo "\$cmd has failed to start - args: $args" >&2 [ "\$retVal" = 0 ] && echo "\$cmd has been started" || echo "\$cmd has failed to start - args: $args" >&2
exit \$retVal exit \$retVal