mirror of
https://github.com/okxlin/appstore.git
synced 2026-09-24 16:01:02 +00:00
Rebuilt-from-PR: #6488 Source-PR: #6488 Maintainer-workflow: appstore-pr-maintainer - Consolidate fixed rotator variants onto one numeric version line. - Add ALLOW_NO_AUTH form/env handling and preserve existing upgrade values. - Pin the fixed MicroWARP image to the verified multi-architecture digest. - Keep the rolling aliases and HTTP/rotator variants. Runtime evidence: - 1Panel upgrade smoke: rotator-latest -> 0.3.1-rotator: passed - 1Panel upgrade smoke: rotator-http-latest -> 0.3.1-rotator-http: passed - Upgrade compatibility cases: missing/0/1 ALLOW_NO_AUTH and idempotent rerun: passed - YAML, shell, Compose, and repository Renovate tests: passed Residual security review: - Candidate fixed image scan: Critical=1, High=12; baseline 0.2.0 scan: Critical=0, High=0. - This accepted-risk update is disclosed in the app README; deployment should be restricted and the upstream image monitored. - Existing strict validator app_data_dir diagnostics are present in the unchanged baseline scripts and were not introduced here.
69 lines
1.7 KiB
Bash
69 lines
1.7 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(CDPATH="" cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
|
|
APP_ROOT="${APP_ROOT:-$(CDPATH="" cd -- "${SCRIPT_DIR}/.." && pwd -P)}"
|
|
ENV_FILE="${ENV_FILE:-${APP_ROOT}/.env}"
|
|
|
|
if [[ "${ENV_FILE}" != /* ]]; then
|
|
ENV_FILE="${APP_ROOT}/${ENV_FILE#./}"
|
|
fi
|
|
|
|
strip_matching_quotes() {
|
|
local value="$1"
|
|
|
|
case "${value}" in
|
|
\"*\")
|
|
value="${value#\"}"
|
|
value="${value%\"}"
|
|
;;
|
|
\'*\')
|
|
value="${value#\'}"
|
|
value="${value%\'}"
|
|
;;
|
|
esac
|
|
printf '%s\n' "${value}"
|
|
}
|
|
|
|
ensure_allow_no_auth() {
|
|
local current temp_file
|
|
|
|
current="${ALLOW_NO_AUTH:-}"
|
|
if [[ -z "${current}" && -f "${ENV_FILE}" ]]; then
|
|
current="$(sed -n 's/^ALLOW_NO_AUTH=//p' "${ENV_FILE}" | tail -n 1)"
|
|
current="$(strip_matching_quotes "${current}")"
|
|
fi
|
|
[[ -n "${current}" || ! -f "${ENV_FILE}" ]] && return 0
|
|
|
|
temp_file="$(mktemp "${ENV_FILE}.upgrade.XXXXXX")"
|
|
awk '
|
|
BEGIN { updated = 0 }
|
|
/^ALLOW_NO_AUTH=/ {
|
|
if (!updated) {
|
|
print "ALLOW_NO_AUTH=1"
|
|
updated = 1
|
|
}
|
|
next
|
|
}
|
|
{ print }
|
|
END { if (!updated) print "ALLOW_NO_AUTH=1" }
|
|
' "${ENV_FILE}" >"${temp_file}"
|
|
chmod --reference="${ENV_FILE}" "${temp_file}" 2>/dev/null || chmod 0600 "${temp_file}"
|
|
mv -f -- "${temp_file}" "${ENV_FILE}"
|
|
}
|
|
|
|
ensure_allow_no_auth
|
|
|
|
app_data_dir="${APP_DATA_DIR_1:-}"
|
|
if [[ -z "${app_data_dir}" && -f "${ENV_FILE}" ]]; then
|
|
app_data_dir="$(sed -n 's/^APP_DATA_DIR_1=//p' "${ENV_FILE}" | tail -n 1)"
|
|
fi
|
|
app_data_dir="$(strip_matching_quotes "${app_data_dir}")"
|
|
app_data_dir="${app_data_dir:-./data}"
|
|
if [[ "${app_data_dir}" != /* ]]; then
|
|
app_data_dir="${APP_ROOT}/${app_data_dir#./}"
|
|
fi
|
|
|
|
mkdir -p "${app_data_dir}"
|
|
exit 0
|