11#! /usr/bin/env bash
22
33# Copyright (c) 2021-2025 community-scripts ORG
4- # Author: Author: MickLesk
4+ # Author: MickLesk
55# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
66
77function header_info() {
5353
5454header_info
5555
56- function msg_info() {
57- local msg=" $1 "
58- echo -e " ${INFO} ${YW}${msg} ...${CL} "
59- }
60-
61- function msg_ok() {
62- local msg=" $1 "
63- echo -e " ${CM} ${GN}${msg}${CL} "
64- }
65-
66- function msg_error() {
67- local msg=" $1 "
68- echo -e " ${CROSS} ${RD}${msg}${CL} "
69- }
56+ function msg_info() { echo -e " ${INFO} ${YW} $1 ...${CL} " ; }
57+ function msg_ok() { echo -e " ${CM} ${GN} $1 ${CL} " ; }
58+ function msg_error() { echo -e " ${CROSS} ${RD} $1 ${CL} " ; }
7059
7160# Detect legacy FileBrowser installation
7261LEGACY_DB=" /usr/local/community-scripts/filebrowser.db"
@@ -96,42 +85,32 @@ if [[ -f "$LEGACY_DB" || -f "$LEGACY_BIN" && ! -f "$CONFIG_PATH" ]]; then
9685 fi
9786fi
9887
99- # Check existing installation
100- if [[ -f " $INSTALL_PATH " ]]; then
101- echo -e " ${YW} ⚠️ ${APP} is already installed.${CL} "
102- echo -n " Uninstall ${APP} ? (y/N): "
103- read -r uninstall_prompt
104- if [[ " ${uninstall_prompt,,} " =~ ^(y| yes)$ ]]; then
105- msg_info " Uninstalling ${APP} "
106- if [[ " $OS " == " Debian" ]]; then
107- systemctl disable --now filebrowser.service & > /dev/null
108- rm -f " $SERVICE_PATH "
109- else
110- rc-service filebrowser stop & > /dev/null
111- rc-update del filebrowser & > /dev/null
112- rm -f " $SERVICE_PATH "
113- fi
114- rm -f " $INSTALL_PATH " " $CONFIG_PATH "
115- msg_ok " ${APP} has been uninstalled."
116- exit 0
88+ # Existing installation
89+ if [[ -f " $INSTALL_PATH " ]]; then
90+ echo -e " ${YW} ⚠️ ${APP} is already installed.${CL} "
91+ echo -n " Uninstall ${APP} ? (y/N): "
92+ read -r uninstall_prompt
93+ if [[ " ${uninstall_prompt,,} " =~ ^(y| yes)$ ]]; then
94+ msg_info " Uninstalling ${APP} "
95+ if [[ " $OS " == " Debian" ]]; then
96+ systemctl disable --now filebrowser.service & > /dev/null
97+ rm -f " $SERVICE_PATH "
98+ else
99+ rc-service filebrowser stop & > /dev/null
100+ rc-update del filebrowser & > /dev/null
101+ rm -f " $SERVICE_PATH "
117102 fi
118-
119- echo -n " Update ${APP} ? (y/N): "
120- read -r update_prompt
103+ rm -f " $INSTALL_PATH " " $CONFIG_PATH "
104+ msg_ok " ${APP} has been uninstalled."
105+ exit 0
106+ fi
107+
108+ echo -n " Update ${APP} ? (y/N): "
109+ read -r update_prompt
121110 if [[ " ${update_prompt,,} " =~ ^(y| yes)$ ]]; then
122111 msg_info " Updating ${APP} "
123- tmp=" ${INSTALL_PATH} .tmp.$$ "
124- if ! curl -fSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o " $tmp " ; then
125- msg_error " Download failed"
126- rm -f " $tmp "
127- exit 1
128- fi
129- chmod 0755 " $tmp "
130- if ! mv -f " $tmp " " $INSTALL_PATH " ; then
131- msg_error " Install failed (cannot move into $INSTALL_PATH )"
132- rm -f " $tmp "
133- exit 1
134- fi
112+ curl -fsSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o " $INSTALL_PATH "
113+ chmod +x " $INSTALL_PATH "
135114 msg_ok " Updated ${APP} "
136115 exit 0
137116 else
@@ -147,72 +126,80 @@ PORT=${PORT:-$DEFAULT_PORT}
147126
148127echo -n " Install ${APP} ? (y/n): "
149128read -r install_prompt
150- if [[ " ${install_prompt,,} " =~ ^(y| yes)$ ]]; then
151- msg_info " Installing ${APP} on ${OS} "
152- $PKG_MANAGER curl ffmpeg & > /dev/null
153- curl -fsSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o " $INSTALL_PATH "
154- chmod +x " $INSTALL_PATH "
155- msg_ok " Installed ${APP} "
156-
157- msg_info " Preparing configuration directory"
158- mkdir -p /usr/local/community-scripts
159- chown root:root /usr/local/community-scripts
160- chmod 755 /usr/local/community-scripts
161- msg_ok " Directory prepared"
162-
163- echo -n " Use No Authentication? (y/N): "
164- read -r noauth_prompt
165-
166- if [[ " ${noauth_prompt,,} " =~ ^(y| yes)$ ]]; then
167- cat << EOF >"$CONFIG_PATH "
129+ if ! [[ " ${install_prompt,,} " =~ ^(y| yes)$ ]]; then
130+ echo -e " ${YW} ⚠️ Installation skipped. Exiting.${CL} "
131+ exit 0
132+ fi
133+
134+ msg_info " Installing ${APP} on ${OS} "
135+ $PKG_MANAGER curl ffmpeg & > /dev/null
136+ curl -fsSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o " $INSTALL_PATH "
137+ chmod +x " $INSTALL_PATH "
138+ msg_ok " Installed ${APP} "
139+
140+ msg_info " Preparing configuration directory"
141+ mkdir -p /usr/local/community-scripts
142+ chown root:root /usr/local/community-scripts
143+ chmod 755 /usr/local/community-scripts
144+ msg_ok " Directory prepared"
145+
146+ echo -n " Use No Authentication? (y/N): "
147+ read -r noauth_prompt
148+
149+ # === YAML CONFIG GENERATION ===
150+ if [[ " ${noauth_prompt,,} " =~ ^(y| yes)$ ]]; then
151+ cat << EOF >"$CONFIG_PATH "
168152server:
169153 port: $PORT
170154 sources:
171- - path: "$SRC_DIR "
155+ - path: "$SRC_DIR "
156+ name: "RootFS"
172157 config:
158+ denyByDefault: false
173159 disableIndexing: false
174160 indexingIntervalMinutes: 240
175- exclude :
176- folderPaths :
177- - "/proc"
178- - "/sys"
179- - "/dev"
180- - "/run"
181- - "/tmp"
182- - "/lost+found"
161+ conditionals :
162+ rules :
163+ - neverWatchPath: "/proc"
164+ - neverWatchPath: "/sys"
165+ - neverWatchPath: "/dev"
166+ - neverWatchPath: "/run"
167+ - neverWatchPath: "/tmp"
168+ - neverWatchPath: "/lost+found"
183169auth:
184170 methods:
185171 noauth: true
186172EOF
187- msg_ok " Configured with no authentication"
188- else
189- cat << EOF >"$CONFIG_PATH "
173+ msg_ok " Configured with no authentication"
174+ else
175+ cat << EOF >"$CONFIG_PATH "
190176server:
191177 port: $PORT
192178 sources:
193179 - path: "$SRC_DIR "
180+ name: "RootFS"
194181 config:
182+ denyByDefault: false
195183 disableIndexing: false
196184 indexingIntervalMinutes: 240
197- exclude :
198- folderPaths :
199- - "/proc"
200- - "/sys"
201- - "/dev"
202- - "/run"
203- - "/tmp"
204- - "/lost+found"
185+ conditionals :
186+ rules :
187+ - neverWatchPath: "/proc"
188+ - neverWatchPath: "/sys"
189+ - neverWatchPath: "/dev"
190+ - neverWatchPath: "/run"
191+ - neverWatchPath: "/tmp"
192+ - neverWatchPath: "/lost+found"
205193auth:
206194 adminUsername: admin
207195 adminPassword: helper-scripts.com
208196EOF
209- msg_ok " Configured with default admin (admin / helper-scripts.com)"
210- fi
211-
212- msg_info " Creating service"
197+ msg_ok " Configured with default admin (admin / helper-scripts.com)"
198+ fi
213199
214- if [[ " $OS " == " Debian" ]]; then
215- cat << EOF >"$SERVICE_PATH "
200+ msg_info " Creating service"
201+ if [[ " $OS " == " Debian" ]]; then
202+ cat << EOF >"$SERVICE_PATH "
216203[Unit]
217204Description=FileBrowser Quantum
218205After=network.target
@@ -226,9 +213,9 @@ Restart=always
226213[Install]
227214WantedBy=multi-user.target
228215EOF
229- systemctl enable --now filebrowser & > /dev/null
230- else
231- cat << EOF >"$SERVICE_PATH "
216+ systemctl enable --now filebrowser & > /dev/null
217+ else
218+ cat << EOF >"$SERVICE_PATH "
232219#!/sbin/openrc-run
233220
234221command="/usr/local/bin/filebrowser"
@@ -241,14 +228,10 @@ depend() {
241228 need net
242229}
243230EOF
244- chmod +x " $SERVICE_PATH "
245- rc-update add filebrowser default & > /dev/null
246- rc-service filebrowser start & > /dev/null
247- fi
248-
249- msg_ok " Service created successfully"
250- echo -e " ${CM} ${GN}${APP} is reachable at: ${BL} http://$IP :$PORT ${CL} "
251- else
252- echo -e " ${YW} ⚠️ Installation skipped. Exiting.${CL} "
253- exit 0
231+ chmod +x " $SERVICE_PATH "
232+ rc-update add filebrowser default & > /dev/null
233+ rc-service filebrowser start & > /dev/null
254234fi
235+
236+ msg_ok " Service created successfully"
237+ echo -e " ${CM} ${GN}${APP} is reachable at: ${BL} http://$IP :$PORT ${CL} "
0 commit comments