Skip to content
This repository was archived by the owner on Nov 2, 2024. It is now read-only.

Commit 103ac46

Browse files
authored
Update prometheus.sh
Create update path
1 parent 5fb1be4 commit 103ac46

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

ct/prometheus.sh

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,30 @@ function default_settings() {
5555
function update_script() {
5656
header_info
5757
if [[ ! -f /etc/systemd/system/prometheus.service ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
58-
msg_error "There is currently no update path available."
58+
RELEASE=$(curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
59+
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
60+
msg_info "Stopping ${APP}"
61+
systemctl stop prometheus
62+
msg_ok "Stopped ${APP}"
63+
64+
msg_info "Updating ${APP} to ${RELEASE}"
65+
wget -q https://github.com/prometheus/prometheus/releases/download/v${RELEASE}/prometheus-${RELEASE}.linux-amd64.tar.gz
66+
tar -xf prometheus-${RELEASE}.linux-amd64.tar.gz
67+
cd prometheus-${RELEASE}.linux-amd64
68+
cp -rf prometheus promtool /usr/local/bin/
69+
cp -rf consoles/ console_libraries/ /etc/prometheus/
70+
cd ~
71+
rm -rf prometheus-${RELEASE}.linux-amd64 prometheus-${RELEASE}.linux-amd64.tar.gz
72+
echo "${RELEASE}" >/opt/${APP}_version.txt
73+
msg_ok "Updated ${APP} to ${RELEASE}"
74+
75+
msg_info "Starting ${APP}"
76+
systemctl start prometheus
77+
msg_ok "Started ${APP}"
78+
msg_ok "Updated Successfully"
79+
else
80+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
81+
fi
5982
exit
6083
}
6184

0 commit comments

Comments
 (0)