Skip to content

Commit 4f569c6

Browse files
authored
Refactor (#5849)
1 parent e856b36 commit 4f569c6

File tree

2 files changed

+8
-23
lines changed

2 files changed

+8
-23
lines changed

ct/gatus.sh

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,35 +29,29 @@ function update_script() {
2929
exit
3030
fi
3131
RELEASE=$(curl -s https://api.github.com/repos/TwiN/gatus/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
32-
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
32+
if [[ "${RELEASE}" != "$(cat ~/.gatus 2>/dev/null)" ]] || [[ ! -f ~/.gatus ]]; then
3333
msg_info "Updating $APP"
3434

3535
msg_info "Stopping $APP"
3636
systemctl stop gatus
3737
msg_ok "Stopped $APP"
3838

39-
msg_info "Updating $APP to v${RELEASE}"
4039
mv /opt/gatus/config/config.yaml /opt
41-
rm -rf /opt/gatus/*
42-
temp_file=$(mktemp)
43-
curl -fsSL "https://github.com/TwiN/gatus/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
44-
tar zxf "$temp_file" --strip-components=1 -C /opt/gatus
40+
rm -rf /opt/gatus
41+
fetch_and_deploy_gh_release "gatus" "TwiN/gatus"
42+
43+
msg_info "Updating $APP to v${RELEASE}"
4544
cd /opt/gatus
4645
$STD go mod tidy
4746
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gatus .
4847
setcap CAP_NET_RAW+ep gatus
4948
mv /opt/config.yaml config
50-
echo "${RELEASE}" >/opt/${APP}_version.txt
5149
msg_ok "Updated $APP to v${RELEASE}"
5250

5351
msg_info "Starting $APP"
5452
systemctl start gatus
5553
msg_ok "Started $APP"
5654

57-
msg_info "Cleaning Up"
58-
rm -f "$temp_file"
59-
msg_ok "Cleanup Completed"
60-
6155
msg_ok "Update Successful"
6256
else
6357
msg_ok "No update required. ${APP} is already at v${RELEASE}"

install/gatus-install.sh

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,15 @@ $STD apt-get install -y \
2020
msg_ok "Installed Dependencies"
2121

2222
setup_go
23+
fetch_and_deploy_gh_release "gatus" "TwiN/gatus"
2324

24-
RELEASE=$(curl -s https://api.github.com/repos/TwiN/gatus/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
25-
msg_info "Setting up gatus v${RELEASE}"
26-
temp_file=$(mktemp)
27-
mkdir -p /opt/gatus
28-
curl -fsSL "https://github.com/TwiN/gatus/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
29-
tar zxf "$temp_file" --strip-components=1 -C /opt/gatus
25+
msg_info "Configuring gatus"
3026
cd /opt/gatus
3127
$STD go mod tidy
3228
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gatus .
3329
setcap CAP_NET_RAW+ep gatus
3430
mv config.yaml config
35-
echo "${RELEASE}" >/opt/gatus_version.txt
36-
msg_ok "Done setting up gatus"
31+
msg_ok "Configured gatus"
3732

3833
msg_info "Creating Service"
3934
cat <<EOF >/etc/systemd/system/gatus.service
@@ -58,10 +53,6 @@ motd_ssh
5853
customize
5954

6055
msg_info "Cleaning up"
61-
rm -f "$temp_file"
6256
$STD apt-get -y autoremove
6357
$STD apt-get -y autoclean
6458
msg_ok "Cleaned"
65-
66-
motd_ssh
67-
customize

0 commit comments

Comments
 (0)