Update filebrowser_quantum.sh
This commit is contained in:
parent
ae7471c92d
commit
cbd34de096
@ -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: tteck (tteckster) | Co-Author: MickLesk
|
# Author: 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 {
|
||||||
@ -25,19 +25,19 @@ CM="${GN}✔️${CL}"
|
|||||||
CROSS="${RD}✖️${CL}"
|
CROSS="${RD}✖️${CL}"
|
||||||
INFO="${BL}ℹ️${CL}"
|
INFO="${BL}ℹ️${CL}"
|
||||||
|
|
||||||
APP="FileBrowser"
|
APP="FileBrowser Quantum"
|
||||||
INSTALL_PATH="/usr/local/bin/filebrowser"
|
INSTALL_PATH="/usr/local/bin/filebrowser"
|
||||||
DB_PATH="/usr/local/community-scripts/filebrowser.db"
|
CONFIG_PATH="/usr/local/community-scripts/config.yaml"
|
||||||
DEFAULT_PORT=8080
|
DEFAULT_PORT=8080
|
||||||
|
SRC_DIR="/srv"
|
||||||
|
|
||||||
# Get first non-loopback IP & Detect primary network interface dynamically
|
# Get primary IP
|
||||||
IFACE=$(ip -4 route | awk '/default/ {print $5; exit}')
|
IFACE=$(ip -4 route | awk '/default/ {print $5; exit}')
|
||||||
IP=$(ip -4 addr show "$IFACE" | awk '/inet / {print $2}' | cut -d/ -f1 | head -n 1)
|
IP=$(ip -4 addr show "$IFACE" | awk '/inet / {print $2}' | cut -d/ -f1 | head -n 1)
|
||||||
|
|
||||||
[[ -z "$IP" ]] && IP=$(hostname -I | awk '{print $1}')
|
[[ -z "$IP" ]] && IP=$(hostname -I | awk '{print $1}')
|
||||||
[[ -z "$IP" ]] && IP="127.0.0.1"
|
[[ -z "$IP" ]] && IP="127.0.0.1"
|
||||||
|
|
||||||
# Detect OS
|
# OS Detection
|
||||||
if [[ -f "/etc/alpine-release" ]]; then
|
if [[ -f "/etc/alpine-release" ]]; then
|
||||||
OS="Alpine"
|
OS="Alpine"
|
||||||
SERVICE_PATH="/etc/init.d/filebrowser"
|
SERVICE_PATH="/etc/init.d/filebrowser"
|
||||||
@ -67,10 +67,10 @@ function msg_error() {
|
|||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -e "${CROSS} ${RD}${msg}${CL}"
|
echo -e "${CROSS} ${RD}${msg}${CL}"
|
||||||
}
|
}
|
||||||
|
# Check 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}"
|
||||||
read -r -p "Would you like to uninstall ${APP}? (y/N): " uninstall_prompt
|
read -r -p "Uninstall ${APP}? (y/N): " uninstall_prompt
|
||||||
if [[ "${uninstall_prompt,,}" =~ ^(y|yes)$ ]]; then
|
if [[ "${uninstall_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||||
msg_info "Uninstalling ${APP}"
|
msg_info "Uninstalling ${APP}"
|
||||||
if [[ "$OS" == "Debian" ]]; then
|
if [[ "$OS" == "Debian" ]]; then
|
||||||
@ -81,15 +81,15 @@ if [ -f "$INSTALL_PATH" ]; then
|
|||||||
rc-update del filebrowser &>/dev/null
|
rc-update del filebrowser &>/dev/null
|
||||||
rm -f "$SERVICE_PATH"
|
rm -f "$SERVICE_PATH"
|
||||||
fi
|
fi
|
||||||
rm -f "$INSTALL_PATH" "$DB_PATH"
|
rm -f "$INSTALL_PATH" "$CONFIG_PATH"
|
||||||
msg_ok "${APP} has been uninstalled."
|
msg_ok "${APP} has been uninstalled."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
read -r -p "Would you like to update ${APP}? (y/N): " update_prompt
|
read -r -p "Update ${APP}? (y/N): " update_prompt
|
||||||
if [[ "${update_prompt,,}" =~ ^(y|yes)$ ]]; then
|
if [[ "${update_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||||
msg_info "Updating ${APP}"
|
msg_info "Updating ${APP}"
|
||||||
curl -fsSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o /usr/local/bin/filebrowser
|
curl -fsSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o "$INSTALL_PATH"
|
||||||
chmod +x "$INSTALL_PATH"
|
chmod +x "$INSTALL_PATH"
|
||||||
msg_ok "Updated ${APP}"
|
msg_ok "Updated ${APP}"
|
||||||
exit 0
|
exit 0
|
||||||
@ -103,83 +103,85 @@ echo -e "${YW}⚠️ ${APP} is not installed.${CL}"
|
|||||||
read -r -p "Enter port number (Default: ${DEFAULT_PORT}): " PORT
|
read -r -p "Enter port number (Default: ${DEFAULT_PORT}): " PORT
|
||||||
PORT=${PORT:-$DEFAULT_PORT}
|
PORT=${PORT:-$DEFAULT_PORT}
|
||||||
|
|
||||||
read -r -p "Would you like to install ${APP}? (y/n): " install_prompt
|
read -r -p "Install ${APP}? (y/n): " install_prompt
|
||||||
if [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then
|
if [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||||
msg_info "Installing ${APP} on ${OS}"
|
msg_info "Installing ${APP} on ${OS}"
|
||||||
$PKG_MANAGER wget tar curl &>/dev/null
|
$PKG_MANAGER curl ffmpeg &>/dev/null
|
||||||
curl -fsSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o /usr/local/bin/filebrowser
|
curl -fsSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o "$INSTALL_PATH"
|
||||||
chmod +x "$INSTALL_PATH"
|
chmod +x "$INSTALL_PATH"
|
||||||
msg_ok "Installed ${APP}"
|
msg_ok "Installed ${APP}"
|
||||||
|
|
||||||
msg_info "Creating FileBrowser directory"
|
msg_info "Preparing configuration directory"
|
||||||
mkdir -p /usr/local/community-scripts
|
mkdir -p /usr/local/community-scripts
|
||||||
chown root:root /usr/local/community-scripts
|
chown root:root /usr/local/community-scripts
|
||||||
chmod 755 /usr/local/community-scripts
|
chmod 755 /usr/local/community-scripts
|
||||||
touch "$DB_PATH"
|
msg_ok "Directory prepared"
|
||||||
chown root:root "$DB_PATH"
|
|
||||||
chmod 644 "$DB_PATH"
|
|
||||||
msg_ok "Directory created successfully"
|
|
||||||
|
|
||||||
read -r -p "Would you like to use No Authentication? (y/N): " auth_prompt
|
read -r -p "Use No Authentication? (y/N): " noauth_prompt
|
||||||
if [[ "${auth_prompt,,}" =~ ^(y|yes)$ ]]; then
|
|
||||||
msg_info "Configuring No Authentication"
|
if [[ "${noauth_prompt,,}" =~ ^(y|yes)$ ]]; then
|
||||||
cd /usr/local/community-scripts
|
cat <<EOF >"$CONFIG_PATH"
|
||||||
filebrowser config init -a '0.0.0.0' -p "$PORT" -d "$DB_PATH" &>/dev/null
|
server:
|
||||||
filebrowser config set -a '0.0.0.0' -p "$PORT" -d "$DB_PATH" &>/dev/null
|
port: $PORT
|
||||||
filebrowser config init --auth.method=noauth &>/dev/null
|
sources:
|
||||||
filebrowser config set --auth.method=noauth &>/dev/null
|
- path: "$SRC_DIR"
|
||||||
filebrowser users add ID 1 --perm.admin &>/dev/null
|
auth:
|
||||||
msg_ok "No Authentication configured"
|
methods:
|
||||||
|
noauth: true
|
||||||
|
EOF
|
||||||
|
msg_ok "Configured with no authentication"
|
||||||
else
|
else
|
||||||
msg_info "Setting up default authentication"
|
cat <<EOF >"$CONFIG_PATH"
|
||||||
cd /usr/local/community-scripts
|
server:
|
||||||
filebrowser config init -a '0.0.0.0' -p "$PORT" -d "$DB_PATH" &>/dev/null
|
port: $PORT
|
||||||
filebrowser config set -a '0.0.0.0' -p "$PORT" -d "$DB_PATH" &>/dev/null
|
sources:
|
||||||
filebrowser users add admin helper-scripts.com --perm.admin --database "$DB_PATH" &>/dev/null
|
- path: "$SRC_DIR"
|
||||||
msg_ok "Default authentication configured (admin:helper-scripts.com)"
|
auth:
|
||||||
|
adminUsername: admin
|
||||||
|
adminPassword: helper-scripts.com
|
||||||
|
EOF
|
||||||
|
msg_ok "Configured with default admin (admin / helper-scripts.com)"
|
||||||
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]
|
||||||
Description=Filebrowser
|
Description=FileBrowser Quantum
|
||||||
After=network-online.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=root
|
User=root
|
||||||
WorkingDirectory=/usr/local/community-scripts
|
WorkingDirectory=/usr/local/community-scripts
|
||||||
ExecStartPre=/bin/touch /usr/local/community-scripts/filebrowser.db
|
ExecStart=/usr/local/bin/filebrowser -c $CONFIG_PATH
|
||||||
ExecStartPre=/usr/local/bin/filebrowser config set -a "0.0.0.0" -p ${PORT} -d /usr/local/community-scripts/filebrowser.db
|
|
||||||
ExecStart=/usr/local/bin/filebrowser -r / -d /usr/local/community-scripts/filebrowser.db -p ${PORT}
|
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
systemctl enable -q --now filebrowser
|
systemctl enable --now filebrowser &>/dev/null
|
||||||
else
|
else
|
||||||
cat <<EOF >"$SERVICE_PATH"
|
cat <<EOF >"$SERVICE_PATH"
|
||||||
#!/sbin/openrc-run
|
#!/sbin/openrc-run
|
||||||
|
|
||||||
command="/usr/local/bin/filebrowser"
|
command="/usr/local/bin/filebrowser"
|
||||||
command_args="-r / -d $DB_PATH -p $PORT"
|
command_args="-c $CONFIG_PATH"
|
||||||
command_background=true
|
command_background=true
|
||||||
pidfile="/var/run/filebrowser.pid"
|
|
||||||
directory="/usr/local/community-scripts"
|
directory="/usr/local/community-scripts"
|
||||||
|
|
||||||
depend() {
|
depend() {
|
||||||
need net
|
need net
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
chmod +x "$SERVICE_PATH"
|
chmod +x "$SERVICE_PATH"
|
||||||
rc-update add filebrowser default &>/dev/null
|
rc-update add filebrowser default &>/dev/null
|
||||||
rc-service filebrowser start &>/dev/null
|
rc-service filebrowser start &>/dev/null
|
||||||
fi
|
fi
|
||||||
msg_ok "Service created successfully"
|
|
||||||
|
|
||||||
echo -e "${CM} ${GN}${APP} is reachable at: ${BL}http://$IP:$PORT${CL}"
|
msg_ok "Service created successfully"
|
||||||
|
echo -e "${CM} ${GN}${APP} is reachable at: ${BL}http://$IP:$PORT${CL}"
|
||||||
else
|
else
|
||||||
echo -e "${YW}⚠️ Installation skipped. Exiting.${CL}"
|
echo -e "${YW}⚠️ Installation skipped. Exiting.${CL}"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
Loading…
x
Reference in New Issue
Block a user