From 545bb08f9bc84c5e2f7436f53efdc9b6344c3624 Mon Sep 17 00:00:00 2001 From: Thorsten Spille Date: Mon, 5 Oct 2026 12:10:17 +0200 Subject: [PATCH] Install latest checkmk release automatically Add inst_checkmk to functions.sh, which resolves the release from https://download.checkmk.com/stable_downloads.json, downloads the package for the container's Debian release and verifies its SHA256 checksum. CMK_VERSION now accepts: - empty: latest stable release - 2.4 / 2.4.0: latest patch release of a branch - 2.4.0p18: exactly this release (no checksum available) Package file names are taken from the JSON, so the rename from check-mk-raw to check-mk-community in 2.5 is handled transparently. Legacy edition names (raw, enterprise, cloud, managed) are still accepted. CMK_BUILD is no longer needed. checkmk now installs the latest stable release, bashclub-cmk stays on the latest 2.4 patch release. Co-Authored-By: Claude Opus 5.5 --- conf/README.md | 10 +++-- conf/zamba.conf.example | 8 ++-- src/bashclub-cmk/constants-service.conf | 6 +-- src/bashclub-cmk/install-service.sh | 4 +- src/checkmk/constants-service.conf | 6 +-- src/checkmk/install-service.sh | 4 +- src/functions.sh | 60 ++++++++++++++++++++++++- 7 files changed, 75 insertions(+), 23 deletions(-) diff --git a/conf/README.md b/conf/README.md index 0d03fba..13aa820 100644 --- a/conf/README.md +++ b/conf/README.md @@ -249,11 +249,13 @@ CMK_ADMIN_PW='Start!123' ``` ### CMK_EDITION -checkmk edition (raw or free) -- raw = completely free -- free = limited version of the enterprise edition (25 hosts, 1 instance) +checkmk edition (community, pro, ultimate or ultimatemt), the latest release will be installed +- community = completely free (formerly raw, which is still accepted) +- pro, ultimate, ultimatemt = commercial editions (formerly enterprise, cloud, managed) + +The version can be pinned with `CMK_VERSION` in `src/checkmk/constants-service.conf` (empty = latest stable release, `2.4` = latest patch release of a branch, `2.4.0p18` = exactly this release). ```bash -CMK_EDITION=raw +CMK_EDITION=community ``` ### Kopano-Section diff --git a/conf/zamba.conf.example b/conf/zamba.conf.example index e8095ba..44364af 100644 --- a/conf/zamba.conf.example +++ b/conf/zamba.conf.example @@ -160,10 +160,10 @@ CMK_INSTANCE=zmbrocks # Define the password of user 'cmkadmin' CMK_ADMIN_PW='Start!123' -# checkmk edition (raw or free) -# raw = completely free -# free = limited version of the enterprise edition (25 hosts, 1 instance) -CMK_EDITION=raw +# checkmk edition (community, pro, ultimate or ultimatemt), the latest release will be installed +# community = completely free (formerly raw, which is still accepted) +# pro, ultimate, ultimatemt = commercial editions (formerly enterprise, cloud, managed) +CMK_EDITION=community ############### vaultwarden Section ############### diff --git a/src/bashclub-cmk/constants-service.conf b/src/bashclub-cmk/constants-service.conf index e360c84..b028b87 100644 --- a/src/bashclub-cmk/constants-service.conf +++ b/src/bashclub-cmk/constants-service.conf @@ -27,10 +27,8 @@ LXC_NESTING="1" # enable keyctl feature LXC_KEYCTL="0" -# checkmk version -CMK_VERSION=2.4.0p19 -# build number of the debian package (needs to start with underscore) -CMK_BUILD=_0 +# checkmk version (empty = latest stable release, 2.4 = latest patch release of a branch, 2.4.0p18 = exactly this release) +CMK_VERSION="2.4" # Sets the minimum amount of RAM the service needs for operation LXC_MEM_MIN=2048 diff --git a/src/bashclub-cmk/install-service.sh b/src/bashclub-cmk/install-service.sh index cf2a1ef..512f2c2 100644 --- a/src/bashclub-cmk/install-service.sh +++ b/src/bashclub-cmk/install-service.sh @@ -15,9 +15,7 @@ wget -O - https://apt.bashclub.org/gpg/bashclub.pub | gpg --dearmor > /usr/share echo "deb [signed-by=/usr/share/keyrings/bashclub-keyring.gpg] https://apt.bashclub.org/testing $(lsb_release -cs) main" > /etc/apt/sources.list.d/bashclub.list apt update -cd /tmp -wget https://download.checkmk.com/checkmk/$CMK_VERSION/check-mk-$CMK_EDITION-$CMK_VERSION$CMK_BUILD.$(lsb_release -cs)_amd64.deb -DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt -y -qq install ./check-mk-$CMK_EDITION-$CMK_VERSION$CMK_BUILD.$(lsb_release -cs)_amd64.deb +inst_checkmk "$CMK_EDITION" "$CMK_VERSION" omd create --admin-password $CMK_ADMIN_PW $CMK_INSTANCE cat << EOF > /etc/apache2/sites-available/000-default.conf diff --git a/src/checkmk/constants-service.conf b/src/checkmk/constants-service.conf index 9715ad6..b7fce92 100644 --- a/src/checkmk/constants-service.conf +++ b/src/checkmk/constants-service.conf @@ -27,10 +27,8 @@ LXC_NESTING="1" # enable keyctl feature LXC_KEYCTL="0" -# checkmk version -CMK_VERSION=2.4.0p18 -# build number of the debian package (needs to start with underscore) -CMK_BUILD=_0 +# checkmk version (empty = latest stable release, 2.4 = latest patch release of a branch, 2.4.0p18 = exactly this release) +CMK_VERSION="" # Sets the minimum amount of RAM the service needs for operation LXC_MEM_MIN=2048 diff --git a/src/checkmk/install-service.sh b/src/checkmk/install-service.sh index 499934e..1794e03 100644 --- a/src/checkmk/install-service.sh +++ b/src/checkmk/install-service.sh @@ -11,9 +11,7 @@ source /root/functions.sh source /root/zamba.conf source /root/constants-service.conf -cd /tmp -wget https://download.checkmk.com/checkmk/$CMK_VERSION/check-mk-$CMK_EDITION-$CMK_VERSION$CMK_BUILD.$(lsb_release -cs)_amd64.deb -DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt -y -qq install ./check-mk-$CMK_EDITION-$CMK_VERSION$CMK_BUILD.$(lsb_release -cs)_amd64.deb +inst_checkmk "$CMK_EDITION" "$CMK_VERSION" omd create --admin-password $CMK_ADMIN_PW $CMK_INSTANCE diff --git a/src/functions.sh b/src/functions.sh index 20aee4b..0da2da8 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -132,4 +132,62 @@ inst_bashclub() { apt_repo "bashclub-$BASHCLUB_COMPONENT" "https://apt.bashclub.org/gpg/bashclub.pub" "https://apt.bashclub.org/$BASHCLUB_COMPONENT" "$(lsb_release -cs)" "main" apt update -} \ No newline at end of file +} + +#### Download and install Checkmk #### +# First parameter is the edition (community, pro, ultimate, ultimatemt - legacy names like raw are accepted) +# Second parameter is the version (optional): +# empty = latest stable release +# 2.4 / 2.4.0 = latest patch release of branch 2.4.0 +# 2.4.0p18 = exactly this release (checksum is only available for the latest patch release of a branch) +inst_checkmk() { + local cmk_edition cmk_version cmk_branch cmk_os cmk_release cmk_latest cmk_file cmk_sha256 + case "${1}" in + raw|cre|community) cmk_edition=community ;; + enterprise|cee|pro) cmk_edition=pro ;; + cloud|cce|ultimate) cmk_edition=ultimate ;; + managed|cme|ultimatemt) cmk_edition=ultimatemt ;; + *) echo "❌ Unknown checkmk edition '${1}'."; exit 1 ;; + esac + cmk_version=${2:-} + # short branch notation: 2.4 -> 2.4.0 + if [[ "${cmk_version}" =~ ^[0-9]+\.[0-9]+$ ]]; then + cmk_version="${cmk_version}.0" + fi + cmk_branch=$(grep -oE '^[0-9]+\.[0-9]+\.[0-9]+' <<< "${cmk_version}" || true) + cmk_os=$(lsb_release -cs) + + cmk_release=$(curl -fsSL https://download.checkmk.com/stable_downloads.json | jq -r \ + --arg ed "${cmk_edition}" --arg os "${cmk_os}" --arg branch "${cmk_branch}" ' + .checkmk | to_entries + | map(select(.value.editions[$ed][$os] != null)) + | map(select(if $branch == "" then .value.class == "stable" else .key == $branch end)) + | sort_by(.key | split(".") | map(tonumber)) | last // empty + | [.value.version, .value.editions[$ed][$os][]] | @tsv') || true + if [ -z "${cmk_release}" ]; then + echo "❌ No checkmk release found for edition '${cmk_edition}', version '${cmk_version:-latest}' on ${cmk_os}." + exit 1 + fi + read -r cmk_latest cmk_file cmk_sha256 <<< "${cmk_release}" + + if [ -z "${cmk_version}" ] || [ "${cmk_version}" == "${cmk_branch}" ]; then + cmk_version=${cmk_latest} + elif [ "${cmk_version}" != "${cmk_latest}" ]; then + # older patch release: same file name scheme as the latest one of this branch, but no checksum + cmk_file=${cmk_file/${cmk_latest}/${cmk_version}} + cmk_sha256="" + fi + + echo "Downloading checkmk ${cmk_version} (${cmk_file})..." + if ! curl -fsSL -o "/tmp/${cmk_file}" "https://download.checkmk.com/checkmk/${cmk_version}/${cmk_file}"; then + echo "❌ Download of checkmk ${cmk_version} failed." + exit 1 + fi + if [ -n "${cmk_sha256}" ]; then + echo "${cmk_sha256} /tmp/${cmk_file}" | sha256sum -c - + else + echo "⚠️ No checksum available for checkmk ${cmk_version}, skipping verification." + fi + DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt -y -qq install "/tmp/${cmk_file}" + rm -f "/tmp/${cmk_file}" +}