From 34da66600d88a393a7274e6b452ed4c80d8ae78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Tue, 29 Jul 2025 08:30:32 +0200 Subject: [PATCH] Refactor: Autobrr (#6302) * Refactor * Update * Update autobrr.sh --- ct/autobrr.sh | 30 ++++++++++++++++-------------- install/autobrr-install.sh | 20 +++++++++++--------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/ct/autobrr.sh b/ct/autobrr.sh index 3cb5fad10..35ee681a2 100644 --- a/ct/autobrr.sh +++ b/ct/autobrr.sh @@ -27,22 +27,24 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - msg_info "Stopping ${APP} LXC" - systemctl stop autobrr.service - msg_ok "Stopped ${APP} LXC" - msg_info "Updating ${APP} LXC" - rm -rf /usr/local/bin/* - curl -fsSL "$(curl -fsSL https://api.github.com/repos/autobrr/autobrr/releases/latest | grep download | grep linux_x86_64 | cut -d\" -f4)" -o $(basename "$(curl -fsSL https://api.github.com/repos/autobrr/autobrr/releases/latest | grep download | grep linux_x86_64 | cut -d\" -f4)") - tar -C /usr/local/bin -xzf autobrr*.tar.gz - rm -rf autobrr*.tar.gz - msg_ok "Updated ${APP} LXC" + RELEASE=$(curl -fsSL https://api.github.com/repos/autobrr/autobrr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + if [[ "${RELEASE}" != "$(cat ~/.autobrr 2>/dev/null)" ]] || [[ ! -f ~/.autobrr ]]; then + msg_info "Stopping ${APP} LXC" + systemctl stop autobrr + msg_ok "Stopped ${APP} LXC" - msg_info "Starting ${APP} LXC" - systemctl start autobrr.service - msg_ok "Started ${APP} LXC" - msg_ok "Updated Successfully" - exit + fetch_and_deploy_gh_release "autobrr" "autobrr/autobrr" "prebuild" "latest" "/usr/local/bin" "autobrr_*_linux_x86_64.tar.gz" + + msg_info "Starting ${APP} LXC" + systemctl start autobrr + msg_ok "Started ${APP} LXC" + + msg_ok "Updated Successfully" + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" + fi + exit } start diff --git a/install/autobrr-install.sh b/install/autobrr-install.sh index 06febc839..42f7af37f 100644 --- a/install/autobrr-install.sh +++ b/install/autobrr-install.sh @@ -13,10 +13,9 @@ setting_up_container network_check update_os -msg_info "Installing Autobrr" -curl -fsSL "$(curl -fsSL https://api.github.com/repos/autobrr/autobrr/releases/latest | grep download | grep linux_x86_64 | cut -d\" -f4)" -o $(basename "$(curl -fsSL https://api.github.com/repos/autobrr/autobrr/releases/latest | grep download | grep linux_x86_64 | cut -d\" -f4)") -tar -C /usr/local/bin -xzf autobrr*.tar.gz -rm -rf autobrr*.tar.gz +fetch_and_deploy_gh_release "autobrr" "autobrr/autobrr" "prebuild" "latest" "/usr/local/bin" "autobrr_*_linux_x86_64.tar.gz" + +msg_info "Configuring Autobrr" mkdir -p /root/.config/autobrr cat <>/root/.config/autobrr/config.toml # https://autobrr.com/configuration/autobrr @@ -25,21 +24,24 @@ port = 7474 logLevel = "DEBUG" sessionSecret = "$(openssl rand -base64 24)" EOF -msg_ok "Installed Autobrr" +msg_ok "Configured Autobrr" msg_info "Creating Service" -service_path="/etc/systemd/system/autobrr.service" -echo "[Unit] +cat </etc/systemd/system/autobrr.service +[Unit] Description=autobrr service After=syslog.target network-online.target + [Service] Type=simple User=root Group=root ExecStart=/usr/local/bin/autobrr --config=/root/.config/autobrr/ + [Install] -WantedBy=multi-user.target" >$service_path -systemctl enable --now -q autobrr.service +WantedBy=multi-user.target +EOF +systemctl enable --now -q autobrr msg_ok "Created Service" motd_ssh