From 49ab4cdf7e2edea719f789b444a88f2debdb9c82 Mon Sep 17 00:00:00 2001 From: okxlin <61420215+okxlin@users.noreply.github.com> Date: Sun, 22 Nov 2026 16:00:06 +0800 Subject: [PATCH] Update trailbase to 0.36.2 (#9361) --- apps/trailbase/0.36.2/.env.sample | 3 + apps/trailbase/0.36.2/data.yml | 63 ++++++++++++ apps/trailbase/0.36.2/docker-compose.yml | 31 ++++++ apps/trailbase/0.36.2/scripts/init.sh | 109 +++++++++++++++++++++ apps/trailbase/0.36.2/scripts/uninstall.sh | 8 ++ apps/trailbase/0.36.2/scripts/upgrade.sh | 5 + 6 files changed, 219 insertions(+) create mode 100644 apps/trailbase/0.36.2/.env.sample create mode 100644 apps/trailbase/0.36.2/data.yml create mode 100644 apps/trailbase/0.36.2/docker-compose.yml create mode 100755 apps/trailbase/0.36.2/scripts/init.sh create mode 100755 apps/trailbase/0.36.2/scripts/uninstall.sh create mode 100755 apps/trailbase/0.36.2/scripts/upgrade.sh diff --git a/apps/trailbase/0.36.2/.env.sample b/apps/trailbase/0.36.2/.env.sample new file mode 100644 index 000000000..246be81e6 --- /dev/null +++ b/apps/trailbase/0.36.2/.env.sample @@ -0,0 +1,3 @@ +CONTAINER_NAME=trailbase-compose-check +PANEL_APP_PORT_HTTP=4000 +APP_DATA_DIR=./data diff --git a/apps/trailbase/0.36.2/data.yml b/apps/trailbase/0.36.2/data.yml new file mode 100644 index 000000000..f570f0156 --- /dev/null +++ b/apps/trailbase/0.36.2/data.yml @@ -0,0 +1,63 @@ +additionalProperties: + formFields: + - default: 4000 + edit: true + envKey: PANEL_APP_PORT_HTTP + labelEn: HTTP Port + labelZh: HTTP 端口 + label: + en: HTTP Port + zh: HTTP 端口 + zh-hant: HTTP 連接埠 + ja: HTTP ポート + ko: HTTP 포트 + ru: HTTP-порт + ms: Port HTTP + pt-br: Porta HTTP + tr: HTTP Portu + es-es: Puerto HTTP + fa: پورت HTTP + lo: ພອດ HTTP + required: true + rule: paramPort + type: number + - default: ./data + edit: true + envKey: APP_DATA_DIR + labelEn: Data Directory + labelZh: 数据目录 + label: + en: Data Directory + zh: 数据目录 + zh-hant: 資料目錄 + ja: データディレクトリ + ko: 데이터 디렉터리 + ru: Каталог данных + ms: Direktori Data + pt-br: Diretório de dados + tr: Veri dizini + es-es: Directorio de datos + fa: پوشه داده‌ها + lo: ໄດເຣັກະທໍລີຂໍ້ມູນ + required: true + type: text + - default: Asia/Shanghai + edit: true + envKey: TZ + labelEn: Timezone + labelZh: 时区 + label: + en: Timezone + zh: 时区 + zh-hant: 時區 + ja: タイムゾーン + ko: 시간대 + ru: Часовой пояс + ms: Zon waktu + pt-br: Fuso horário + tr: Dilim saati + es-es: Zona horaria + fa: منطقه زمانی + lo: ເຂດເວລາ + required: true + type: text diff --git a/apps/trailbase/0.36.2/docker-compose.yml b/apps/trailbase/0.36.2/docker-compose.yml new file mode 100644 index 000000000..5e944e9ba --- /dev/null +++ b/apps/trailbase/0.36.2/docker-compose.yml @@ -0,0 +1,31 @@ +services: + trail: + image: "trailbase/trailbase:0.36.2" + container_name: ${CONTAINER_NAME} + restart: unless-stopped + ports: + - "${PANEL_APP_PORT_HTTP}:4000" + environment: + - RUST_BACKTRACE=1 + volumes: + - "${APP_DATA_DIR:-./data}:/app/traildepot" + healthcheck: + test: + - CMD-SHELL + - curl --fail http://localhost:4000/api/healthcheck || exit 1 + interval: 30s + timeout: 5s + retries: 5 + start_period: 15s + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + networks: + - 1panel-network + labels: + createdBy: "Apps" + +networks: + 1panel-network: + external: true diff --git a/apps/trailbase/0.36.2/scripts/init.sh b/apps/trailbase/0.36.2/scripts/init.sh new file mode 100755 index 000000000..3be7c4063 --- /dev/null +++ b/apps/trailbase/0.36.2/scripts/init.sh @@ -0,0 +1,109 @@ +#!/usr/bin/env bash +set -euo pipefail +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +export PATH + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" +ENV_FILE="${ENV_FILE:-$ROOT_DIR/.env}" + +read_env_value() { + local key="$1" + [[ -f "$ENV_FILE" ]] || return 0 + local value + value="$(sed -n "s/^${key}=//p" "$ENV_FILE" | tail -n 1)" + case "$value" in + \"*\") value="${value#\"}"; value="${value%\"}" ;; + \'*\') value="${value#\'}"; value="${value%\'}" ;; + esac + printf '%s\n' "$value" +} + +configured_value() { + local key="$1" + local default_value="$2" + local value + value="${!key:-}" + if [[ -z "$value" ]]; then + value="$(read_env_value "$key")" + fi + printf '%s\n' "${value:-$default_value}" +} + +resolve_app_path() { + local key="$1" + local raw="$2" + local clean candidate resolved current part + local -a parts=() + case "$raw" in + ""|/*|.|..|../*|*/../*|*/..) echo "unsafe ${key} path" >&2; return 1 ;; + esac + if [[ "$raw" =~ [[:cntrl:]] ]]; then + echo "unsafe ${key} path" >&2 + return 1 + fi + clean="${raw#./}" + [[ -n "$clean" ]] || { echo "unsafe ${key} path" >&2; return 1; } + command -v realpath >/dev/null 2>&1 || { echo "realpath is required" >&2; return 1; } + candidate="$ROOT_DIR/$clean" + resolved="$(realpath -m -- "$candidate")" || { echo "unsafe ${key} path" >&2; return 1; } + case "$resolved" in + "$ROOT_DIR"/*) ;; + *) echo "unsafe ${key} path" >&2; return 1 ;; + esac + current="$ROOT_DIR" + IFS='/' read -r -a parts <<< "$clean" + for part in "${parts[@]}"; do + [[ -z "$part" || "$part" == "." ]] && continue + current="$current/$part" + if [[ -L "$current" ]]; then + echo "unsafe ${key} path" >&2 + return 1 + fi + done + printf '%s\n' "$resolved" +} + +resolve_direct_child() { + local key="$1" + local raw="$2" + local clean path + clean="${raw#./}" + if [[ -z "$clean" || "$clean" == */* ]]; then + echo "unsafe ${key} path: lifecycle directories must be direct children of the version root" >&2 + return 1 + fi + path="$(resolve_app_path "$key" "$raw")" + [[ "$path" == "$ROOT_DIR/$clean" ]] || { echo "unsafe ${key} path" >&2; return 1; } + printf '%s\n' "$path" +} + +verify_trusted_root_chain() { + local current owner mode + [[ "$(id -u)" == "0" ]] || { echo "directory ownership initialization must run as root" >&2; return 1; } + command -v stat >/dev/null 2>&1 || { echo "stat is required" >&2; return 1; } + current="$ROOT_DIR" + while [[ "$current" != "/" ]]; do + [[ -d "$current" && ! -L "$current" ]] || { echo "unsafe version root chain: $current" >&2; return 1; } + IFS=':' read -r owner mode < <(stat -c '%u:%a' -- "$current") + [[ "$owner" == "0" ]] || { echo "unsafe version root chain owner: $current" >&2; return 1; } + [[ "$mode" =~ ^[0-7]{3,4}$ ]] || { echo "unsafe version root chain mode: $current" >&2; return 1; } + (( (8#$mode & 0022) == 0 )) || { echo "unsafe version root chain permissions: $current" >&2; return 1; } + current="$(dirname -- "$current")" + done +} + +ensure_dir() { + local key="$1" + local raw + local path + raw="$(configured_value "$key" "$2")" + path="$(resolve_app_path "$key" "$raw")" + mkdir -p -- "$path" + [[ "$(resolve_app_path "$key" "$raw")" == "$path" ]] || { echo "unsafe ${key} path" >&2; return 1; } +} + +ensure_dir "APP_DATA_DIR" "./data" + +APP_DATA_DIR_VALUE="$(configured_value "APP_DATA_DIR" "./data")" +DATA_DIR="$(resolve_app_path "APP_DATA_DIR" "$APP_DATA_DIR_VALUE")" +chown -R 1000:1000 -- "$DATA_DIR" diff --git a/apps/trailbase/0.36.2/scripts/uninstall.sh b/apps/trailbase/0.36.2/scripts/uninstall.sh new file mode 100755 index 000000000..5a3f6bd6b --- /dev/null +++ b/apps/trailbase/0.36.2/scripts/uninstall.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail + +if command -v docker-compose >/dev/null 2>&1; then + docker-compose down --volumes --remove-orphans +else + docker compose down --volumes --remove-orphans +fi diff --git a/apps/trailbase/0.36.2/scripts/upgrade.sh b/apps/trailbase/0.36.2/scripts/upgrade.sh new file mode 100755 index 000000000..5ec28d784 --- /dev/null +++ b/apps/trailbase/0.36.2/scripts/upgrade.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +exec "$SCRIPT_DIR/init.sh"