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)
This commit is contained in:
parent
73a0910239
commit
4182815b4c
@ -97,31 +97,41 @@ if [[ -f "$LEGACY_DB" || -f "$LEGACY_BIN" && ! -f "$CONFIG_PATH" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check existing installation
|
# 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}"
|
||||||
echo -n "Uninstall ${APP}? (y/N): "
|
echo -n "Uninstall ${APP}? (y/N): "
|
||||||
read -r uninstall_prompt
|
read -r 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
|
||||||
systemctl disable --now filebrowser.service &>/dev/null
|
systemctl disable --now filebrowser.service &>/dev/null
|
||||||
rm -f "$SERVICE_PATH"
|
rm -f "$SERVICE_PATH"
|
||||||
else
|
else
|
||||||
rc-service filebrowser stop &>/dev/null
|
rc-service filebrowser stop &>/dev/null
|
||||||
rc-update del filebrowser &>/dev/null
|
rc-update del filebrowser &>/dev/null
|
||||||
rm -f "$SERVICE_PATH"
|
rm -f "$SERVICE_PATH"
|
||||||
|
fi
|
||||||
|
rm -f "$INSTALL_PATH" "$CONFIG_PATH"
|
||||||
|
msg_ok "${APP} has been uninstalled."
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
rm -f "$INSTALL_PATH" "$CONFIG_PATH"
|
|
||||||
msg_ok "${APP} has been uninstalled."
|
echo -n "Update ${APP}? (y/N): "
|
||||||
exit 0
|
read -r update_prompt
|
||||||
fi
|
|
||||||
|
|
||||||
echo -n "Update ${APP}? (y/N): "
|
|
||||||
read -r 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 "$INSTALL_PATH"
|
tmp="${INSTALL_PATH}.tmp.$$"
|
||||||
chmod +x "$INSTALL_PATH"
|
if ! curl -fSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o "$tmp"; then
|
||||||
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user