diff --git a/ct/nagios.sh b/ct/nagios.sh index de6ead2c6..7f4600fa7 100644 --- a/ct/nagios.sh +++ b/ct/nagios.sh @@ -29,71 +29,54 @@ 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 "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 + 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_ok "Updated successfully!" exit }