[Solved]Manual Installation for 1.3.0 Got blank screen

Support requests, bug reports, questions etc.
damcool
beginner
beginner
Posts: 8
Joined: Sun Dec 11, 2011 14:59

[Solved]Manual Installation for 1.3.0 Got blank screen

Post by damcool » Sun Dec 11, 2011 15:05

I just used my script to install the nagios with nconf. I was managed to install nconf 1.2.6-1 successfuly with my script. But failed in 1.3.0. I listed my script as below, and anyone could give me some clues for the failure reason. Thanks in advance.

Code: Select all

#!/bin/bash
BASE_DIR="$( cd "$( dirname "$0" )" && pwd )"
cd $BASE_DIR
source nagios.cfg
mkdir -p $BASE_DIR/nconf
cd $BASE_DIR/nconf
echo ">>STARTING INSTALLATION OF NCONF..."
DOWNLOAD_URL=$(check_latest_version "http://sourceforge.net/projects/nconf/files/nconf/" "nconf-" ".tgz/download" "/[0-9]{1,}(\.[0-9]{1,}){1,}-[0-9]{1,}/")
if [ $? -ne 0 ]; then
   echo ">>Sorry downloading latest NAGIOS NCONF failed!"
   echo ">>Please check your Internet connections then try agian."
   exit 1
fi
MAX_VER=${DOWNLOAD_URL##*nconf-}
MAX_VER=${MAX_VER%.tgz*}
if [[ $MAX_VER < "1.2.6-1" ]]; then
   echo ">>NCONF 1.2.6-1 found on different server..."
   DOWNLOAD_URL="https://github.com/Tontonitch/nconf-1.2.6-1/tarball/master"
   MAX_VER="1.2.6-1"
fi
echo ">>Found New Link $DOWNLOAD_URL ..."

echo ">>Downloading latest NAGIOS NCONF..."
wget $DOWNLOAD_URL --no-check-certificate -O nconf-latest.tar.gz >>/dev/null 2>&1
if [ $? -ne 0 ]; then
   echo ">>Sorry downloading latest NAGIOS NCONF failed!"
   echo ">>Please check your Internet connections then try agian."
   exit 1
fi
echo ">>Extracting download package nconf-latest.tar.gz..."
tar xvf nconf-latest.tar.gz >>/dev/null 2>&1
rm -f nconf-latest.tar.gz
EXTR_DIR=$(ls)
if [ ${#EXTR_DIR} -eq 0 ]; then
   echo ">>Sorry nothing extracted from tar file..."
   exit 1
fi
[ -d /var/www/html/nconf ] && rm -rf /var/www/html/nconf
mv $EXTR_DIR/ /var/www/html/nconf
find /var/www/html/nconf -type f -name ".gitignore" -exec rm -f {} \;

echo ">>Running configure of NCONF...."
echo ">>Setup the privileges of files and directories.."
find /var/www/html/nconf -type d -exec chmod 775 {} \;
find /var/www/html/nconf -type f -exec chmod 664 {} \;
chmod -R 775 /var/www/html/nconf/bin
chmod -R 775 /var/www/html/nconf/ADD-ONS
chmod 775 /var/www/html/nconf/{config,output,static_cfg,temp}
chcon -R --type=httpd_sys_content_t /var/www/html >>/dev/null 2>&1
echo ">>Setup config files of NCONF..."
cp /var/www/html/nconf/config.orig/* /var/www/html/nconf/config
sed -i "s/nconf/$MYSQL_USR/" /var/www/html/nconf/config/mysql.php
sed -i "s/NConf/$NCONF_DB/" /var/www/html/nconf/config/mysql.php
sed -i "s/link2db/$MYSQL_USR/" /var/www/html/nconf/config/mysql.php
sed -i "s/\"\/var\/www\/nconf\"/\"\/var\/www\/html\/nconf\"/" /var/www/html/nconf/config/nconf.php
sed -i "s/\"\/var\/www\/nconf\/bin\/nagios\"/\"\/usr\/local\/nagios\/bin\/nagios\"/" /var/www/html/nconf/config/nconf.php

echo ">>Setup MYSQL for NCONF..."
mysql -u root -p$MYSQL_ROOT_PWD <<EOF
drop database if exists $NCONF_DB;
create database $NCONF_DB;
grant all on $NCONF_DB.* to $MYSQL_USR@localhost;
flush privileges;
exit
EOF
sed -i "s/CHARSET=latin1/CHARSET=utf8/" /var/www/html/nconf/INSTALL/create_database.sql
sed -i "s/'Default Nagios'/'`hostname -s`'/" /var/www/html/nconf/INSTALL/create_database.sql
sed -i "s/'localhost.localdomain'/'`hostname`'/" /var/www/html/nconf/INSTALL/create_database.sql
sed -i "s/'localhost'/'`hostname -s`'/" /var/www/html/nconf/INSTALL/create_database.sql
mysql -u root -p$MYSQL_ROOT_PWD $NCONF_DB < /var/www/html/nconf/INSTALL/create_database.sql
mysql -u root -p$MYSQL_ROOT_PWD <<EOF
update $NCONF_DB.ConfigAttrs set poss_values=replace (poss_values,'/nagios/html/pnp4nagios/index.php?','/nagios/pnp/index.php?') where attr_name='action_url';
update $NCONF_DB.ConfigValues set attr_value='/usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl -d HOSTPERFDATA' where fk_id_attr=99 and fk_id_item=5294;
update $NCONF_DB.ConfigValues set attr_value='/usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl' where fk_id_attr=99 and fk_id_item=5295;
commit;
EOF
echo ">>Setup the web directories privileges..."
rm -fr /var/www/html/nconf/INSTALL* /var/www/html/nconf/UPDATE*
chown -R $NAGIOS_USR.$NAGIOS_GRP /var/www/html/nconf
echo ">>Configure Nagios.Cfg settings..."
sed "/^#cfg_dir=\/usr\/local\/nagios\/etc\/servers/i cfg_dir=\/usr\/local\/nagios\/etc\/global\ncfg_dir=\/usr\/local\/nagios\/etc\/`hostname -s`" /usr/local/nagios/etc/nagios.cfg >/tmp/nagios.cfg
rm -f /usr/local/nagios/etc/nagios.cfg
cp -f /tmp/nagios.cfg /usr/local/nagios/etc/nagios.cfg
sed -i "s/^cfg_file=/#cfg_file=/" /usr/local/nagios/etc/nagios.cfg
mkdir -p /usr/local/nagios/etc/global
mkdir -p /usr/local/nagios/etc/`hostname -s`
chown -R $NAGIOS_USR.$NAGIOS_GRP /usr/local/nagios
[ -f /usr/local/nagios/etc/objects/commands.cfg.bak ] && rm -f /usr/local/nagios/etc/objects/commands.cfg.bak
mv /usr/local/nagios/etc/objects/commands.cfg /usr/local/nagios/etc/objects/commands.cfg.bak
cd /var/www/html/nconf/
php include/ajax/exec_generate_config.php >>/dev/null 2>&1
service httpd restart
echo "* * * * * sh /var/www/html/nconf/ADD-ONS/deploy_local.sh" | crontab -u nagios -
echo ">>NCONF INSTALLTION COMPLETED"
sleep 60
cd /usr/local/nagios/
bin/nagios -v etc/nagios.cfg
if [ $? -ne 0 ] ; then
   echo ">>Checking nagios.cfg error!"
   echo ">>Please refer to previous information for the corrections!"
   exit 1
fi
cd
service nagios restart

Last edited by damcool on Mon Dec 12, 2011 03:18, edited 1 time in total.

User avatar
fgander
NConf developer
NConf developer
Posts: 308
Joined: Mon Mar 16, 2009 14:23
Location: Bern, Switzerland
Contact:

Re: Manual Installation for 1.3.0 Got blank screen

Post by fgander » Sun Dec 11, 2011 18:37

Hey, you are fast :) Still on updating documentation etc. :)

Interresting script... Do you have any information in the error log of apache ?
I have no time now to go through your script, perhaps you try a normal setup, and then check with your script / setup what could get wrong...

Check also the requirements etc. I suggest to make a setup over the normal GUI, INSTALL.php and try that first...
Regards Fabian
F.G. - NConf developer
http://www.nconf.org
Image
Follow NConf on Twitter!

damcool
beginner
beginner
Posts: 8
Joined: Sun Dec 11, 2011 14:59

Re: Manual Installation for 1.3.0 Got blank screen

Post by damcool » Mon Dec 12, 2011 02:04

fgander wrote:Hey, you are fast :) Still on updating documentation etc. :)

Interresting script... Do you have any information in the error log of apache ?
I have no time now to go through your script, perhaps you try a normal setup, and then check with your script / setup what could get wrong...

Check also the requirements etc. I suggest to make a setup over the normal GUI, INSTALL.php and try that first...
Regards Fabian

Hi, not I'm fast, but my script autodetect the latest version on sourceforge.net and download it for installation. :)

Please refer to below information I got from error.log and access.log of httpd
Error.log

Code: Select all

[Mon Dec 12 08:02:02 2011] [error] [client 10.160.41.124] PHP Notice:  Undefined variable: nconfdir in /var/www/html/nconf/config/nconf.php on line 11
[Mon Dec 12 08:02:02 2011] [error] [client 10.160.41.124] PHP Warning:  require_once(/include/version.php): failed to open stream: No such file or directory in /var/www/html/nconf/main.php on line 19
[Mon Dec 12 08:02:02 2011] [error] [client 10.160.41.124] PHP Fatal error:  require_once(): Failed opening required '/include/version.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/nconf/main.php on line 19
[Mon Dec 12 08:02:04 2011] [error] [client 10.160.41.124] File does not exist: /var/www/html/favicon.ico

looks like something missing.

Access.log

Code: Select all

10.160.41.124 - - [12/Dec/2011:08:02:02 +0800] "GET /nconf/ HTTP/1.1" 500 - "-" "Mozilla/5.0 (X11; Linux x86_64; rv:8.0.1) Gecko/20100101 Firefox/8.0.1"
10.160.41.124 - - [12/Dec/2011:08:02:04 +0800] "GET /favicon.ico HTTP/1.1" 404 286 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:8.0.1) Gecko/20100101 Firefox/8.0.1"

damcool
beginner
beginner
Posts: 8
Joined: Sun Dec 11, 2011 14:59

Re: [Solved]Manual Installation for 1.3.0 Got blank screen

Post by damcool » Mon Dec 12, 2011 03:18

Hi, Sir

I've solved the problem. The root cause is there are two lines in config/nconf.php, and my script only modified the one being remarked, which caused the php couldn't get right location of version.php. Thanks for your great software.

Locked