Filebrowser-Quantum: fix initial config to newer version

Refactor message functions for conciseness and clarity. Update installation and update logic for the application.
This commit is contained in:
CanbiZ 2025-10-20 08:41:17 +02:00 committed by GitHub
parent 8fd8bb407e
commit 0d1dceacba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) 2021-2025 community-scripts ORG # Copyright (c) 2021-2025 community-scripts ORG
# Author: Author: MickLesk # Author: MickLesk
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
function header_info() { function header_info() {
@ -53,20 +53,9 @@ fi
header_info header_info
function msg_info() { function msg_info() { echo -e "${INFO} ${YW}$1...${CL}"; }
local msg="$1" function msg_ok() { echo -e "${CM} ${GN}$1${CL}"; }
echo -e "${INFO} ${YW}${msg}...${CL}" function msg_error() { echo -e "${CROSS} ${RD}$1${CL}"; }
}
function msg_ok() {
local msg="$1"
echo -e "${CM} ${GN}${msg}${CL}"
}
function msg_error() {
local msg="$1"
echo -e "${CROSS} ${RD}${msg}${CL}"
}
# Detect legacy FileBrowser installation # Detect legacy FileBrowser installation
LEGACY_DB="/usr/local/community-scripts/filebrowser.db" LEGACY_DB="/usr/local/community-scripts/filebrowser.db"
@ -96,7 +85,7 @@ if [[ -f "$LEGACY_DB" || -f "$LEGACY_BIN" && ! -f "$CONFIG_PATH" ]]; then
fi fi
fi fi
# Check existing installation # Existing installation
if [[ -f "$INSTALL_PATH" ]]; then if [[ -f "$INSTALL_PATH" ]]; then
echo -e "${YW}⚠️ ${APP} is already installed.${CL}" echo -e "${YW}⚠️ ${APP} is already installed.${CL}"
echo -n "Uninstall ${APP}? (y/N): " echo -n "Uninstall ${APP}? (y/N): "
@ -120,18 +109,8 @@ fi
read -r update_prompt read -r update_prompt
if [[ "${update_prompt,,}" =~ ^(y|yes)$ ]]; then if [[ "${update_prompt,,}" =~ ^(y|yes)$ ]]; then
msg_info "Updating ${APP}" msg_info "Updating ${APP}"
tmp="${INSTALL_PATH}.tmp.$$" curl -fsSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o "$INSTALL_PATH"
if ! curl -fSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o "$tmp"; then chmod +x "$INSTALL_PATH"
msg_error "Download failed"
rm -f "$tmp"
exit 1
fi
chmod 0755 "$tmp"
if ! mv -f "$tmp" "$INSTALL_PATH"; then
msg_error "Install failed (cannot move into $INSTALL_PATH)"
rm -f "$tmp"
exit 1
fi
msg_ok "Updated ${APP}" msg_ok "Updated ${APP}"
exit 0 exit 0
else else
@ -147,7 +126,11 @@ PORT=${PORT:-$DEFAULT_PORT}
echo -n "Install ${APP}? (y/n): " echo -n "Install ${APP}? (y/n): "
read -r install_prompt read -r install_prompt
if [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then if ! [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then
echo -e "${YW}⚠️ Installation skipped. Exiting.${CL}"
exit 0
fi
msg_info "Installing ${APP} on ${OS}" msg_info "Installing ${APP} on ${OS}"
$PKG_MANAGER curl ffmpeg &>/dev/null $PKG_MANAGER curl ffmpeg &>/dev/null
curl -fsSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o "$INSTALL_PATH" curl -fsSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o "$INSTALL_PATH"
@ -163,6 +146,7 @@ if [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then
echo -n "Use No Authentication? (y/N): " echo -n "Use No Authentication? (y/N): "
read -r noauth_prompt read -r noauth_prompt
# === YAML CONFIG GENERATION ===
if [[ "${noauth_prompt,,}" =~ ^(y|yes)$ ]]; then if [[ "${noauth_prompt,,}" =~ ^(y|yes)$ ]]; then
cat <<EOF >"$CONFIG_PATH" cat <<EOF >"$CONFIG_PATH"
server: server:
@ -172,14 +156,16 @@ server:
config: config:
disableIndexing: false disableIndexing: false
indexingIntervalMinutes: 240 indexingIntervalMinutes: 240
exclude: conditionals:
folderPaths: ignoreHidden: true
- "/proc" ignoreZeroSizeFolders: true
- "/sys" rules:
- "/dev" - folderPaths: "/proc"
- "/run" - folderPaths: "/sys"
- "/tmp" - folderPaths: "/dev"
- "/lost+found" - folderPaths: "/run"
- folderPaths: "/tmp"
- folderPaths: "/lost+found"
auth: auth:
methods: methods:
noauth: true noauth: true
@ -194,14 +180,16 @@ server:
config: config:
disableIndexing: false disableIndexing: false
indexingIntervalMinutes: 240 indexingIntervalMinutes: 240
exclude: conditionals:
folderPaths: ignoreHidden: true
- "/proc" ignoreZeroSizeFolders: true
- "/sys" rules:
- "/dev" - folderPaths: "/proc"
- "/run" - folderPaths: "/sys"
- "/tmp" - folderPaths: "/dev"
- "/lost+found" - folderPaths: "/run"
- folderPaths: "/tmp"
- folderPaths: "/lost+found"
auth: auth:
adminUsername: admin adminUsername: admin
adminPassword: helper-scripts.com adminPassword: helper-scripts.com
@ -210,7 +198,6 @@ EOF
fi fi
msg_info "Creating service" msg_info "Creating service"
if [[ "$OS" == "Debian" ]]; then if [[ "$OS" == "Debian" ]]; then
cat <<EOF >"$SERVICE_PATH" cat <<EOF >"$SERVICE_PATH"
[Unit] [Unit]
@ -248,7 +235,3 @@ EOF
msg_ok "Service created successfully" msg_ok "Service created successfully"
echo -e "${CM} ${GN}${APP} is reachable at: ${BL}http://$IP:$PORT${CL}" echo -e "${CM} ${GN}${APP} is reachable at: ${BL}http://$IP:$PORT${CL}"
else
echo -e "${YW}⚠️ Installation skipped. Exiting.${CL}"
exit 0
fi