Skip to content

Commit 4182815

Browse files
FileBrowser Quantum: safer update (tmp download + atomic replace + arch autodetect) (#7174)
* FileBrowser Quantum: safer update (tmp download + atomic replace + arch autodetect) **What** Safer updater for FileBrowser Quantum addon: - Download to temp file, then atomic `mv` into INSTALL_PATH - Stop/start service around the swap - CPU arch autodetect (amd64/arm64/armv7/armv6) - Proper error handling & version verification before printing success **Why** Current update streams `curl` directly to `/usr/local/bin/filebrowser` and prints success even if `curl` fails. I hit: * fix(filebrowser-quantum): add missing `fi` before install section Closes the conditional started with `if [[ -f "$INSTALL_PATH" ]]` so the script doesn’t hit a bash syntax error when reaching the install path. * refactor(update): minimal fix - temp file + atomic mv; amd64 only * style(update): remove comments/blank lines; drop restart (alpine-safe)
1 parent 73a0910 commit 4182815

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

tools/addon/filebrowser-quantum.sh

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -97,31 +97,41 @@ if [[ -f "$LEGACY_DB" || -f "$LEGACY_BIN" && ! -f "$CONFIG_PATH" ]]; then
9797
fi
9898

9999
# 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"
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
113117
fi
114-
rm -f "$INSTALL_PATH" "$CONFIG_PATH"
115-
msg_ok "${APP} has been uninstalled."
116-
exit 0
117-
fi
118-
119-
echo -n "Update ${APP}? (y/N): "
120-
read -r update_prompt
118+
119+
echo -n "Update ${APP}? (y/N): "
120+
read -r update_prompt
121121
if [[ "${update_prompt,,}" =~ ^(y|yes)$ ]]; then
122122
msg_info "Updating ${APP}"
123-
curl -fsSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o "$INSTALL_PATH"
124-
chmod +x "$INSTALL_PATH"
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
125135
msg_ok "Updated ${APP}"
126136
exit 0
127137
else

0 commit comments

Comments
 (0)