Skip to content

Commit 5d52671

Browse files
authored
Refactor (#7093)
1 parent 287265d commit 5d52671

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

ct/prometheus.sh

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,18 @@ function update_script() {
2828
exit
2929
fi
3030
RELEASE=$(curl -fsSL https://api.github.com/repos/prometheus/prometheus/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
31-
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
31+
if [[ ! -f ~/.prometheus ]] || [[ "${RELEASE}" != "$(cat ~/.prometheus 2>/dev/null)" ]]; then
3232
msg_info "Stopping ${APP}"
3333
systemctl stop prometheus
3434
msg_ok "Stopped ${APP}"
3535

36-
msg_info "Updating ${APP} to v${RELEASE}"
37-
cd /opt
38-
curl -fsSL "https://github.com/prometheus/prometheus/releases/download/v${RELEASE}/prometheus-${RELEASE}.linux-amd64.tar.gz" -o $(basename "https://github.com/prometheus/prometheus/releases/download/v${RELEASE}/prometheus-${RELEASE}.linux-amd64.tar.gz")
39-
tar -xf prometheus-${RELEASE}.linux-amd64.tar.gz
40-
cp -rf prometheus-${RELEASE}.linux-amd64/prometheus prometheus-${RELEASE}.linux-amd64/promtool /usr/local/bin/
41-
rm -rf prometheus-${RELEASE}.linux-amd64 prometheus-${RELEASE}.linux-amd64.tar.gz
42-
echo "${RELEASE}" >/opt/${APP}_version.txt
43-
msg_ok "Updated ${APP} to v${RELEASE}"
36+
fetch_and_deploy_gh_release "prometheus" "prometheus/prometheus" "prebuild" "latest" "/usr/local/bin" "*linux-amd64.tar.gz"
37+
rm -f /usr/local/bin/prometheus.yml
4438

4539
msg_info "Starting ${APP}"
4640
systemctl start prometheus
4741
msg_ok "Started ${APP}"
42+
4843
msg_ok "Updated Successfully"
4944
else
5045
msg_ok "No update required. ${APP} is already at v${RELEASE}"

frontend/public/json/prometheus.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"updateable": true,
1010
"privileged": false,
1111
"interface_port": 9090,
12-
"documentation": null,
12+
"documentation": "https://prometheus.io/docs/introduction/overview/",
1313
"website": "https://prometheus.io/",
1414
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/prometheus.webp",
1515
"config_path": "/etc/prometheus/prometheus.yml",

install/prometheus-install.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@ setting_up_container
1313
network_check
1414
update_os
1515

16+
fetch_and_deploy_gh_release "prometheus" "prometheus/prometheus" "prebuild" "latest" "/usr/local/bin" "*linux-amd64.tar.gz"
17+
1618
msg_info "Installing Prometheus"
17-
RELEASE=$(curl -fsSL https://api.github.com/repos/prometheus/prometheus/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
1819
mkdir -p /etc/prometheus
1920
mkdir -p /var/lib/prometheus
20-
curl -fsSL "https://github.com/prometheus/prometheus/releases/download/v${RELEASE}/prometheus-${RELEASE}.linux-amd64.tar.gz" -o "prometheus-${RELEASE}.linux-amd64.tar.gz"
21-
tar -xf prometheus-${RELEASE}.linux-amd64.tar.gz
22-
mv prometheus-${RELEASE}.linux-amd64/prometheus prometheus-${RELEASE}.linux-amd64/promtool /usr/local/bin/
23-
mv prometheus-${RELEASE}.linux-amd64/prometheus.yml /etc/prometheus/prometheus.yml
21+
mv /usr/local/bin/prometheus.yml /etc/prometheus/prometheus.yml
2422
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
2523
msg_ok "Installed Prometheus"
2624

2725
msg_info "Creating Service"
28-
cat <<EOF >/etc/systemd/system/prometheus.service
26+
cat <<'EOF' >/etc/systemd/system/prometheus.service
2927
[Unit]
3028
Description=Prometheus
3129
Wants=network-online.target
@@ -53,5 +51,4 @@ customize
5351
msg_info "Cleaning up"
5452
$STD apt-get -y autoremove
5553
$STD apt-get -y autoclean
56-
rm -rf prometheus-${RELEASE}.linux-amd64 prometheus-${RELEASE}.linux-amd64.tar.gz
5754
msg_ok "Cleaned"

0 commit comments

Comments
 (0)