Skip to content

Commit 34da666

Browse files
authored
Refactor: Autobrr (#6302)
* Refactor * Update * Update autobrr.sh
1 parent 5a889d8 commit 34da666

2 files changed

Lines changed: 29 additions & 25 deletions

File tree

ct/autobrr.sh

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,24 @@ function update_script() {
2727
msg_error "No ${APP} Installation Found!"
2828
exit
2929
fi
30-
msg_info "Stopping ${APP} LXC"
31-
systemctl stop autobrr.service
32-
msg_ok "Stopped ${APP} LXC"
33-
34-
msg_info "Updating ${APP} LXC"
35-
rm -rf /usr/local/bin/*
36-
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)")
37-
tar -C /usr/local/bin -xzf autobrr*.tar.gz
38-
rm -rf autobrr*.tar.gz
39-
msg_ok "Updated ${APP} LXC"
40-
41-
msg_info "Starting ${APP} LXC"
42-
systemctl start autobrr.service
43-
msg_ok "Started ${APP} LXC"
44-
msg_ok "Updated Successfully"
45-
exit
30+
31+
RELEASE=$(curl -fsSL https://api.github.com/repos/autobrr/autobrr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
32+
if [[ "${RELEASE}" != "$(cat ~/.autobrr 2>/dev/null)" ]] || [[ ! -f ~/.autobrr ]]; then
33+
msg_info "Stopping ${APP} LXC"
34+
systemctl stop autobrr
35+
msg_ok "Stopped ${APP} LXC"
36+
37+
fetch_and_deploy_gh_release "autobrr" "autobrr/autobrr" "prebuild" "latest" "/usr/local/bin" "autobrr_*_linux_x86_64.tar.gz"
38+
39+
msg_info "Starting ${APP} LXC"
40+
systemctl start autobrr
41+
msg_ok "Started ${APP} LXC"
42+
43+
msg_ok "Updated Successfully"
44+
else
45+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
46+
fi
47+
exit
4648
}
4749

4850
start

install/autobrr-install.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ setting_up_container
1313
network_check
1414
update_os
1515

16-
msg_info "Installing Autobrr"
17-
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)")
18-
tar -C /usr/local/bin -xzf autobrr*.tar.gz
19-
rm -rf autobrr*.tar.gz
16+
fetch_and_deploy_gh_release "autobrr" "autobrr/autobrr" "prebuild" "latest" "/usr/local/bin" "autobrr_*_linux_x86_64.tar.gz"
17+
18+
msg_info "Configuring Autobrr"
2019
mkdir -p /root/.config/autobrr
2120
cat <<EOF >>/root/.config/autobrr/config.toml
2221
# https://autobrr.com/configuration/autobrr
@@ -25,21 +24,24 @@ port = 7474
2524
logLevel = "DEBUG"
2625
sessionSecret = "$(openssl rand -base64 24)"
2726
EOF
28-
msg_ok "Installed Autobrr"
27+
msg_ok "Configured Autobrr"
2928

3029
msg_info "Creating Service"
31-
service_path="/etc/systemd/system/autobrr.service"
32-
echo "[Unit]
30+
cat <<EOF >/etc/systemd/system/autobrr.service
31+
[Unit]
3332
Description=autobrr service
3433
After=syslog.target network-online.target
34+
3535
[Service]
3636
Type=simple
3737
User=root
3838
Group=root
3939
ExecStart=/usr/local/bin/autobrr --config=/root/.config/autobrr/
40+
4041
[Install]
41-
WantedBy=multi-user.target" >$service_path
42-
systemctl enable --now -q autobrr.service
42+
WantedBy=multi-user.target
43+
EOF
44+
systemctl enable --now -q autobrr
4345
msg_ok "Created Service"
4446

4547
motd_ssh

0 commit comments

Comments
 (0)