Refactor (#7093)
This commit is contained in:
parent
287265d554
commit
5d526717ef
@ -28,23 +28,18 @@ function update_script() {
|
||||
exit
|
||||
fi
|
||||
RELEASE=$(curl -fsSL https://api.github.com/repos/prometheus/prometheus/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
|
||||
if [[ ! -f ~/.prometheus ]] || [[ "${RELEASE}" != "$(cat ~/.prometheus 2>/dev/null)" ]]; then
|
||||
msg_info "Stopping ${APP}"
|
||||
systemctl stop prometheus
|
||||
msg_ok "Stopped ${APP}"
|
||||
|
||||
msg_info "Updating ${APP} to v${RELEASE}"
|
||||
cd /opt
|
||||
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")
|
||||
tar -xf prometheus-${RELEASE}.linux-amd64.tar.gz
|
||||
cp -rf prometheus-${RELEASE}.linux-amd64/prometheus prometheus-${RELEASE}.linux-amd64/promtool /usr/local/bin/
|
||||
rm -rf prometheus-${RELEASE}.linux-amd64 prometheus-${RELEASE}.linux-amd64.tar.gz
|
||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||
msg_ok "Updated ${APP} to v${RELEASE}"
|
||||
fetch_and_deploy_gh_release "prometheus" "prometheus/prometheus" "prebuild" "latest" "/usr/local/bin" "*linux-amd64.tar.gz"
|
||||
rm -f /usr/local/bin/prometheus.yml
|
||||
|
||||
msg_info "Starting ${APP}"
|
||||
systemctl start prometheus
|
||||
msg_ok "Started ${APP}"
|
||||
|
||||
msg_ok "Updated Successfully"
|
||||
else
|
||||
msg_ok "No update required. ${APP} is already at v${RELEASE}"
|
||||
|
@ -9,7 +9,7 @@
|
||||
"updateable": true,
|
||||
"privileged": false,
|
||||
"interface_port": 9090,
|
||||
"documentation": null,
|
||||
"documentation": "https://prometheus.io/docs/introduction/overview/",
|
||||
"website": "https://prometheus.io/",
|
||||
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/prometheus.webp",
|
||||
"config_path": "/etc/prometheus/prometheus.yml",
|
||||
|
@ -13,19 +13,17 @@ setting_up_container
|
||||
network_check
|
||||
update_os
|
||||
|
||||
fetch_and_deploy_gh_release "prometheus" "prometheus/prometheus" "prebuild" "latest" "/usr/local/bin" "*linux-amd64.tar.gz"
|
||||
|
||||
msg_info "Installing Prometheus"
|
||||
RELEASE=$(curl -fsSL https://api.github.com/repos/prometheus/prometheus/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||
mkdir -p /etc/prometheus
|
||||
mkdir -p /var/lib/prometheus
|
||||
curl -fsSL "https://github.com/prometheus/prometheus/releases/download/v${RELEASE}/prometheus-${RELEASE}.linux-amd64.tar.gz" -o "prometheus-${RELEASE}.linux-amd64.tar.gz"
|
||||
tar -xf prometheus-${RELEASE}.linux-amd64.tar.gz
|
||||
mv prometheus-${RELEASE}.linux-amd64/prometheus prometheus-${RELEASE}.linux-amd64/promtool /usr/local/bin/
|
||||
mv prometheus-${RELEASE}.linux-amd64/prometheus.yml /etc/prometheus/prometheus.yml
|
||||
mv /usr/local/bin/prometheus.yml /etc/prometheus/prometheus.yml
|
||||
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
|
||||
msg_ok "Installed Prometheus"
|
||||
|
||||
msg_info "Creating Service"
|
||||
cat <<EOF >/etc/systemd/system/prometheus.service
|
||||
cat <<'EOF' >/etc/systemd/system/prometheus.service
|
||||
[Unit]
|
||||
Description=Prometheus
|
||||
Wants=network-online.target
|
||||
@ -53,5 +51,4 @@ customize
|
||||
msg_info "Cleaning up"
|
||||
$STD apt-get -y autoremove
|
||||
$STD apt-get -y autoclean
|
||||
rm -rf prometheus-${RELEASE}.linux-amd64 prometheus-${RELEASE}.linux-amd64.tar.gz
|
||||
msg_ok "Cleaned"
|
||||
|
Loading…
x
Reference in New Issue
Block a user