Author: Lars Michelsen <[email protected]> Date: Wed May 25 20:05:26 2011 +0200 Committer: Lars Michelsen <[email protected]> Commit-Date: Wed May 25 20:05:26 2011 +0200
Added omd_install.sh to install NagVis to the local/ path of OMD sites --- ChangeLog | 4 + omd_install.sh | 192 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index baad877..ff5a094 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 1.6b2 +Core + * Added omd_install.sh to install NagVis to the local/ path of OMD sites + (ONLY FOR TESTING!!!) + Frontend * Bugfix: Added missing controls to services which are displayed as gadgets diff --git a/omd_install.sh b/omd_install.sh new file mode 100755 index 0000000..0121288 --- /dev/null +++ b/omd_install.sh @@ -0,0 +1,192 @@ +#!/bin/bash +# omd_install.sh - Installs NagVis to the local/ path of OMD sites +# +# Copyright (c) 2004-2011 NagVis Project (Contact: [email protected]) +# +# Development: +# Lars Michelsen <[email protected]> +# +# License: +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +echo "+--------------------------------------------------------------------+" +echo "| This script installs NagVis into the local/ path of your OMD site. |" +echo "| The installation in the local/ path will then override the default |" +echo "| NagVis installation included with OMD. |" +echo "| |" +echo "| When installed in local/ path NagVis will use the config and user |" +echo "| files of the site. |" +echo "| |" +echo "| ONLY RECOMMENDED FOR TESTING |" +echo "+--------------------------------------------------------------------+" + +if [ -z "$OMD_SITE" ] || [ -z "$OMD_ROOT" ]; then + echo "ERROR: You are not within an OMD site. Check out http://omdistro.org/ for easy installable and manageable Nagios." + exit 1 +fi + +echo "Installing..." + +# 1.5 had the userfiles dir in $OMD_ROOT/var/nagvis/userfiles +# Test if this is the first installation of NagVis 1.6x in this +# site. If so: Copy the contents of the old userfiles dir to the +# new location +if [ ! -d $OMD_ROOT/local/share/nagvis/htdocs/userfiles ]; then + mkdir -p $OMD_ROOT/local/share/nagvis/htdocs/userfiles + cp -r $OMD_ROOT/var/nagvis/userfiles/* $OMD_ROOT/local/share/nagvis/htdocs/userfiles +fi + +mkdir -p $OMD_ROOT/local/share/nagvis/htdocs +cp -r share/* $OMD_ROOT/local/share/nagvis/htdocs + +# Update "old" (1.5) userfiles dir +if [ -d $OMD_ROOT/var/nagvis/userfiles ]; then + cp -r share/userfiles/* $OMD_ROOT/var/nagvis/userfiles +fi + +# Backup the nagvis-omd.ini.php on first time using omd_install.sh +if ! grep omd_install.sh $OMD_ROOT/etc/nagvis/nagvis-omd.ini.php >/dev/null 2>&1; then + cp $OMD_ROOT/etc/nagvis/nagvis-omd.ini.php $OMD_ROOT/etc/nagvis/nagvis-omd.ini.php.bak +fi + +# Update omd specific nagvis.ini.php file +cat > $OMD_ROOT/etc/nagvis/nagvis-omd.ini.php <<EOF +; <?php return 1; ?> +; ----------------------------------------------------------------- +; Don't touch this file. It is under control of OMD. Modifying this +; file might break the update mechanism of OMD. +; +; If you want to customize your NagVis configuration please use the +; etc/nagvis/nagvis.ini.php file. +; +; Tainted by omd_install.sh for installation to local/ +; ----------------------------------------------------------------- + +[global] +sesscookiepath="/$OMD_SITE/nagvis" + +[paths] +base="$OMD_ROOT/local/share/nagvis/" +cfg="$OMD_ROOT/etc/nagvis/" +mapcfg="$OMD_ROOT/etc/nagvis/maps/" +automapcfg="$OMD_ROOT/etc/nagvis/automaps/" +var="$OMD_ROOT/tmp/nagvis/" +sharedvar="$OMD_ROOT/tmp/nagvis/share/" +profiles="$OMD_ROOT/var/nagvis/profiles/" +htmlbase="/$OMD_SITE/nagvis" +htmlcgi="/$OMD_SITE/nagios/cgi-bin" + +[defaults] +backend="$OMD_SITE" + +[backend_$OMD_SITE] +backendtype="mklivestatus" +socket="unix:$OMD_ROOT/tmp/run/live" +EOF + +# Backup the agvis.conf on first time using omd_install.sh +if ! grep omd_install.sh $OMD_ROOT/etc/apache/conf.d/nagvis.conf >/dev/null 2>&1; then + cp $OMD_ROOT/etc/apache/conf.d/nagvis.conf $OMD_ROOT/etc/apache/conf.d/nagvis.conf.bak +fi + +cat > $OMD_ROOT/etc/apache/conf.d/nagvis.conf <<EOF +# NagVis Apache2 configuration file for use in OMD +# +# This file has been created by omd_install.sh which installs NagVis into +# the local hierarchy of an OMD site. +# ############################################################################# + +Alias /$OMD_SITE/nagvis/var "$OMD_ROOT/tmp/nagvis/share" +Alias /$OMD_SITE/nagvis "$OMD_ROOT/local/share/nagvis/htdocs" + +<Directory "$OMD_ROOT/tmp/nagvis/share"> + Options FollowSymLinks + AllowOverride None +</Directory> + +<Directory "$OMD_ROOT/local/share/nagvis/htdocs"> + Options FollowSymLinks + AllowOverride None + + # With installed and enabled mod_rewrite there are several redirections + # available to fix deprecated and/or wrong urls. None of those rules is + # mandatory to get NagVis working. + <IfModule mod_rewrite.c> + RewriteEngine On + RewriteBase /$OMD_SITE/nagvis + + # Use mod_rewrite for old url redirection even if there are php files which + # redirect the queries itselfs. In some cases the mod_rewrite redirect + # is better than the php redirect. + RewriteCond %{REQUEST_URI} ^/$OMD_SITE/nagvis(/index\.php|/|)(\?.*|)$ + RewriteRule ^(index\.php|)(\?.*|)$ /$OMD_SITE/nagvis/frontend/nagvis-js/$1$2 [R=301,L] + RewriteCond %{REQUEST_URI} ^/$OMD_SITE/nagvis/config\.php.*$ + RewriteRule ^config\.php(.*) /$OMD_SITE/nagvis/frontend/wui/$1 [R=301,L] + + # Redirect old regular map links + RewriteCond %{REQUEST_URI} ^/$OMD_SITE/nagvis/frontend/nagvis-js + RewriteCond %{QUERY_STRING} map=(.*) + RewriteRule ^(.*)$ /$OMD_SITE/nagvis/frontend/nagvis-js/index.php?mod=Map&act=view&show=%1 [R=301,L] + + # Redirect old wui map links + RewriteCond %{REQUEST_URI} ^/$OMD_SITE/nagvis/frontend/wui + RewriteCond %{QUERY_STRING} map=(.*) + RewriteRule ^(.*)$ /$OMD_SITE/nagvis/frontend/wui/index.php?mod=Map&act=edit&show=%1 [R=301,L] + + # Redirect old rotation calls + RewriteCond %{REQUEST_URI} ^/$OMD_SITE/nagvis/frontend/nagvis-js + RewriteCond %{QUERY_STRING} !mod + RewriteCond %{QUERY_STRING} rotation=(.*) + RewriteRule ^(.*)$ /$OMD_SITE/nagvis/frontend/nagvis-js/index.php?mod=Rotation&act=view&show=%1 [R=301,L] + </IfModule> +</Directory> +EOF + +patch -s $OMD_ROOT/local/share/nagvis/htdocs/server/core/defines/global.php <<EOF +--- nagvis-1.5.3/share/server/core/defines/global.php.orig 2010-10-02 19:43:58.000000000 +0200 ++++ nagvis-1.5.3/share/server/core/defines/global.php 2010-10-02 19:47:00.000000000 +0200 +@@ -64,7 +64,7 @@ + define('DEBUGLEVEL', 6); + + // Path to the debug file +-define('DEBUGFILE', '../../../var/nagvis-debug.log'); ++define('DEBUGFILE', join(array_slice(explode('/' ,dirname(\$_SERVER["SCRIPT_FILENAME"])), 0, -6), '/').'/tmp/nagvis/nagvis-debug.log'); + + // It is possible to define a second main configuration file + // to pre-define some options in a file the user may not be +@@ -78,14 +78,14 @@ + // The last value wins. + // + // Path to the main configuration file +-define('CONST_MAINCFG', '../../../etc/nagvis.ini.php'); +-define('CONST_MAINCFG_CACHE', '../../../var/nagvis.ini.php'); ++define('CONST_MAINCFG', join(array_slice(explode('/' ,dirname(\$_SERVER["SCRIPT_FILENAME"])), 0, -6), '/').'/etc/nagvis/nagvis.ini.php'); ++define('CONST_MAINCFG_CACHE', join(array_slice(explode('/' ,dirname(\$_SERVER["SCRIPT_FILENAME"])), 0, -6), '/').'/tmp/nagvis/nagvis.ini.php'); + + // Path to "site" main configuration file +-//define('CONST_MAINCFG_SITE', '../../../etc/nagvis-site.ini.php'); ++define('CONST_MAINCFG_SITE', join(array_slice(explode('/' ,dirname(\$_SERVER["SCRIPT_FILENAME"])), 0, -6), '/').'/etc/nagvis/nagvis-omd.ini.php'); + + // The directory below the NagVis root which is shared by the webserver +-define('HTDOCS_DIR', 'share'); ++define('HTDOCS_DIR', 'htdocs'); + + // Needed minimal PHP version + define('CONST_NEEDED_PHP_VERSION', '5.0'); +EOF + +echo " ...done." + +exit 0 ------------------------------------------------------------------------------ vRanger cuts backup time in half-while increasing security. With the market-leading solution for virtual backup and recovery, you get blazing-fast, flexible, and affordable data protection. Download your free trial now. http://p.sf.net/sfu/quest-d2dcopy1 _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
