optimize backrest

This commit is contained in:
CanbiZ 2025-05-27 16:14:34 +02:00
parent 8f69e39e02
commit 849c43f85a
3 changed files with 25 additions and 12 deletions

View File

@ -34,18 +34,23 @@ function update_script() {
msg_ok "Stopped ${APP}"
msg_info "Updating ${APP} to ${RELEASE}"
cd /opt/backrest/bin
curl -fsSL "https://github.com/garethgeorge/backrest/releases/download/v${RELEASE}/backrest_Linux_x86_64.tar.gz" -o "backrest_Linux_x86_64.tar.gz"
tar -xzf backrest_Linux_x86_64.tar.gz
rm -rf backrest_Linux_x86_64.tar.gz
rm -f install.sh uninstall.sh
chmod +x backrest
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 zxf "$temp_file" --strip-components=1 -C /opt/backrest/bin
chmod +x /opt/backrest/bin/backrest
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated ${APP} to ${RELEASE}"
msg_info "Starting ${APP}"
systemctl start backrest
msg_ok "Started ${APP}"
msg_info "Cleaning up"
rm -f "$temp_file"
apt-get -y autoremove
apt-get -y autoclean
msg_ok "Cleaned up"
msg_ok "Updated Successfully"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"

View File

@ -15,11 +15,11 @@ 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}
cd /opt/backrest/bin
curl -fsSL "https://github.com/garethgeorge/backrest/releases/download/v${RELEASE}/backrest_Linux_x86_64.tar.gz" -o "backrest_Linux_x86_64.tar.gz"
tar -xzf backrest_Linux_x86_64.tar.gz
chmod +x backrest
curl -fsSL "https://github.com/garethgeorge/backrest/releases/download/v${RELEASE}/backrest_Linux_x86_64.tar.gz" -o "$temp_file"
tar zxf "$temp_file" --strip-components=1 -C /opt/backrest/bin
chmod +x /opt/backrest/bin/backrest
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
msg_ok "Installed Backrest"
@ -48,8 +48,7 @@ motd_ssh
customize
msg_info "Cleaning up"
rm -f "$temp_file"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
rm -rf backrest_Linux_x86_64.tar.gz
rm -f install.sh uninstall.sh
msg_ok "Cleaned"

View File

@ -32,6 +32,15 @@ install_node_and_modules() {
NEED_NODE_INSTALL=true
fi
if ! command -v jq &>/dev/null; then
$STD msg_info "Installing jq..."
$STD apt-get update -qq &>/dev/null
$STD apt-get install -y jq &>/dev/null || {
msg_error "Failed to install jq"
return 1
}
fi
# Install Node.js if required
if [[ "$NEED_NODE_INSTALL" == true ]]; then
$STD apt-get purge -y nodejs