simplify nagios

This commit is contained in:
CanbiZ (MickLesk)
2026-04-30 14:00:30 +02:00
parent c632b4eeaa
commit bfc3b8b617
2 changed files with 55 additions and 78 deletions

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)
# Copyright (c) 2021-2026 community-scripts ORG # 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 # License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
# Source: https://github.com/NagiosEnterprises/nagioscore # Source: https://github.com/NagiosEnterprises/nagioscore
@@ -29,28 +29,15 @@ function update_script() {
exit exit
fi fi
local core_update=0
local plugins_update=0
if check_for_gh_release "nagios" "NagiosEnterprises/nagioscore"; then
core_update=1
fi
if check_for_gh_release "nagios-plugins" "nagios-plugins/nagios-plugins"; then
plugins_update=1
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 "Backing up Configuration" msg_info "Backing up Configuration"
cp -a /usr/local/nagios/etc /opt/nagios-etc-backup cp -a /usr/local/nagios/etc /opt/nagios-etc-backup
msg_ok "Backed up Configuration" msg_ok "Backed up Configuration"
if [[ "$core_update" == "1" ]]; then if check_for_gh_release "nagios" "NagiosEnterprises/nagioscore"; then
msg_info "Stopping Nagios"
systemctl stop nagios
msg_ok "Stopped Nagios"
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "nagios" "NagiosEnterprises/nagioscore" "tarball" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "nagios" "NagiosEnterprises/nagioscore" "tarball"
msg_info "Building Nagios Core" msg_info "Building Nagios Core"
@@ -62,14 +49,18 @@ function update_script() {
$STD make install $STD make install
$STD make install-daemoninit $STD make install-daemoninit
$STD make install-commandmode $STD make install-commandmode
$STD make install-config
$STD make install-webconf $STD make install-webconf
a2enmod rewrite >/dev/null 2>&1 $STD a2enmod rewrite
a2enmod cgi >/dev/null 2>&1 $STD a2enmod cgi
msg_ok "Built Nagios Core" msg_ok "Built Nagios Core"
msg_info "Starting Nagios"
systemctl restart apache2
systemctl start nagios
msg_ok "Started Nagios"
fi fi
if [[ "$plugins_update" == "1" ]]; then if check_for_gh_release "nagios-plugins" "nagios-plugins/nagios-plugins"; then
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "nagios-plugins" "nagios-plugins/nagios-plugins" "tarball" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "nagios-plugins" "nagios-plugins/nagios-plugins" "tarball"
msg_info "Building Nagios Plugins" msg_info "Building Nagios Plugins"
@@ -87,13 +78,6 @@ function update_script() {
rm -rf /opt/nagios-etc-backup rm -rf /opt/nagios-etc-backup
msg_ok "Restored Configuration" msg_ok "Restored Configuration"
msg_info "Starting Services"
systemctl start apache2
systemctl start nagios
msg_ok "Started Services"
msg_ok "Updated successfully!"
fi
exit exit
} }

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG # 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 # License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
# Source: https://github.com/NagiosEnterprises/nagioscore # Source: https://github.com/NagiosEnterprises/nagioscore
@@ -17,28 +17,23 @@ msg_info "Installing Dependencies"
$STD apt install -y \ $STD apt install -y \
autoconf \ autoconf \
automake \ automake \
gcc \
libc6 \
libgd-dev \
libmcrypt-dev \
libnet-snmp-perl \
libssl-dev \
make \
openssl \
php \
apache2 \
apache2-utils \
build-essential \ build-essential \
bc \ bc \
dc \ dc \
gawk \ gawk \
gperf \
gettext \ gettext \
gperf \
libgd-dev \
libmcrypt-dev \
libnet-snmp-perl \
libssl-dev \
snmp \ snmp \
unzip \ apache2 \
wget apache2-utils
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
PHP_APACHE="YES" setup_php
fetch_and_deploy_gh_release "nagios" "NagiosEnterprises/nagioscore" "tarball" fetch_and_deploy_gh_release "nagios" "NagiosEnterprises/nagioscore" "tarball"
msg_info "Building Nagios Core" msg_info "Building Nagios Core"
@@ -52,8 +47,8 @@ $STD make install-daemoninit
$STD make install-commandmode $STD make install-commandmode
$STD make install-config $STD make install-config
$STD make install-webconf $STD make install-webconf
a2enmod rewrite >/dev/null 2>&1 $STD a2enmod rewrite
a2enmod cgi >/dev/null 2>&1 $STD a2enmod cgi
msg_ok "Built Nagios Core" msg_ok "Built Nagios Core"
fetch_and_deploy_gh_release "nagios-plugins" "nagios-plugins/nagios-plugins" "tarball" 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_ok "Built Nagios Plugins"
msg_info "Configuring Web Authentication" 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 chown root:www-data /usr/local/nagios/etc/htpasswd.users
chmod 640 /usr/local/nagios/etc/htpasswd.users chmod 640 /usr/local/nagios/etc/htpasswd.users
msg_ok "Configured Web Authentication" msg_ok "Configured Web Authentication"
@@ -75,8 +70,6 @@ msg_ok "Configured Web Authentication"
msg_info "Starting Services" msg_info "Starting Services"
systemctl enable -q --now apache2 systemctl enable -q --now apache2
systemctl enable -q --now nagios systemctl enable -q --now nagios
systemctl restart apache2
systemctl restart nagios
msg_ok "Started Services" msg_ok "Started Services"
motd_ssh motd_ssh