2 # I, Ian Kelling, follow the GNU license recommendations at
3 # https://www.gnu.org/licenses/license-recommendations.en.html. They
4 # recommend that small programs, < 300 lines, be licensed under the
5 # Apache License 2.0. This file contains or is part of one or more small
6 # programs. If a small program grows beyond 300 lines, I plan to switch
9 # Copyright 2024 Ian Kelling
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
15 # http://www.apache.org/licenses/LICENSE-2.0
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
24 # iank: fixed version of /usr/share/prometheus/alertmanager/generate-ui.sh, plus exit if already build
27 if [[ -e /usr
/share
/prometheus
/alertmanager
/ui
/index.html
]]; then
32 ELMDISTURL
=https
://github.com
/elm
/compiler
/releases
/download
/0.19.1/binary-for-linux-64-bit.gz
33 SRCDIR
=/usr
/share
/gocode
/src
/github.com
/prometheus
/alertmanager
/ui
/app
34 DSTDIR
=/usr
/share
/prometheus
/alertmanager
/ui
36 echo "Installing dependencies..." >&2
37 apt
install libjs-bootstrap4 fonts-font-awesome curl uglifyjs \
38 golang-github-prometheus-alertmanager-dev
40 #/usr/share/fonts-font-awesome/
43 echo "Downloading Elm tools..." >&2
45 curl
--location $ELMDISTURL | zcat
>$TMPDIR/elm
48 echo "Compiling source code..." >&2
49 ln -s $SRCDIR/src
$SRCDIR/elm.json
$TMPDIR
50 (cd $TMPDIR; .
/elm
make src
/Main.elm
--optimize --output $TMPDIR/app.js
)
52 echo "Optimising source code..." >&2
53 uglifyjs
$TMPDIR/app.js \
54 --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters,keep_fargs=false,unsafe_comps,unsafe' \
55 --mangle --output $TMPDIR/script.js
57 echo "Installing in Alertmanager directory..." >&2
60 cp $TMPDIR/script.js
$DSTDIR
61 cp $SRCDIR/index.html
$SRCDIR/favicon.ico
$DSTDIR
62 ln -s /usr
/share
/fonts-font-awesome
$DSTDIR/lib
/font-awesome
63 ln -s /usr
/share
/nodejs
/bootstrap
/dist
$DSTDIR/lib
/bootstrap4
67 echo "Finished! Please, restart prometheus-alertmanager to activate UI." >&2