This commit is contained in:
Slaviša Arežina 2025-07-09 07:42:06 +02:00 committed by GitHub
parent e856b36306
commit 4f569c67eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 23 deletions

View File

@ -29,35 +29,29 @@ function update_script() {
exit exit
fi fi
RELEASE=$(curl -s https://api.github.com/repos/TwiN/gatus/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') RELEASE=$(curl -s https://api.github.com/repos/TwiN/gatus/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then if [[ "${RELEASE}" != "$(cat ~/.gatus 2>/dev/null)" ]] || [[ ! -f ~/.gatus ]]; then
msg_info "Updating $APP" msg_info "Updating $APP"
msg_info "Stopping $APP" msg_info "Stopping $APP"
systemctl stop gatus systemctl stop gatus
msg_ok "Stopped $APP" msg_ok "Stopped $APP"
msg_info "Updating $APP to v${RELEASE}"
mv /opt/gatus/config/config.yaml /opt mv /opt/gatus/config/config.yaml /opt
rm -rf /opt/gatus/* rm -rf /opt/gatus
temp_file=$(mktemp) fetch_and_deploy_gh_release "gatus" "TwiN/gatus"
curl -fsSL "https://github.com/TwiN/gatus/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
tar zxf "$temp_file" --strip-components=1 -C /opt/gatus msg_info "Updating $APP to v${RELEASE}"
cd /opt/gatus cd /opt/gatus
$STD go mod tidy $STD go mod tidy
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gatus . CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gatus .
setcap CAP_NET_RAW+ep gatus setcap CAP_NET_RAW+ep gatus
mv /opt/config.yaml config mv /opt/config.yaml config
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated $APP to v${RELEASE}" msg_ok "Updated $APP to v${RELEASE}"
msg_info "Starting $APP" msg_info "Starting $APP"
systemctl start gatus systemctl start gatus
msg_ok "Started $APP" msg_ok "Started $APP"
msg_info "Cleaning Up"
rm -f "$temp_file"
msg_ok "Cleanup Completed"
msg_ok "Update Successful" msg_ok "Update Successful"
else else
msg_ok "No update required. ${APP} is already at v${RELEASE}" msg_ok "No update required. ${APP} is already at v${RELEASE}"

View File

@ -20,20 +20,15 @@ $STD apt-get install -y \
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
setup_go setup_go
fetch_and_deploy_gh_release "gatus" "TwiN/gatus"
RELEASE=$(curl -s https://api.github.com/repos/TwiN/gatus/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') msg_info "Configuring gatus"
msg_info "Setting up gatus v${RELEASE}"
temp_file=$(mktemp)
mkdir -p /opt/gatus
curl -fsSL "https://github.com/TwiN/gatus/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
tar zxf "$temp_file" --strip-components=1 -C /opt/gatus
cd /opt/gatus cd /opt/gatus
$STD go mod tidy $STD go mod tidy
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gatus . CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gatus .
setcap CAP_NET_RAW+ep gatus setcap CAP_NET_RAW+ep gatus
mv config.yaml config mv config.yaml config
echo "${RELEASE}" >/opt/gatus_version.txt msg_ok "Configured gatus"
msg_ok "Done setting up gatus"
msg_info "Creating Service" msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/gatus.service cat <<EOF >/etc/systemd/system/gatus.service
@ -58,10 +53,6 @@ motd_ssh
customize customize
msg_info "Cleaning up" msg_info "Cleaning up"
rm -f "$temp_file"
$STD apt-get -y autoremove $STD apt-get -y autoremove
$STD apt-get -y autoclean $STD apt-get -y autoclean
msg_ok "Cleaned" msg_ok "Cleaned"
motd_ssh
customize