feat: update Nagios installation and configuration scripts for improved paths and dependencies
This commit is contained in:
76
ct/nagios.sh
76
ct/nagios.sh
@@ -24,22 +24,76 @@ function update_script() {
|
||||
check_container_storage
|
||||
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!"
|
||||
exit
|
||||
fi
|
||||
|
||||
msg_info "Updating Nagios Packages"
|
||||
$STD apt update
|
||||
$STD apt install -y --only-upgrade nagios4 nagios-plugins-contrib apache2
|
||||
msg_ok "Updated Nagios Packages"
|
||||
local core_update=0
|
||||
local plugins_update=0
|
||||
|
||||
msg_info "Restarting Services"
|
||||
systemctl restart nagios4
|
||||
systemctl restart apache2
|
||||
msg_ok "Restarted Services"
|
||||
if check_for_gh_release "nagios" "NagiosEnterprises/nagioscore"; then
|
||||
core_update=1
|
||||
fi
|
||||
|
||||
msg_ok "Updated successfully!"
|
||||
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!"
|
||||
fi
|
||||
exit
|
||||
}
|
||||
|
||||
@@ -50,4 +104,4 @@ 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}/nagios4${CL}"
|
||||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}/nagios${CL}"
|
||||
|
||||
Reference in New Issue
Block a user