From 52980bd3dc0081edcae104db84165eb4a88bcb45 Mon Sep 17 00:00:00 2001
From: slerena <slerena@gmail.com>
Date: Thu, 2 Aug 2007 18:30:10 +0000
Subject: [PATCH] 2007-08-02  Sancho Lerena  <slerena@gmail.com>

        * Makefile.PL: Missing dep updated and .pl extensions purged.

        * All (4) startup scripts: Updated startup script.

        * lib/PandoraFMS/Config.pm: Now servers dont get "Homedir" from command line, get
        config file directly

        * bin/pandora_recon, bin/pandora_server, bin/pandora_network, bin/pandora_snmpconsole:
        Renamed (deleted .pl).



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@588 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_server/ChangeLog                       | 10 ++++++++++
 pandora_server/Makefile.PL                     |  3 ++-
 .../{pandora_network.pl => pandora_network}    |  0
 .../bin/{pandora_recon.pl => pandora_recon}    |  0
 .../bin/{pandora_server.pl => pandora_server}  |  0
 ...dora_snmpconsole.pl => pandora_snmpconsole} |  0
 pandora_server/lib/PandoraFMS/Config.pm        | 18 +++++++++---------
 pandora_server/pandora_network                 | 11 ++++++-----
 pandora_server/pandora_recon                   | 11 ++++++-----
 pandora_server/pandora_server                  | 15 ++++++++-------
 pandora_server/pandora_snmpconsole             | 13 +++++++------
 11 files changed, 48 insertions(+), 33 deletions(-)
 rename pandora_server/bin/{pandora_network.pl => pandora_network} (100%)
 rename pandora_server/bin/{pandora_recon.pl => pandora_recon} (100%)
 rename pandora_server/bin/{pandora_server.pl => pandora_server} (100%)
 rename pandora_server/bin/{pandora_snmpconsole.pl => pandora_snmpconsole} (100%)

diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog
index 61726c49f4..f2533d2f45 100644
--- a/pandora_server/ChangeLog
+++ b/pandora_server/ChangeLog
@@ -1,5 +1,15 @@
 2007-08-02  Sancho Lerena  <slerena@gmail.com>
 
+	* Makefile.PL: Missing dep updated and .pl extensions purged.
+
+	* All (4) startup scripts: Updated startup script.
+
+	* lib/PandoraFMS/Config.pm: Now servers dont get "Homedir" from command line, get 
+	config file directly
+
+	* bin/pandora_recon, bin/pandora_server, bin/pandora_network, bin/pandora_snmpconsole:
+	Renamed (deleted .pl).
+
 	* Final changes (link is now over bin, and lib is real dir, for work
 	with Makefile.PL).
 
diff --git a/pandora_server/Makefile.PL b/pandora_server/Makefile.PL
index dde9b43b3f..9d54d44be8 100644
--- a/pandora_server/Makefile.PL
+++ b/pandora_server/Makefile.PL
@@ -6,6 +6,7 @@ WriteMakefile(
 	VERSION_FROM    => 'bin/PandoraFMS/Config.pm',
 	AUTHOR 		=> 'Sancho Lerena <slerena@gmail.com>',
 	PREREQ_PM 	=> {
+		NetAddr::IP => 0,
 		DBI => 0,
                 threads::shared => 0,
                 IO::Socket => 0,
@@ -19,7 +20,7 @@ WriteMakefile(
 		SNMP => 0
     },
     EXE_FILES 		=>
-[ 'bin/pandora_server.pl', 'bin/pandora_network.pl', 'bin/pandora_recon.pl', 'bin/pandora_snmpconsole.pl'],
+[ 'bin/pandora_server', 'bin/pandora_network', 'bin/pandora_recon', 'bin/pandora_snmpconsole'],
     PMLIBDIRS  		=> [ 'lib' ],
     'dist'		=> { 'TAR' => 'tar', 'TARFLAGS' => 'cvfz', 'SUFFIX'
 => '.gz', 'COMPRESS' => 'gzip'}
diff --git a/pandora_server/bin/pandora_network.pl b/pandora_server/bin/pandora_network
similarity index 100%
rename from pandora_server/bin/pandora_network.pl
rename to pandora_server/bin/pandora_network
diff --git a/pandora_server/bin/pandora_recon.pl b/pandora_server/bin/pandora_recon
similarity index 100%
rename from pandora_server/bin/pandora_recon.pl
rename to pandora_server/bin/pandora_recon
diff --git a/pandora_server/bin/pandora_server.pl b/pandora_server/bin/pandora_server
similarity index 100%
rename from pandora_server/bin/pandora_server.pl
rename to pandora_server/bin/pandora_server
diff --git a/pandora_server/bin/pandora_snmpconsole.pl b/pandora_server/bin/pandora_snmpconsole
similarity index 100%
rename from pandora_server/bin/pandora_snmpconsole.pl
rename to pandora_server/bin/pandora_snmpconsole
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index 1924859f0e..645b8727de 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -48,7 +48,7 @@ my %pa_config;
 ##########################################################################
 
 sub help_screen {
-	printf "\n\nSyntax: \n  pandora_xxxxxxx.pl <fullpathname to PANDORA HOME directory> [ options ] \n\n";
+	printf "\n\nSyntax: \n  pandora_server < fullpathname to pandora server configuration file > [ options ] \n\n";
 	printf "Following options are optional : \n";
 	printf "            -v  :  Verbose mode activated, give more information in logfile \n";
 	printf "            -d  :  Debug mode activated, give extensive information in logfile \n";
@@ -75,7 +75,7 @@ sub pandora_init {
 
 	# Load config file from command line
 	if ($#ARGV == -1 ){
-		print "I Need at least one parameter: Complete path to Pandora FMS Server HOME Directory. \n";
+		print "I Need at least one parameter: Complete path to Pandora FMS Server configuration file. \n";
 		help_screen;
 		exit;
 	}
@@ -96,7 +96,7 @@ sub pandora_init {
 		else { ($pa_config->{"pandora_path"} = $parametro); }
 	}
 	if ($pa_config->{"pandora_path"} eq ""){
-		print "I Need at least one parameter: Complete path to Pandora FMS HOME Directory. \n";
+		print "I Need at least one parameter: Complete path to Pandora FMS configuration file. \n";
 		exit;
 	}
 }
@@ -108,7 +108,7 @@ sub pandora_init {
 sub pandora_loadconfig {
 	my $pa_config = $_[0];
 	my $opmode = $_[1]; # 0 dataserver, 1 network server, 2 snmp console, 3 recon server
-	my $archivo_cfg = $pa_config->{'pandora_path'}."/conf/pandora_server.conf";
+	my $archivo_cfg = $pa_config->{'pandora_path'};
 	my $buffer_line;
 	my @command_line;
 	my $tbuf;
@@ -121,14 +121,14 @@ sub pandora_loadconfig {
 	$pa_config->{"dbhost"} = "localhost";
 	$pa_config->{"dbname"} = "pandora";
 	$pa_config->{"basepath"}=$pa_config->{'pandora_path'}; # Compatibility with Pandora 1.1
-	$pa_config->{"incomingdir"}=$pa_config->{'pandora_path'}."/data_in";
+	$pa_config->{"incomingdir"}="/var/spool/pandor/data_in";
 	$pa_config->{"server_threshold"}=30;
 	$pa_config->{"alert_threshold"}=60;
-	$pa_config->{"logfile"}=$pa_config->{'pandora_path'}."/log/pandora_server.log";
-	$pa_config->{"errorlogfile"}=$pa_config->{'pandora_path'}."/log/pandora_server.error";
+	$pa_config->{"logfile"}="/var/log/pandora_server.log";
+	$pa_config->{"errorlogfile"}="/var/log/pandora_server.error";
 	$pa_config->{"networktimeout"}=15; 	# By default, not in config file yet
 	$pa_config->{"pandora_master"}=1; 	# on by default
-	$pa_config->{"pandora_check"}=1; 	# on by default
+	$pa_config->{"pandora_check"}=0; 	# on by default
 	$pa_config->{"snmpconsole"}=0; 	# off by default
 	$pa_config->{"version"}=$pandora_version;
 	$pa_config->{"build"}=$pandora_build;
@@ -138,7 +138,7 @@ sub pandora_loadconfig {
 	$pa_config->{"dataserver"}=0;
 	$pa_config->{"reconserver"}=0;
 	$pa_config->{"servermode"}="";
-	$pa_config->{'pandora_snmp_logfile'}="/var/log/pandora/pandora_snmptrap.log";
+	$pa_config->{'pandora_snmp_logfile'}="/var/log/pandora_snmptrap.log";
 	$pa_config->{"network_threads"}=5; # Fixed default
 	$pa_config->{"keepalive"}=60; # 60 Seconds initially for server keepalive
 	$pa_config->{"keepalive_orig"} = $pa_config->{"keepalive"};
diff --git a/pandora_server/pandora_network b/pandora_server/pandora_network
index a943a877eb..2b76276148 100755
--- a/pandora_server/pandora_network
+++ b/pandora_server/pandora_network
@@ -6,9 +6,10 @@
 # v1.3 Build 070731
 
 # Configurable path and filenames
-PANDORA_HOME="/usr/share/pandora_server"
+PANDORA_HOME="/etc/pandora"
 PANDORA_PID_PATH="/var/run/pandora"
 PANDORA_PID=$PANDORA_PID_PATH/pandora_network.pid
+PANDORA_DAEMON=/usr/bin/pandora_network.pl
 
 # Main script
 
@@ -18,7 +19,7 @@ then
 	exit
 fi
 
-if [ ! -f $PANDORA_HOME/bin/pandora_network.pl ]
+if [ ! -f $PANDORA_DAEMON ]
 then
         echo "Pandora FMS Network Server not found, please check setup and read manual"
         exit
@@ -38,10 +39,10 @@ case "$1" in
 		fi
 	fi
 	
-	cd $PANDORA_HOME/bin
-	./pandora_network.pl $PANDORA_HOME -D
+	$PANDORA_DAEMON $PANDORA_HOME -D
+	sleep 1
 
-	MYPID=`ps aux | grep 'pandora_network.pl' | grep -v grep | tail -1 | awk '{print $2}'`
+	MYPID=`ps aux | grep 'pandora_network' | grep -v grep | tail -1 | awk '{print $2}'`
 	if [ ! -z "$MYPID" ]
 	then
 		echo $MYPID > $PANDORA_PID
diff --git a/pandora_server/pandora_recon b/pandora_server/pandora_recon
index 62a1d4b315..164b0fab74 100755
--- a/pandora_server/pandora_recon
+++ b/pandora_server/pandora_recon
@@ -6,9 +6,10 @@
 # v1.3 Build 070731
 
 # Configurable path and filenames
-PANDORA_HOME="/usr/share/pandora_server"
+PANDORA_HOME="/etc/pandora"
 PANDORA_PID_PATH="/var/run/pandora"
 PANDORA_PID=$PANDORA_PID_PATH/pandora_recon.pid
+PANDORA_DAEMON=/usr/bin/pandora_recon
 
 # Main script
 
@@ -18,7 +19,7 @@ then
 	exit
 fi
 
-if [ ! -f $PANDORA_HOME/bin/pandora_recon.pl ]
+if [ ! -f $PANDORA_DAEMON ] 
 then
         echo "Pandora FMS Recon Server not found, please check setup and read manual"
         exit
@@ -38,10 +39,10 @@ case "$1" in
 		fi
 	fi
 	
-	cd $PANDORA_HOME/bin
-	./pandora_recon.pl $PANDORA_HOME -D
+	$PANDORA_DAEMON $PANDORA_HOME -D
+	sleep 1
 
-	MYPID=`ps aux | grep 'pandora_recon.pl' | grep -v grep | tail -1 | awk '{print $2}'`
+	MYPID=`ps aux | grep 'pandora_recon' | grep -v grep | tail -1 | awk '{print $2}'`
 	if [ ! -z "$MYPID" ]
 	then
 		echo $MYPID > $PANDORA_PID
diff --git a/pandora_server/pandora_server b/pandora_server/pandora_server
index 0b069ee0fe..7d9a8c6c05 100755
--- a/pandora_server/pandora_server
+++ b/pandora_server/pandora_server
@@ -3,12 +3,13 @@
 # Pandora Data Server, startup script
 # Sancho Lerena, <slerena@gmail.com>
 # Linux Version (generico)
-# v1.3 Build 070731
+# v1.3 Build 070802
 
 # Configurable path and filenames
-PANDORA_HOME="/usr/share/pandora_server"
+PANDORA_HOME="/etc/pandora"
 PANDORA_PID_PATH="/var/run/pandora"
 PANDORA_PID=$PANDORA_PID_PATH/pandora_dataserver.pid
+PANDORA_DAEMON=/usr/bin/pandora_server
 
 # Main script
 
@@ -18,7 +19,7 @@ then
 	exit
 fi
 
-if [ ! -f $PANDORA_HOME/bin/pandora_server.pl ]
+if [ ! -f $PANDORA_DAEMON ]
 then
         echo "Pandora FMS Data Server not found, please check setup and read manual"
         exit
@@ -30,7 +31,7 @@ case "$1" in
 	if [ -f $PANDORA_PID ]
 	then
 		CHECK_PID=`cat $PANDORA_PID`
-		CHECK_PID_RESULT=`ps aux | grep -v grep | grep "$CHECK_PID" | grep "pandora_server.pl" | wc -l`
+		CHECK_PID_RESULT=`ps aux | grep -v grep | grep "$CHECK_PID" | grep "pandora_server" | wc -l`
 		if [ $CHECK_PID_RESULT == 1 ]
 		then
 			echo "Pandora FMS Data Server is currently running on this machine with PID ($CHECK_PID). Aborting now..."
@@ -38,10 +39,10 @@ case "$1" in
 		fi
 	fi
 	
-	cd $PANDORA_HOME/bin
-	./pandora_server.pl $PANDORA_HOME -D
+	$PANDORA_DAEMON $PANDORA_HOME -D
+	sleep 1
 
-	MYPID=`ps aux | grep 'pandora_server.pl' | grep -v grep | tail -1 | awk '{print $2}'`
+	MYPID=`ps aux | grep 'pandora_server' | grep -v grep | tail -1 | awk '{print $2}'`
 	if [ ! -z "$MYPID" ]
 	then
 		echo $MYPID > $PANDORA_PID
diff --git a/pandora_server/pandora_snmpconsole b/pandora_server/pandora_snmpconsole
index 41ed15c8ca..5d46782a2e 100755
--- a/pandora_server/pandora_snmpconsole
+++ b/pandora_server/pandora_snmpconsole
@@ -3,15 +3,16 @@
 # Startup script for Pandora SNMP Console
 # Sancho Lerena, <slerena@gmail.com>
 # Linux Version (generic)
-# v1.3 BUILD 070731 
+# v1.3 BUILD 070802
 
 # Compatible with NetSNMP 5.1 or higher
 
 # Configurable path and filenames
 
-PANDORA_HOME="/usr/share/pandora_server"
+PANDORA_HOME="/etc/pandora"
 PANDORA_PID_PATH="/var/run/pandora"
 PANDORA_PID=$PANDORA_PID_PATH/pandora_snmp.pid
+PANDORA_DAEMON=/usr/bin/pandora_snmpconsole
 
 DAEMON_LOG="/var/log/pandora/pandora_snmptrap.log"
 DAEMON_PID="$PANDORA_PID_PATH/pandora_snmptrapd.pid"
@@ -90,7 +91,7 @@ case "$1" in
 	if [ -f $PANDORA_PID ]
         then
                 CHECK_PID=`cat $PANDORA_PID`
-                CHECK_PID_RESULT=`ps aux | grep -v grep | grep "$CHECK_PID" | grep "pandora_snmpconsole.pl" | wc -l`
+                CHECK_PID_RESULT=`ps aux | grep -v grep | grep "$CHECK_PID" | grep "pandora_snmpconsole" | wc -l`
                 if [ $CHECK_PID_RESULT == 1 ]
                 then
                         echo "Pandora FMS SNMP Server is currently running on this machine with PID ($CHECK_PID). Aborting now..."
@@ -98,10 +99,10 @@ case "$1" in
                 fi
         fi
 
-	cd $PANDORA_HOME/bin
-	./pandora_snmpconsole.pl $PANDORA_HOME -D
+	$PANDORA_DAEMON $PANDORA_HOME -D
+	sleep 1
 
-	MYPID=`ps aux | grep 'pandora_snmpconsole.pl' | grep -v grep | tail -1 | awk '{print $2}'`
+	MYPID=`ps aux | grep 'pandora_snmpconsole' | grep -v grep | tail -1 | awk '{print $2}'`
 	if [ ! -z "$MYPID" ]
 	then
 		echo $MYPID > $PANDORA_PID