Skip to content

Commit 9a4d35b

Browse files
authored
Prometheus + Alertmanager: Unify scripts for easier maintenance (#1402)
1 parent b7a8d34 commit 9a4d35b

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

ct/prometheus-alertmanager.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,17 @@ function update_script() {
4242
cd /opt
4343
wget -q https://github.com/prometheus/alertmanager/releases/download/v${RELEASE}/alertmanager-${RELEASE}.linux-amd64.tar.gz
4444
tar -xf alertmanager-${RELEASE}.linux-amd64.tar.gz
45-
cd alertmanager-${RELEASE}.linux-amd64
46-
cp -rf alertmanager amtool /usr/local/bin/
45+
cp -rf alertmanager-${RELEASE}.linux-amd64/alertmanager alertmanager-${RELEASE}.linux-amd64/amtool /usr/local/bin/
4746
rm -rf alertmanager-${RELEASE}.linux-amd64 alertmanager-${RELEASE}.linux-amd64.tar.gz
4847
echo "${RELEASE}" >/opt/${APP}_version.txt
49-
msg_ok "Updated ${APP} to ${RELEASE}"
48+
msg_ok "Updated ${APP} to v${RELEASE}"
5049

5150
msg_info "Starting ${APP}"
5251
systemctl start prometheus-alertmanager
5352
msg_ok "Started ${APP}"
5453
msg_ok "Updated Successfully"
5554
else
56-
msg_ok "No update required. ${APP} is already at ${RELEASE}"
55+
msg_ok "No update required. ${APP} is already at v${RELEASE}"
5756
fi
5857
exit
5958
}

ct/prometheus.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3-
# Copyright (c) 2021-2025 tteck
3+
# Copyright (c) 2021-2025 community-scripts ORG
44
# Author: tteck (tteckster)
55
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
66
# Source: https://prometheus.io/
@@ -38,22 +38,21 @@ function update_script() {
3838
systemctl stop prometheus
3939
msg_ok "Stopped ${APP}"
4040

41-
msg_info "Updating ${APP} to ${RELEASE}"
41+
msg_info "Updating ${APP} to v${RELEASE}"
42+
cd /opt
4243
wget -q https://github.com/prometheus/prometheus/releases/download/v${RELEASE}/prometheus-${RELEASE}.linux-amd64.tar.gz
4344
tar -xf prometheus-${RELEASE}.linux-amd64.tar.gz
44-
cd prometheus-${RELEASE}.linux-amd64
45-
cp -rf prometheus promtool /usr/local/bin/
46-
cd ~
45+
cp -rf prometheus-${RELEASE}.linux-amd64/prometheus prometheus-${RELEASE}.linux-amd64/promtool /usr/local/bin/
4746
rm -rf prometheus-${RELEASE}.linux-amd64 prometheus-${RELEASE}.linux-amd64.tar.gz
4847
echo "${RELEASE}" >/opt/${APP}_version.txt
49-
msg_ok "Updated ${APP} to ${RELEASE}"
48+
msg_ok "Updated ${APP} to v${RELEASE}"
5049

5150
msg_info "Starting ${APP}"
5251
systemctl start prometheus
5352
msg_ok "Started ${APP}"
5453
msg_ok "Updated Successfully"
5554
else
56-
msg_ok "No update required. ${APP} is already at ${RELEASE}"
55+
msg_ok "No update required. ${APP} is already at v${RELEASE}"
5756
fi
5857
exit
5958
}

install/prometheus-install.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env bash
22

3-
# Copyright (c) 2021-2025 tteck
3+
# Copyright (c) 2021-2025 community-scripts ORG
44
# Author: tteck (tteckster)
5-
# License: MIT
6-
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://prometheus.io/
77

88
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
99
color
@@ -14,9 +14,10 @@ network_check
1414
update_os
1515

1616
msg_info "Installing Dependencies"
17-
$STD apt-get install -y curl
18-
$STD apt-get install -y sudo
19-
$STD apt-get install -y mc
17+
$STD apt-get install -y \
18+
curl \
19+
sudo \
20+
mc
2021
msg_ok "Installed Dependencies"
2122

2223
msg_info "Installing Prometheus"
@@ -25,14 +26,13 @@ mkdir -p /etc/prometheus
2526
mkdir -p /var/lib/prometheus
2627
wget -q https://github.com/prometheus/prometheus/releases/download/v${RELEASE}/prometheus-${RELEASE}.linux-amd64.tar.gz
2728
tar -xf prometheus-${RELEASE}.linux-amd64.tar.gz
28-
cd prometheus-${RELEASE}.linux-amd64
29-
mv prometheus promtool /usr/local/bin/
30-
mv prometheus.yml /etc/prometheus/prometheus.yml
29+
mv prometheus-${RELEASE}.linux-amd64/prometheus prometheus-${RELEASE}.linux-amd64/promtool /usr/local/bin/
30+
mv prometheus-${RELEASE}.linux-amd64/prometheus.yml /etc/prometheus/prometheus.yml
3131
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
3232
msg_ok "Installed Prometheus"
3333

3434
msg_info "Creating Service"
35-
service_path="/etc/systemd/system/prometheus.service"
35+
cat <<EOF >/etc/systemd/system/prometheus.service"
3636
echo "[Unit]
3737
Description=Prometheus
3838
Wants=network-online.target
@@ -49,7 +49,8 @@ ExecStart=/usr/local/bin/prometheus \
4949
ExecReload=/bin/kill -HUP \$MAINPID
5050
5151
[Install]
52-
WantedBy=multi-user.target" >$service_path
52+
WantedBy=multi-user.target"
53+
EOF
5354
systemctl enable -q --now prometheus
5455
msg_ok "Created Service"
5556

@@ -59,5 +60,5 @@ customize
5960
msg_info "Cleaning up"
6061
$STD apt-get -y autoremove
6162
$STD apt-get -y autoclean
62-
rm -rf ../prometheus-${RELEASE}.linux-amd64 ../prometheus-${RELEASE}.linux-amd64.tar.gz
63+
rm -rf prometheus-${RELEASE}.linux-amd64 prometheus-${RELEASE}.linux-amd64.tar.gz
6364
msg_ok "Cleaned"

0 commit comments

Comments
 (0)