diff --git a/ct/backrest.sh b/ct/backrest.sh index 05aae23dd..0396901c7 100644 --- a/ct/backrest.sh +++ b/ct/backrest.sh @@ -27,28 +27,18 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - RELEASE=$(curl -fsSL https://api.github.com/repos/garethgeorge/backrest/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') - if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + + if check_for_gh_release "backrest" "garethgeorge/backrest"; then msg_info "Stopping Service" systemctl stop backrest msg_ok "Stopped Service" - msg_info "Updating ${APP} to ${RELEASE}" - temp_file=$(mktemp) - rm -f /opt/backrest/bin/backrest - curl -fsSL "https://github.com/garethgeorge/backrest/releases/download/v${RELEASE}/backrest_Linux_x86_64.tar.gz" -o "$temp_file" - tar xzf $temp_file -C /opt/backrest/bin - chmod +x /opt/backrest/bin/backrest - rm -f "$temp_file" - echo "${RELEASE}" >/opt/${APP}_version.txt - msg_ok "Updated ${APP} to ${RELEASE}" + fetch_and_deploy_gh_release "backrest" "garethgeorge/backrest" "prebuild" "latest" "/opt/backrest/bin" "backrest_Linux_x86_64.tar.gz" msg_info "Starting Service" systemctl start backrest msg_ok "Started Service" msg_ok "Updated successfully!" - else - msg_ok "No update required. ${APP} is already at ${RELEASE}" fi exit } diff --git a/install/backrest-install.sh b/install/backrest-install.sh index 88e834df9..bea0cd2d3 100644 --- a/install/backrest-install.sh +++ b/install/backrest-install.sh @@ -13,16 +13,7 @@ setting_up_container network_check update_os -msg_info "Installing Backrest" -RELEASE=$(curl -fsSL https://api.github.com/repos/garethgeorge/backrest/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') -temp_file=$(mktemp) -mkdir -p /opt/backrest/{bin,config,data} -curl -fsSL "https://github.com/garethgeorge/backrest/releases/download/v${RELEASE}/backrest_Linux_x86_64.tar.gz" -o "$temp_file" -tar xzf $temp_file -C /opt/backrest/bin -chmod +x /opt/backrest/bin/backrest -rm -f "$temp_file" -echo "${RELEASE}" >/opt/${APPLICATION}_version.txt -msg_ok "Installed Backrest" +fetch_and_deploy_gh_release "backrest" "garethgeorge/backrest" "prebuild" "latest" "/opt/backrest/bin" "backrest_Linux_x86_64.tar.gz" msg_info "Creating Service" cat </etc/systemd/system/backrest.service @@ -32,7 +23,6 @@ After=network.target [Service] Type=simple -User=root ExecStart=/opt/backrest/bin/backrest Environment="BACKREST_PORT=9898" Environment="BACKREST_CONFIG=/opt/backrest/config/config.json" @@ -48,4 +38,3 @@ msg_ok "Created Service" motd_ssh customize cleanup_lxc -