feat: update Nagios installation and configuration scripts for improved paths and dependencies

This commit is contained in:
MickLesk
2026-04-25 22:56:01 +02:00
parent de34267e30
commit e109ac9286
3 changed files with 121 additions and 20 deletions

View File

@@ -24,22 +24,76 @@ function update_script() {
check_container_storage check_container_storage
check_container_resources check_container_resources
if [[ ! -f /etc/nagios4/nagios.cfg ]]; then if [[ ! -f /usr/local/nagios/etc/nagios.cfg ]]; then
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi fi
msg_info "Updating Nagios Packages" local core_update=0
$STD apt update local plugins_update=0
$STD apt install -y --only-upgrade nagios4 nagios-plugins-contrib apache2
msg_ok "Updated Nagios Packages"
msg_info "Restarting Services" if check_for_gh_release "nagios" "NagiosEnterprises/nagioscore"; then
systemctl restart nagios4 core_update=1
systemctl restart apache2 fi
msg_ok "Restarted Services"
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"
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!" msg_ok "Updated successfully!"
fi
exit exit
} }
@@ -50,4 +104,4 @@ description
msg_ok "Completed Successfully!\n" msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}/nagios4${CL}" echo -e "${TAB}${GATEWAY}${BGN}http://${IP}/nagios${CL}"

View File

@@ -15,20 +15,67 @@ update_os
msg_info "Installing Dependencies" msg_info "Installing Dependencies"
$STD apt install -y \ $STD apt install -y \
autoconf \
automake \
gcc \
libc6 \
libgd-dev \
libmcrypt-dev \
libnet-snmp-perl \
libssl-dev \
make \
openssl \
php \
apache2 \
apache2-utils \ apache2-utils \
nagios4 \ build-essential \
nagios-plugins-contrib bc \
dc \
gawk \
gettext \
snmp \
unzip \
wget
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
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"
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"
msg_info "Configuring Web Authentication" msg_info "Configuring Web Authentication"
htpasswd -bc /etc/nagios4/htpasswd.users nagiosadmin nagiosadmin htpasswd -bc /usr/local/nagios/etc/htpasswd.users nagiosadmin nagiosadmin
chown root:www-data /etc/nagios4/htpasswd.users chown root:www-data /usr/local/nagios/etc/htpasswd.users
chmod 640 /etc/nagios4/htpasswd.users chmod 640 /usr/local/nagios/etc/htpasswd.users
msg_ok "Configured Web Authentication" msg_ok "Configured Web Authentication"
msg_info "Starting Services" msg_info "Starting Services"
systemctl enable -q --now nagios4
systemctl enable -q --now apache2 systemctl enable -q --now apache2
systemctl enable -q --now nagios
systemctl restart apache2
systemctl restart nagios
msg_ok "Started Services" msg_ok "Started Services"
motd_ssh motd_ssh

View File

@@ -17,7 +17,7 @@
{ {
"type": "default", "type": "default",
"script": "ct/nagios.sh", "script": "ct/nagios.sh",
"config_path": "/etc/nagios4/nagios.cfg", "config_path": "/usr/local/nagios/etc/nagios.cfg",
"resources": { "resources": {
"cpu": 2, "cpu": 2,
"ram": 2048, "ram": 2048,
@@ -33,11 +33,11 @@
}, },
"notes": [ "notes": [
{ {
"text": "After first login, change the default web password in /etc/nagios4/htpasswd.users.", "text": "After first login, change the default web password in /usr/local/nagios/etc/htpasswd.users.",
"type": "warning" "type": "warning"
}, },
{ {
"text": "Web UI path is /nagios4 on port 80.", "text": "Web UI path is /nagios on port 80.",
"type": "info" "type": "info"
} }
] ]