From 0ebb69dbe4fc511cabf64d820396886747353f67 Mon Sep 17 00:00:00 2001
From: Ramon Novoa <rnovoa@artica.es>
Date: Fri, 7 Jun 2013 11:43:34 +0000
Subject: [PATCH] 2013-06-07  Ramon Novoa  <rnovoa@artica.es>

	* pandora_server_installer: Fixed a bug that created
	  pandora_server.conf.new even if pandora_server.conf did not exists.
	  Remove PERL libs when uninstalling.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8274 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_server/ChangeLog                |  6 +++++
 pandora_server/pandora_server_installer | 35 +++++++++++++++++++------
 2 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog
index 1a240991f1..7243390d01 100644
--- a/pandora_server/ChangeLog
+++ b/pandora_server/ChangeLog
@@ -1,3 +1,9 @@
+2013-06-07  Ramon Novoa  <rnovoa@artica.es>
+
+	* pandora_server_installer: Fixed a bug that created
+	  pandora_server.conf.new even if pandora_server.conf did not exists.
+	  Remove PERL libs when uninstalling.
+
 2013-06-07  Ramon Novoa  <rnovoa@artica.es>
 
 	* lib/PandoraFMS/Core.pm: Return undef from get_agent_from_name if the
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index 159d62d468..cf9fe05be3 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -278,14 +278,14 @@ perl-TimeDate perl-XML-Simple perl-XML-Twig perl-libwww-perl mysql-client"
 		
 		echo "Creating setup directory in $PANDORA_CFG_DIR"
 		mkdir $PANDORA_CFG_DIR 2> /dev/null
-		if [ -e $PANDORA_CFG_FILE ]
-		then
-			OLDFILENAMETMP=`date +"%Y-%m-%d"`
-			echo "Old installation detected, backing up pandora_server.conf.$ODFILENAMETMP"
-			mv $PANDORA_CFG_FILE $PANDORA_CFG_FILE.$OLDFILENAMETMP
-		fi
 		if [ "$DISTRO" = "FreeBSD" ]
 		then
+			if [ -e $PANDORA_CFG_FILE ]
+			then
+				OLDFILENAMETMP=`date +"%Y-%m-%d"`
+				echo "Old installation detected, backing up pandora_server.conf.$ODFILENAMETMP"
+				mv $PANDORA_CFG_FILE $PANDORA_CFG_FILE.$OLDFILENAMETMP
+			fi
 			echo cp FreeBSD/pandora_server.conf $PANDORA_CFG_DIR
                 	cp FreeBSD/pandora_server.conf $PANDORA_CFG_DIR
 		elif [ "$DISTRO" = "NetBSD" ]
@@ -294,11 +294,23 @@ perl-TimeDate perl-XML-Simple perl-XML-Twig perl-libwww-perl mysql-client"
 			then
 				mkdir -p $PANDORA_CFG_DIR
 			fi
+			if [ -e $PANDORA_CFG_FILE ]
+			then
+				OLDFILENAMETMP=`date +"%Y-%m-%d"`
+				echo "Old installation detected, backing up pandora_server.conf.$ODFILENAMETMP"
+				mv $PANDORA_CFG_FILE $PANDORA_CFG_FILE.$OLDFILENAMETMP
+			fi
 			echo cp NetBSD/pandora_server.conf $PANDORA_CFG_DIR
 			cp NetBSD/pandora_server.conf $PANDORA_CFG_DIR     
 		else
-			echo cp conf/pandora_server.conf.new $PANDORA_CFG_DIR
-			cp conf/pandora_server.conf.new $PANDORA_CFG_DIR
+			if [ -f "$PANDORA_CFG_FILE" ]
+			then
+				echo cp conf/pandora_server.conf.new $PANDORA_CFG_DIR
+				cp conf/pandora_server.conf.new $PANDORA_CFG_DIR
+			else
+			echo cp conf/pandora_server.conf.new $PANDORA_CFG_FILE
+				cp conf/pandora_server.conf.new $PANDORA_CFG_FILE
+			fi
 		fi
 		chmod 770 $PANDORA_CFG_FILE
 
@@ -500,6 +512,9 @@ uninstall_bsd () {
 		TMP_CRONTAB=/tmp/crontab.tmp
         fi
 
+	echo "Removing PERL libs"
+	rm -rf /usr/lib/perl5/PandoraFMS/
+
 	echo "Removing Pandora Servers"
 	rm -Rf $PANDORA_SPOOL/data_in/
 
@@ -532,6 +547,10 @@ uninstall () {
 			echo "This is not a Linux-based distro. Uninstaller is currently not working for your OS"
 		fi
 	fi
+
+	echo "Removing PERL libs"
+	rm -rf /usr/lib/perl5/PandoraFMS/
+
 	echo "Removing Pandora Servers"
 	if [ -d $PANDORA_SPOOL/data_out ]; then
 		rm -Rf $PANDORA_SPOOL/data_in