From 0672dc0353b209beaea5e877492e3930b5e50ee2 Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Thu, 19 Dec 2024 15:28:49 +0100 Subject: [PATCH 1/3] New Script: CheckMk --- ct/checkmk.sh | 59 ++++++++++++++++++++++++++++++++++++++ install/checkmk-install.sh | 47 ++++++++++++++++++++++++++++++ json/checkmk.json | 34 ++++++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 ct/checkmk.sh create mode 100644 install/checkmk-install.sh create mode 100644 json/checkmk.json diff --git a/ct/checkmk.sh b/ct/checkmk.sh new file mode 100644 index 0000000000..4a08f504a1 --- /dev/null +++ b/ct/checkmk.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2024 community-scripts ORG +# Author: Michel Roegl-Brunner (michelroegl-brunner) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://checkmk.com/ + +APP="checkmk" +var_tags="monitoring" +var_cpu="2" +var_ram="2048" +var_disk="4" +var_os="debian" +var_version="12" +var_unprivileged="1" + +header_info "$APP" +base_settings + +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + if [[ ! -f /opt/checkmk_version.txt ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + RELEASE=$(curl -fsSL https://api.github.com/repos/checkmk/checkmk/tags | grep "name" | awk '{print substr($2, 3, length($2)-4) }' | grep -v "*-rc" | tail -n +2 | head -n 1) + if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_info "Updating ${APP} to v${RELEASE}" + omd stop monitoring &>/dev/null + omd cp monitoring monitoringbackup &>/dev/null + wget -q https://download.checkmk.com/checkmk/${RELEASE}/check-mk-raw-${RELEASE}_0.bookworm_amd64.deb -O /opt/checkmk.deb + apt-get install -y /opt/checkmk.deb &>/dev/null + omd --force -V ${RELEASE}.cre update --conflict=install monitoring &>/dev/null + omd start monitoring &>/dev/null + omd -f rm monitoringbackup &>/dev/null + omd cleanup &>/dev/null + rm -rf /opt/checkmk.deb + msg_ok "Updated ${APP} to v${RELEASE}" + else + msg_ok "No update required. ${APP} is already at v${RELEASE}." + fi + + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}/monitoring${CL}" diff --git a/install/checkmk-install.sh b/install/checkmk-install.sh new file mode 100644 index 0000000000..d7f5752489 --- /dev/null +++ b/install/checkmk-install.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +#Copyright (c) 2021-2024 community-scripts ORG +# Author: Michel Roegl-Brunner (michelroegl-brunner) +# License: MIT +# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE + + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y \ + curl \ + mc +msg_ok "Installed Dependencies" + +msg_info "Install Checkmk" +RELEASE=$(curl -fsSL https://api.github.com/repos/checkmk/checkmk/tags | grep "name" | awk '{print substr($2, 3, length($2)-4) }' | grep -v "*-rc" | tail -n +2 | head -n 1) +wget -q https://download.checkmk.com/checkmk/${RELEASE}/check-mk-raw-${RELEASE}_0.bookworm_amd64.deb -O /opt/checkmk.deb +$STD apt-get install -y /opt/checkmk.deb +echo "${RELEASE}" >"/opt/checkmk_version.txt" +msg_ok "Installed Checkmk" + +msg_info "Creating Service" +PASSWORD=$(omd create monitoring | grep "password:" | awk '{print $NF}') +$STD omd start &>/dev/null +{ + echo "Application-Credentials" + echo "Username: cmkadmin" + echo "Password: $PASSWORD" +} >> ~/checkmk.creds +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -rf /opt/checkmk.deb +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/json/checkmk.json b/json/checkmk.json new file mode 100644 index 0000000000..0305c7b21e --- /dev/null +++ b/json/checkmk.json @@ -0,0 +1,34 @@ +{ + "name": "Checkmk", + "slug": "checkmk", + "categories": [ + 7 + ], + "date_created": "2024-12-19", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 80, + "documentation": "https://docs.checkmk.com/", + "website": "https://checkmk.com/", + "logo": "https://github.com/Checkmk/checkmk/blob/master/omd/license_sources/checkmk_logo.svg", + "description": "Checkmk - Your complete IT monitoring solution", + "install_methods": [ + { + "type": "default", + "script": "ct/checkmk.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 4, + "os": null, + "version": null + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] +} \ No newline at end of file From 3e736e0aad08e518b5098e4b248cfb5fd806f056 Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Thu, 19 Dec 2024 15:57:17 +0100 Subject: [PATCH 2/3] Add sudo --- install/checkmk-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install/checkmk-install.sh b/install/checkmk-install.sh index d7f5752489..ae2d0c4265 100644 --- a/install/checkmk-install.sh +++ b/install/checkmk-install.sh @@ -17,6 +17,7 @@ update_os msg_info "Installing Dependencies" $STD apt-get install -y \ curl \ + sudo \ mc msg_ok "Installed Dependencies" From 1794926b9a6f7ab668a940af5bb242cd15afc8e6 Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Fri, 20 Dec 2024 09:12:57 +0100 Subject: [PATCH 3/3] Change to dpkg -i --- ct/checkmk.sh | 2 +- install/checkmk-install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ct/checkmk.sh b/ct/checkmk.sh index 4a08f504a1..e76a69d8fc 100644 --- a/ct/checkmk.sh +++ b/ct/checkmk.sh @@ -35,7 +35,7 @@ function update_script() { omd stop monitoring &>/dev/null omd cp monitoring monitoringbackup &>/dev/null wget -q https://download.checkmk.com/checkmk/${RELEASE}/check-mk-raw-${RELEASE}_0.bookworm_amd64.deb -O /opt/checkmk.deb - apt-get install -y /opt/checkmk.deb &>/dev/null + dpkg -i /opt/checkmk.deb &>/dev/null omd --force -V ${RELEASE}.cre update --conflict=install monitoring &>/dev/null omd start monitoring &>/dev/null omd -f rm monitoringbackup &>/dev/null diff --git a/install/checkmk-install.sh b/install/checkmk-install.sh index ae2d0c4265..9c44d8414a 100644 --- a/install/checkmk-install.sh +++ b/install/checkmk-install.sh @@ -24,7 +24,7 @@ msg_ok "Installed Dependencies" msg_info "Install Checkmk" RELEASE=$(curl -fsSL https://api.github.com/repos/checkmk/checkmk/tags | grep "name" | awk '{print substr($2, 3, length($2)-4) }' | grep -v "*-rc" | tail -n +2 | head -n 1) wget -q https://download.checkmk.com/checkmk/${RELEASE}/check-mk-raw-${RELEASE}_0.bookworm_amd64.deb -O /opt/checkmk.deb -$STD apt-get install -y /opt/checkmk.deb +$STD dpkg -i /opt/checkmk.deb echo "${RELEASE}" >"/opt/checkmk_version.txt" msg_ok "Installed Checkmk"