From bfc3b8b6177a23368a0ba3b2802c4d33709383bc Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Thu, 30 Apr 2026 14:00:30 +0200 Subject: [PATCH] simplify nagios --- ct/nagios.sh | 100 ++++++++++++++++---------------------- install/nagios-install.sh | 33 +++++-------- 2 files changed, 55 insertions(+), 78 deletions(-) diff --git a/ct/nagios.sh b/ct/nagios.sh index c7ee2714..7c5704c4 100644 --- a/ct/nagios.sh +++ b/ct/nagios.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) # Copyright (c) 2021-2026 community-scripts ORG -# Author: GitHub Copilot (GPT-5.3-Codex) +# Author: MickLesk (CanbiZ) # License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE # Source: https://github.com/NagiosEnterprises/nagioscore @@ -29,71 +29,55 @@ function update_script() { exit fi - local core_update=0 - local plugins_update=0 + msg_info "Backing up Configuration" + cp -a /usr/local/nagios/etc /opt/nagios-etc-backup + msg_ok "Backed up Configuration" if check_for_gh_release "nagios" "NagiosEnterprises/nagioscore"; then - core_update=1 + msg_info "Stopping Nagios" + systemctl stop nagios + msg_ok "Stopped Nagios" + + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "nagios" "NagiosEnterprises/nagioscore" "tarball" + + msg_info "Building Nagios Core" + cd /opt/nagios + $STD ./configure --with-httpd-conf=/etc/apache2/sites-enabled + $STD make all + $STD make install-groups-users + usermod -a -G nagios www-data + $STD make install + $STD make install-daemoninit + $STD make install-commandmode + $STD make install-webconf + $STD a2enmod rewrite + $STD a2enmod cgi + msg_ok "Built Nagios Core" + + msg_info "Starting Nagios" + systemctl restart apache2 + systemctl start nagios + msg_ok "Started Nagios" fi if check_for_gh_release "nagios-plugins" "nagios-plugins/nagios-plugins"; then - plugins_update=1 + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "nagios-plugins" "nagios-plugins/nagios-plugins" "tarball" + + msg_info "Building Nagios Plugins" + cd /opt/nagios-plugins + $STD ./tools/setup + $STD ./configure + $STD make + $STD make install + msg_ok "Built Nagios Plugins" fi - if [[ "$core_update" == "1" || "$plugins_update" == "1" ]]; then - msg_info "Stopping Services" - systemctl stop nagios - systemctl stop apache2 - msg_ok "Stopped Services" + msg_info "Restoring Configuration" + rm -rf /usr/local/nagios/etc + cp -a /opt/nagios-etc-backup /usr/local/nagios/etc + rm -rf /opt/nagios-etc-backup + msg_ok "Restored Configuration" - msg_info "Backing up Configuration" - cp -a /usr/local/nagios/etc /opt/nagios-etc-backup - msg_ok "Backed up Configuration" - - if [[ "$core_update" == "1" ]]; then - CLEAN_INSTALL=1 fetch_and_deploy_gh_release "nagios" "NagiosEnterprises/nagioscore" "tarball" - - msg_info "Building Nagios Core" - cd /opt/nagios - $STD ./configure --with-httpd-conf=/etc/apache2/sites-enabled - $STD make all - $STD make install-groups-users - usermod -a -G nagios www-data - $STD make install - $STD make install-daemoninit - $STD make install-commandmode - $STD make install-config - $STD make install-webconf - a2enmod rewrite >/dev/null 2>&1 - a2enmod cgi >/dev/null 2>&1 - msg_ok "Built Nagios Core" - fi - - if [[ "$plugins_update" == "1" ]]; then - CLEAN_INSTALL=1 fetch_and_deploy_gh_release "nagios-plugins" "nagios-plugins/nagios-plugins" "tarball" - - msg_info "Building Nagios Plugins" - cd /opt/nagios-plugins - $STD ./tools/setup - $STD ./configure - $STD make - $STD make install - msg_ok "Built Nagios Plugins" - fi - - msg_info "Restoring Configuration" - rm -rf /usr/local/nagios/etc - cp -a /opt/nagios-etc-backup /usr/local/nagios/etc - rm -rf /opt/nagios-etc-backup - msg_ok "Restored Configuration" - - msg_info "Starting Services" - systemctl start apache2 - systemctl start nagios - msg_ok "Started Services" - - msg_ok "Updated successfully!" - fi exit } diff --git a/install/nagios-install.sh b/install/nagios-install.sh index 74e9387b..af064393 100644 --- a/install/nagios-install.sh +++ b/install/nagios-install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Copyright (c) 2021-2026 community-scripts ORG -# Author: GitHub Copilot (GPT-5.3-Codex) +# Author: MickLesk (CanbiZ) # License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE # Source: https://github.com/NagiosEnterprises/nagioscore @@ -17,28 +17,23 @@ msg_info "Installing Dependencies" $STD apt install -y \ autoconf \ automake \ - gcc \ - libc6 \ - libgd-dev \ - libmcrypt-dev \ - libnet-snmp-perl \ - libssl-dev \ - make \ - openssl \ - php \ - apache2 \ - apache2-utils \ build-essential \ bc \ dc \ gawk \ - gperf \ gettext \ + gperf \ + libgd-dev \ + libmcrypt-dev \ + libnet-snmp-perl \ + libssl-dev \ snmp \ - unzip \ - wget + apache2 \ + apache2-utils msg_ok "Installed Dependencies" +PHP_APACHE="YES" setup_php + fetch_and_deploy_gh_release "nagios" "NagiosEnterprises/nagioscore" "tarball" msg_info "Building Nagios Core" @@ -52,8 +47,8 @@ $STD make install-daemoninit $STD make install-commandmode $STD make install-config $STD make install-webconf -a2enmod rewrite >/dev/null 2>&1 -a2enmod cgi >/dev/null 2>&1 +$STD a2enmod rewrite +$STD a2enmod cgi msg_ok "Built Nagios Core" fetch_and_deploy_gh_release "nagios-plugins" "nagios-plugins/nagios-plugins" "tarball" @@ -67,7 +62,7 @@ $STD make install msg_ok "Built Nagios Plugins" msg_info "Configuring Web Authentication" -htpasswd -bc /usr/local/nagios/etc/htpasswd.users nagiosadmin nagiosadmin +$STD htpasswd -bc /usr/local/nagios/etc/htpasswd.users nagiosadmin nagiosadmin chown root:www-data /usr/local/nagios/etc/htpasswd.users chmod 640 /usr/local/nagios/etc/htpasswd.users msg_ok "Configured Web Authentication" @@ -75,8 +70,6 @@ msg_ok "Configured Web Authentication" msg_info "Starting Services" systemctl enable -q --now apache2 systemctl enable -q --now nagios -systemctl restart apache2 -systemctl restart nagios msg_ok "Started Services" motd_ssh