diff --git a/apps/filerise/3.43.0/.env.sample b/apps/filerise/3.43.0/.env.sample new file mode 100644 index 000000000..19f7fba54 --- /dev/null +++ b/apps/filerise/3.43.0/.env.sample @@ -0,0 +1,7 @@ +CONTAINER_NAME=filerise-compose-check +PANEL_APP_BIND_ADDRESS=127.0.0.1 +PANEL_APP_PORT_HTTP=8080 +APP_DATA_DIR=./data +FILERISE_TIMEZONE=UTC +FILERISE_TOTAL_UPLOAD_SIZE=5G +FILERISE_SECURE=false diff --git a/apps/filerise/3.43.0/data.yml b/apps/filerise/3.43.0/data.yml new file mode 100644 index 000000000..6aa413f45 --- /dev/null +++ b/apps/filerise/3.43.0/data.yml @@ -0,0 +1,104 @@ +additionalProperties: + formFields: + - default: 127.0.0.1 + edit: true + envKey: PANEL_APP_BIND_ADDRESS + labelEn: Bind Address + labelZh: 绑定地址 + label: + en: Bind Address + zh: 绑定地址 + zh-Hant: 綁定位址 + ja: バインドアドレス + ko: 바인드 주소 + ru: Адрес привязки + ms: Alamat ikatan + pt-br: Endereco de vinculacao + required: true + type: text + - default: 8080 + 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 + 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: Diretorio de dados + required: true + type: text + - default: UTC + edit: true + envKey: FILERISE_TIMEZONE + labelEn: Timezone + labelZh: 时区 + label: + en: Timezone + zh: 时区 + zh-Hant: 時區 + ja: タイムゾーン + ko: 시간대 + ru: Часовой пояс + ms: Zon waktu + pt-br: Fuso horario + required: true + type: text + - default: 5G + edit: true + envKey: FILERISE_TOTAL_UPLOAD_SIZE + labelEn: Upload Size Limit + labelZh: 上传大小限制 + label: + en: Upload Size Limit + zh: 上传大小限制 + zh-Hant: 上傳大小限制 + ja: アップロードサイズ上限 + ko: 업로드 크기 제한 + ru: Ограничение размера загрузки + ms: Had saiz muat naik + pt-br: Limite de tamanho de upload + required: true + type: text + - default: "false" + edit: true + envKey: FILERISE_SECURE + labelEn: Secure Cookie + labelZh: 安全 Cookie + label: + en: Secure Cookie + zh: 安全 Cookie + zh-Hant: 安全 Cookie + ja: セキュア Cookie + ko: 보안 Cookie + ru: Защищенные Cookie + ms: Cookie selamat + pt-br: Cookie seguro + required: true + type: select + values: + - label: "false" + value: "false" + - label: "true" + value: "true" diff --git a/apps/filerise/3.43.0/docker-compose.yml b/apps/filerise/3.43.0/docker-compose.yml new file mode 100644 index 000000000..9d9c181a4 --- /dev/null +++ b/apps/filerise/3.43.0/docker-compose.yml @@ -0,0 +1,36 @@ +services: + filerise: + image: "error311/filerise-docker:v3.43.0" + container_name: ${CONTAINER_NAME} + restart: unless-stopped + networks: + - 1panel-network + ports: + - "${PANEL_APP_BIND_ADDRESS}:${PANEL_APP_PORT_HTTP}:80" + environment: + TIMEZONE: "${FILERISE_TIMEZONE}" + TOTAL_UPLOAD_SIZE: "${FILERISE_TOTAL_UPLOAD_SIZE}" + SECURE: "${FILERISE_SECURE}" + PUID: "1000" + PGID: "1000" + CHOWN_ON_START: "false" + SCAN_ON_START: "true" + CLAMAV_AUTO_UPDATE: "false" + volumes: + - "${APP_DATA_DIR}/uploads:/var/www/uploads" + - "${APP_DATA_DIR}/users:/var/www/users" + - "${APP_DATA_DIR}/metadata:/var/www/metadata" + healthcheck: + test: ["CMD-SHELL", "curl -fsS http://localhost/ || exit 1"] + interval: 30s + timeout: 5s + retries: 5 + start_period: 30s + security_opt: + - no-new-privileges:true + labels: + createdBy: "Apps" + +networks: + 1panel-network: + external: true diff --git a/apps/filerise/3.43.0/scripts/init.sh b/apps/filerise/3.43.0/scripts/init.sh new file mode 100755 index 000000000..ecef59ed3 --- /dev/null +++ b/apps/filerise/3.43.0/scripts/init.sh @@ -0,0 +1,117 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" +ENV_FILE="${ENV_FILE:-${ROOT_DIR}/.env}" +FILERISE_UID=1000 +FILERISE_GID=1000 + +fail() { + printf '%s\n' "$1" >&2 + exit 1 +} + +read_env_value() { + local key="$1" + 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" +} + +reject_symlink_components() { + local path="$1" + local current="" + local component + IFS='/' read -r -a components <<< "${path#/}" + for component in "${components[@]}"; do + [[ -n "$component" ]] || continue + current="${current}/${component}" + [[ ! -L "$current" ]] || fail "APP_DATA_DIR must not contain symbolic-link components" + done +} + +[[ -f "$ENV_FILE" ]] || fail "$ENV_FILE not found" +[[ ! -L "$ENV_FILE" ]] || fail "$ENV_FILE must not be a symbolic link" + +bind_address="$(read_env_value PANEL_APP_BIND_ADDRESS)" +[[ "$bind_address" =~ ^[0-9]{1,3}(\.[0-9]{1,3}){3}$ ]] || fail "PANEL_APP_BIND_ADDRESS must be an IPv4 address" +IFS=. read -r octet1 octet2 octet3 octet4 <<< "$bind_address" +for octet in "$octet1" "$octet2" "$octet3" "$octet4"; do + ((10#$octet <= 255)) || fail "PANEL_APP_BIND_ADDRESS contains an invalid IPv4 octet" +done + +port="$(read_env_value PANEL_APP_PORT_HTTP)" +[[ "$port" =~ ^[0-9]+$ ]] || fail "PANEL_APP_PORT_HTTP must be numeric" +((10#$port >= 1 && 10#$port <= 65535)) || fail "PANEL_APP_PORT_HTTP must be between 1 and 65535" + +timezone="$(read_env_value FILERISE_TIMEZONE)" +[[ "$timezone" =~ ^[A-Za-z0-9_+/-]+$ ]] || fail "FILERISE_TIMEZONE is invalid" + +upload_size="$(read_env_value FILERISE_TOTAL_UPLOAD_SIZE)" +[[ "$upload_size" =~ ^[1-9][0-9]*[KMGkmg]?$ ]] || fail "FILERISE_TOTAL_UPLOAD_SIZE must be a positive integer with an optional K, M, or G suffix" + +secure="$(read_env_value FILERISE_SECURE)" +[[ "$secure" == "true" || "$secure" == "false" ]] || fail "FILERISE_SECURE must be true or false" + +data_raw="${APP_DATA_DIR:-$(read_env_value APP_DATA_DIR)}" +[[ -n "$data_raw" ]] || fail "APP_DATA_DIR must not be empty" +case "$data_raw" in + \"*\") data_raw="${data_raw#\"}"; data_raw="${data_raw%\"}" ;; + \'*\') data_raw="${data_raw#\'}"; data_raw="${data_raw%\'}" ;; +esac +[[ -n "$data_raw" ]] || fail "APP_DATA_DIR must not be empty" +[[ "$data_raw" =~ ^[A-Za-z0-9._/\ -]+$ ]] || fail "APP_DATA_DIR contains unsupported characters" + +if [[ "$data_raw" == /* ]]; then + data_candidate="$data_raw" + data_scope="absolute" +else + data_candidate="${ROOT_DIR}/${data_raw#./}" + data_scope="application" +fi + +reject_symlink_components "$data_candidate" +data_dir="$(realpath -m -- "$data_candidate")" +[[ "$data_dir" != "/" ]] || fail "APP_DATA_DIR must not be the filesystem root" +if [[ "$data_scope" == "application" ]]; then + case "$data_dir" in + "${ROOT_DIR}"/*) ;; + *) fail "Relative APP_DATA_DIR must stay inside the application version directory" ;; + esac +fi +[[ ! -e "$data_dir" || -d "$data_dir" ]] || fail "APP_DATA_DIR must be a directory" + +data_existed=false +[[ -d "$data_dir" ]] && data_existed=true + +if [[ "$data_scope" == "absolute" && "$data_existed" == "true" ]]; then + unexpected_owner="$(find "$data_dir" -xdev \( ! -uid "$FILERISE_UID" -o ! -gid "$FILERISE_GID" \) -print -quit)" + [[ -z "$unexpected_owner" ]] || fail "Existing absolute APP_DATA_DIR tree must be owned by ${FILERISE_UID}:${FILERISE_GID}" +fi + +for path in "$data_dir" "$data_dir/uploads" "$data_dir/users" "$data_dir/metadata"; do + [[ ! -L "$path" ]] || fail "$path must not be a symbolic link" + [[ ! -e "$path" || -d "$path" ]] || fail "$path must be a directory" +done + +install -d -m 0750 -o "$FILERISE_UID" -g "$FILERISE_GID" -- \ + "$data_dir" "$data_dir/uploads" "$data_dir/users" "$data_dir/metadata" + +resolved_data_dir="$(realpath -e -- "$data_dir")" +[[ "$resolved_data_dir" == "$data_dir" ]] || fail "APP_DATA_DIR changed while it was being prepared" +if [[ "$data_scope" == "application" ]]; then + case "$resolved_data_dir" in + "${ROOT_DIR}"/*) ;; + *) fail "APP_DATA_DIR resolves outside the application version directory" ;; + esac +fi + +if [[ "$data_scope" == "application" || "$data_existed" == "false" ]]; then + chown -R "$FILERISE_UID:$FILERISE_GID" -- "$data_dir" +fi +chmod 0750 -- "$data_dir" +chmod 0770 -- "$data_dir/uploads" "$data_dir/users" "$data_dir/metadata" diff --git a/apps/filerise/3.43.0/scripts/uninstall.sh b/apps/filerise/3.43.0/scripts/uninstall.sh new file mode 100755 index 000000000..5a3f6bd6b --- /dev/null +++ b/apps/filerise/3.43.0/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/filerise/3.43.0/scripts/upgrade.sh b/apps/filerise/3.43.0/scripts/upgrade.sh new file mode 100755 index 000000000..5ec28d784 --- /dev/null +++ b/apps/filerise/3.43.0/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"