e7e3233361b05e6b13338c7b42817d79f7e9e396
[buildscripts] / prometheus
1 #!/bin/bash
2
3 # I initially was using these
4 # https://github.com/cloudalchemy/ansible-prometheus
5 # https://github.com/cloudalchemy/ansible-alertmanager
6 # https://github.com/cloudalchemy/ansible-node-exporter
7 # https://github.com/cloudalchemy/ansible-grafana
8
9 # As of trisquel 11, get upstream prom because it has the react ui,
10 # which has localtime, and general better usability. alertmanager,
11 # changelog seems to show good changes and surely things will just work
12 # better with a matching prometheus.
13
14 if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
15
16 #rsync --delete consoles console_libraries /etc/prometheus
17
18
19 while read -r prog tool; do
20 cd /a/opt/${prog}dl
21 url=$(curl -s https://api.github.com/repos/prometheus/$prog/releases/latest | jq -r '.assets[].browser_download_url | match(".*linux-amd64.tar.gz$").string')
22 f=${url##*/}
23 if [[ -e $f ]]; then
24 timestamp=$(stat -c %Y $f)
25 else
26 timestamp=0
27 fi
28 m wget -nv -N $url
29 new_timestamp=$(stat -c %Y $f)
30 if [[ $timestamp != $new_timestamp || ! -e /usr/local/bin/$prog ]]; then
31 ngset
32 to_rm=( !($f) )
33 ngreset
34 if (( ${#to_rm[@]} )); then
35 rm -rf ${to_rm[@]}
36 fi
37 m ex $f
38 dir=${f%.tar.gz}
39 m sudo install $dir/$prog $dir/$tool /usr/local/bin
40 m sudo systemctl restart $prog
41 fi
42 done <<'EOF'
43 prometheus promtool
44 alertmanager amtool
45 EOF