-
Notifications
You must be signed in to change notification settings - Fork 0
/
DownloadCheckMK
34 lines (32 loc) · 1.54 KB
/
DownloadCheckMK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
# source me in env'
# and use me like that...
# DownloadCheckMK 2.1.0p6
V="$(curl -s https://download.checkmk.com/stable_downloads.json |jq -r '.checkmk[].version'|sort -h|tail -n 1)"
VER="$${1:-${V}}"
DownloadCheckMK() {
local RELEASES TARGETDIR VERSION BASEURL RELEASE
RELEASES="stretch buster bullseye bionic focal jammy"
TARGETDIR=/var/www/domain.tld/www/html
#TARGETDIR=$HOME/test
VERSION="$VER"
BASEURL="https://download.checkmk.com/checkmk/${VERSION}/check-mk-raw-${VERSION}_0."
#readarray -t VERSIONS < <(curl https://checkmk.com/download |grep -Po '.*window.downloads = \K.*'|jq -r '.cmk.cme|.[][][]|@tsv' |grep -Po "check.*$V.*deb") )
cd "$TARGETDIR" || exit
for RELEASE in $RELEASES ; do
wget -nc "${BASEURL}${RELEASE}_amd64.deb"
if [[ "$RELEASE" = "bullseye" ]]; then
TMPDIR=$(mktemp -d)
ar -x "${TARGETDIR}/check-mk-raw-${VERSION}_0.${RELEASE}_amd64.deb" data.tar.xz --output="$TMPDIR"
FILE="$TMPDIR/data.tar.xz"
tar Jft "$FILE" |grep -E '(agent.msi|all.deb|rpm|agent.freebsd)$' |xargs -n 1 tar Jfx "$FILE" --transform='s/.*\///' -C $TARGETDIR
mv "$TARGETDIR/check_mk_agent.msi" "$TARGETDIR/check_mk_agent-$VERSION-1.msi"
rm -Rf "$TMPDIR"
fi
done
}
alias get_mirrored_files="ls -1 /var/www/domain.tld/www/html| sed 's|^|https://domain.tld/|g'"
# and for remote-listing...
# alias get_mirrored_files="ssh mirror-host ls -1 /var/www/domain.tld/www/html| sed 's|^|https://domain.tld/|g'"
# For Later
# curl https://checkmk.com/download |grep -Po '.*window.downloads = \K.*' |jq