From 64502c45bac1367b80c3aacdc6c41a0073d30c61 Mon Sep 17 00:00:00 2001
From: raulmateos <noreply@pandorafms.org>
Date: Sun, 29 Nov 2009 13:35:16 +0000
Subject: [PATCH] 2009-11-29  Raul Mateos  <raulofpandora@gmail.com>

	* linux/pandora_agent_installer: Added Ubuntu specific stop scripts.
	Added link removing with update-rc.d. Changed temp directory (it
	added duplicated data_out directories). Use tabs instead spaces.

	* linux/pandora_agent_daemon: Use log file in /var/log/pandora/ directory.

	* linux/pandora_agent.conf: Changed temp directory to the one created
	by installer.

	* linux/DEBIAN/control, DEBIAN/make_deb_package.sh: Changed string from rc2
	to RC3.

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2141 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_agents/ChangeLog                      |  16 +-
 pandora_agents/linux/DEBIAN/control           |   2 +-
 .../linux/DEBIAN/make_deb_package.sh          |   2 +-
 pandora_agents/linux/pandora_agent.conf       |   2 +-
 pandora_agents/linux/pandora_agent_daemon     |   4 +-
 pandora_agents/linux/pandora_agent_installer  | 217 +++++++++---------
 6 files changed, 133 insertions(+), 110 deletions(-)

diff --git a/pandora_agents/ChangeLog b/pandora_agents/ChangeLog
index 57ae6ad978..eb1d50f6a4 100644
--- a/pandora_agents/ChangeLog
+++ b/pandora_agents/ChangeLog
@@ -1,6 +1,20 @@
+2009-11-29  Raul Mateos  <raulofpandora@gmail.com>
+
+	* linux/pandora_agent_installer: Added Ubuntu specific stop scripts.
+	Added link removing with update-rc.d. Changed temp directory (it
+	added duplicated data_out directories). Use tabs instead spaces.
+
+	* linux/pandora_agent_daemon: Use log file in /var/log/pandora/ directory.
+
+	* linux/pandora_agent.conf: Changed temp directory to the one created
+	by installer.
+
+	* linux/DEBIAN/control, DEBIAN/make_deb_package.sh: Changed string from rc2
+	to RC3.
+
 2009-11-19 Sancho Lerena <slerena@artica.es>
 
-	*    unix/pandora_agent_installer: Updated help to avoid confussion about force
+	* unix/pandora_agent_installer: Updated help to avoid confussion about force
 	install mode.
 
 	* unix/pandora_agent.spec: Create temp directory. Fixed.
diff --git a/pandora_agents/linux/DEBIAN/control b/pandora_agents/linux/DEBIAN/control
index d1c429181f..6ec731f47b 100755
--- a/pandora_agents/linux/DEBIAN/control
+++ b/pandora_agents/linux/DEBIAN/control
@@ -1,5 +1,5 @@
 package: PandoraFMS-Agent
-Version: 3.0.0.rc2
+Version: 3.0.0.RC3
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/linux/DEBIAN/make_deb_package.sh b/pandora_agents/linux/DEBIAN/make_deb_package.sh
index 30f7251e70..7852d327cd 100644
--- a/pandora_agents/linux/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/linux/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_agent_version="3.0.0.rc2"
+pandora_agent_version="3.0.0.RC3"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/linux/pandora_agent.conf b/pandora_agents/linux/pandora_agent.conf
index ddb11ac9eb..a64eedb1ff 100755
--- a/pandora_agents/linux/pandora_agent.conf
+++ b/pandora_agents/linux/pandora_agent.conf
@@ -9,7 +9,7 @@
 
 server_ip 	localhost
 server_path 	/var/spool/pandora/data_in
-temporal    	/tmp
+temporal    	/var/spool/pandora/data_out
 logfile		/var/log/pandora/pandora_agent.log
 
 # Interval in seconds, 300 by default
diff --git a/pandora_agents/linux/pandora_agent_daemon b/pandora_agents/linux/pandora_agent_daemon
index ad0d048b30..2e7651e50e 100755
--- a/pandora_agents/linux/pandora_agent_daemon
+++ b/pandora_agents/linux/pandora_agent_daemon
@@ -19,7 +19,7 @@
 PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
 PANDORA_PATH=/etc/pandora
 DAEMON=/usr/bin/pandora_agent
-LOGFILE=/var/log/pandora_agent.log
+LOGFILE=/var/log/pandora/pandora_agent.log
 
 # This function replace pidof, not working in the same way in different linux distros
 
@@ -57,7 +57,7 @@ case "$1" in
 			echo "Pandora FMS Agent is not running, cannot stop it. Aborting now..."
 			exit 1
 		else
-			echo "Stopping Pandora Agent."
+			echo "Stopping Pandora FMS Agent."
 			kill $PANDORA_PID > /dev/null 2>&1        
 		fi
 	;;
diff --git a/pandora_agents/linux/pandora_agent_installer b/pandora_agents/linux/pandora_agent_installer
index 19b7240865..29ca9e74f7 100755
--- a/pandora_agents/linux/pandora_agent_installer
+++ b/pandora_agents/linux/pandora_agent_installer
@@ -4,7 +4,7 @@
 # Linux Version (generic), for SuSe and Debian/Ubuntu only
 # other Linux distros could not work properly without modifications
 # Please see http://www.pandorafms.org
-# v3.0 Build 090810
+# v3.0.1 Build 091129
 # This code is licensed under GPL 2.0 license.
 # **********************************************************************
 
@@ -67,6 +67,7 @@ get_distro () {
 }
 
 uninstall () {
+	DISTRO=`get_distro`
         echo "Removing Pandora FMS Agent..."
         rm -Rf $PANDORA_BIN
         rm -Rf $PANDORA_TEMP
@@ -75,124 +76,132 @@ uninstall () {
         rm -Rf $PANDORA_HOME
         rm -Rf $PANDORA_LOG
 	rm -Rf $TENTACLE
+	if [ "$DISTRO" == "UBUNTU" ]
+		then
+	        # Removing linking daemon scripts
+		update-rc.d -f pandora_agent_daemon remove
+	fi
         echo "Done"
 }
 
 install () {
+	DISTRO=`get_distro`
+	OLDFILENAMETMP=`date +"%Y-%m-%d"`
 
-		DISTRO=`get_distro`
-		OLDFILENAMETMP=`date +"%Y-%m-%d"`
+	echo "Detecting Linux distribution: $DISTRO"
 		
-		echo "Detecting Linux distribution: $DISTRO"
-		
-        if [ -f $PANDORA_HOME ] && [ "$FORCE" = "0" ]
-        then
-                echo "Seems that default dir already exists. Please use --force to"
-                echo "force installer to install on $PANDORA_HOME"
-                exit
-        else
-                echo "Checking default dir $PANDORA_HOME..."
-        fi
+	if [ -f $PANDORA_HOME ] && [ "$FORCE" = "0" ]
+	then
+		echo "Seems that default dir already exists. Please use --force-install to"
+		echo "force installer to install on $PANDORA_HOME"
+		exit
+	else
+		echo "Checking default dir $PANDORA_HOME..."
+	fi
 
-        if [ -f $PANDORA_BIN ] && [ "$FORCE" = "0" ]
-        then
-                echo "Seems that $PANDORA_BIN already exists. Please use --force to"
-                echo "force installer to reinstall overwriting it"
-                echo " "
-                exit
-        else
-                echo "Checking Pandora FMS Agent on $PANDORA_BIN...."
-        fi
+	if [ -f $PANDORA_BIN ] && [ "$FORCE" = "0" ]
+	then
+		echo "Seems that $PANDORA_BIN already exists. Please use --force-install to"
+		echo "force installer to reinstall overwriting it"
+		echo " "
+		exit
+	else
+		echo "Checking Pandora FMS Agent on $PANDORA_BIN...."
+	fi
 
-        # Create directories
-        echo "Creating Pandora FMS Agent home directory at $PANDORA_HOME ..."
-        mkdir $PANDORA_HOME 2> /dev/null
-        mkdir -p $PANDORA_TEMP/data_out 2> /dev/null
-        mkdir $PANDORA_CFG 2> /dev/null
-		mkdir /var/log/pandora 2> /dev/null
+	# Create directories
+	echo "Creating Pandora FMS Agent home directory at $PANDORA_HOME ..."
+	mkdir $PANDORA_HOME 2> /dev/null
+	mkdir -p $PANDORA_TEMP 2> /dev/null
+	mkdir $PANDORA_CFG 2> /dev/null
+	mkdir /var/log/pandora 2> /dev/null
 
-        # Create logfile
-        if [ ! -z "`touch $PANDORA_LOG`" ]
-        then
-                echo "Seems to be a problem generating logfile ($PANDORA_LOG) please check it";
-        else
-                echo "Creating logfile at $PANDORA_LOG..."
-        fi
+	# Create logfile
+	if [ ! -z "`touch $PANDORA_LOG`" ]
+	then
+		echo "Seems to be a problem generating logfile ($PANDORA_LOG) please check it";
+	else
+		echo "Creating logfile at $PANDORA_LOG..."
+	fi
 
-        echo "$LOG_TIMESTAMP Pandora FMS installer has created this file at startup" > $PANDORA_LOG
+	echo "$LOG_TIMESTAMP Pandora FMS installer has created this file at startup" > $PANDORA_LOG
 
-        # Copying agent and securing it
-        echo "Copying Pandora FMS Agent to $PANDORA_BIN..."
-        cp pandora_agent $PANDORA_BIN
-        chmod 700 $PANDORA_BIN
-	
-		echo "Copying Pandora FMS Agent contrib dir to $PANDORA_HOME/..."
-        cp pandora_agent_daemon $PANDORA_HOME
+	# Copying agent and securing it
+	echo "Copying Pandora FMS Agent to $PANDORA_BIN..."
+	cp pandora_agent $PANDORA_BIN
+	chmod 700 $PANDORA_BIN
 
-        echo "Copying Pandora FMS Agent configuration file to $PANDORA_HOME/pandora_agent.conf..."
-        if [ -e /etc/pandora/pandora_agent.conf ]
-        then
-        	cat /etc/pandora/pandora_agent.conf > /etc/pandora/pandora_agent.conf.$OLDFILENAMETMP
-        	echo "Backing up old configuration file to /etc/pandora_agent.conf.$OLDFILENAMETMP"
-        fi
+	echo "Copying Pandora FMS Agent contrib dir to $PANDORA_HOME/..."
+	cp pandora_agent_daemon $PANDORA_HOME
+
+	echo "Copying Pandora FMS Agent configuration file to $PANDORA_HOME/pandora_agent.conf..."
+	if [ -e /etc/pandora/pandora_agent.conf ]
+	then
+		cat /etc/pandora/pandora_agent.conf > /etc/pandora/pandora_agent.conf.$OLDFILENAMETMP
+		echo "Backing up old configuration file to /etc/pandora_agent.conf.$OLDFILENAMETMP"
+	fi
         
-        echo "Copying default agent configuration to $PANDORA_HOME/pandora_agent.conf"
-        cp pandora_agent.conf $PANDORA_HOME/pandora_agent.conf
-        chmod 600 $PANDORA_HOME/pandora_agent.conf
+	echo "Copying default agent configuration to $PANDORA_HOME/pandora_agent.conf"
+	cp pandora_agent.conf $PANDORA_HOME/pandora_agent.conf
+	chmod 600 $PANDORA_HOME/pandora_agent.conf
 
-        echo "Copying Pandora FMS Agent plugins to $PANDORA_HOME/plugins..."
-        cp -r plugins $PANDORA_HOME
-        chmod -R 700 $PANDORA_HOME/plugins
+	echo "Copying Pandora FMS Agent plugins to $PANDORA_HOME/plugins..."
+	cp -r plugins $PANDORA_HOME
+	chmod -R 700 $PANDORA_HOME/plugins
 
-		echo "Copying tentacle client to $TENTACLE"
-		cp tentacle_client $TENTACLE
+	echo "Copying tentacle client to $TENTACLE"
+	cp tentacle_client $TENTACLE
 
-        echo "Linking Pandora FMS Agent plugins directory to $PANDORA_CFG/plugins..."
-        rm $PANDORA_CFG/plugins 2> /dev/null
-        ln -s $PANDORA_HOME/plugins $PANDORA_CFG 2> /dev/null
+	echo "Linking Pandora FMS Agent plugins directory to $PANDORA_CFG/plugins..."
+	rm $PANDORA_CFG/plugins 2> /dev/null
+	ln -s $PANDORA_HOME/plugins $PANDORA_CFG 2> /dev/null
 
-        echo "Linking Pandora FMS Agent configuration to $PANDORA_CFG/pandora_agent.conf..."
-        rm $PANDORA_CFG/pandora_agent.conf 2> /dev/null
-        ln -s $PANDORA_HOME/pandora_agent.conf $PANDORA_CFG/pandora_agent.conf 
+	echo "Linking Pandora FMS Agent configuration to $PANDORA_CFG/pandora_agent.conf..."
+	rm $PANDORA_CFG/pandora_agent.conf 2> /dev/null
+	ln -s $PANDORA_HOME/pandora_agent.conf $PANDORA_CFG/pandora_agent.conf 
         
-        echo "Setting secure permissions and ownership for all Pandora FMS Agent files..."
-        chown -R root $PANDORA_HOME
-        chmod -R 600 $PANDORA_TEMP/data_out
-        chmod 640 $PANDORA_LOG
-        chgrp root $PANDORA_LOG
+	echo "Setting secure permissions and ownership for all Pandora FMS Agent files..."
+	chown -R root $PANDORA_HOME
+	chmod -R 600 $PANDORA_TEMP
+	chmod 640 $PANDORA_LOG
+	chgrp root $PANDORA_LOG
 
-        echo "Linking start-up daemon script at $PANDORA_STARTUP";
-        cp pandora_agent_daemon $PANDORA_STARTUP
+	echo "Linking start-up daemon script at $PANDORA_STARTUP";
+	cp pandora_agent_daemon $PANDORA_STARTUP
 
-		if [ "$DISTRO" == "UBUNTU" ]
+	if [ "$DISTRO" == "UBUNTU" ]
 		then
 	        echo "Linking start-up daemon script to /etc/rc2.d";
-	        ln -s /etc/init.d/pandora_agent_daemon /etc/rc2.d/S90pandora_agent
-		else
-			INITLV=`cat /etc/inittab | grep "[0-9]\:initdefault" | cut -f 2 -d ":"`
-			echo "Linking start-up daemon script to /etc/rc.d/rc$INITLV.d";
-	        ln -s /etc/init.d/pandora_agent_daemon /etc/rc.d/rc$INITLV.d/S90pandora_agent
-		fi
-		
-        chown -R root:root $PANDORA_BIN
-        
-        echo "Done."
-        echo " "
-        echo "You have your startup script ready at $PANDORA_STARTUP"
-		echo " "
-		echo "Tentacle is the default transfer mode since 2.0 version."
-        echo "If you want to use SSH, firstly you need to copy your public SSH keys ($HOME/.ssh/id_dsa)"
-        echo "under /home/pandora/.ssh/authorized_keys on your Pandora FMS Server host"
-        echo "You also need to setup your $PANDORA_CFG/pandora_agent.conf config file"
-        echo " "
+	        ln -s /etc/init.d/pandora_agent_daemon /etc/rc2.d/S90pandora_agent_daemon
+		echo "Linking stop daemon script";
+	        ln -s /etc/init.d/pandora_agent_daemon /etc/rc0.d/K90pandora_agent_daemon
+	        ln -s /etc/init.d/pandora_agent_daemon /etc/rc1.d/K90pandora_agent_daemon
+	        ln -s /etc/init.d/pandora_agent_daemon /etc/rc6.d/K90pandora_agent_daemon
+	else
+		INITLV=`cat /etc/inittab | grep "[0-9]\:initdefault" | cut -f 2 -d ":"`
+		echo "Linking start-up daemon script to /etc/rc.d/rc$INITLV.d";
+	ln -s /etc/init.d/pandora_agent_daemon /etc/rc.d/rc$INITLV.d/S90pandora_agent_daemon
+	fi
+	
+	chown -R root:root $PANDORA_BIN
+
+	echo "Done."
+	echo " "
+	echo "You have your startup script ready at $PANDORA_STARTUP"
+	echo " "
+	echo "Tentacle is the default transfer mode since 2.0 version."
+	echo "If you want to use SSH, firstly you need to copy your public SSH keys ($HOME/.ssh/id_dsa)"
+	echo "under /home/pandora/.ssh/authorized_keys on your Pandora FMS Server host"
+	echo "You also need to setup your $PANDORA_CFG/pandora_agent.conf config file"
+	echo " "
 
 }
 
 help () {
-        echo "     --force-install     To force installation if already installed on system "
-        echo "     --install           To install Pandora FMS Agent on this system"
-        echo "     --uninstall         To uninstall and remove Pandora FMS Agent on this System"
-        echo " "
+	echo "     --force-install     To force installation if already installed on system "
+	echo "     --install           To install Pandora FMS Agent on this system"
+	echo "     --uninstall         To uninstall and remove Pandora FMS Agent on this System"
+	echo " "
 }
 
 # Script banner at start
@@ -204,22 +213,22 @@ echo " "
 case "$MODE" in
 
 '--force-install')
-        FORCE=1
-        install
-        exit
-        ;;
+	FORCE=1
+	install
+	exit
+	;;
 
 '--install')
-        install
-        exit
-        ;;
+	install
+	exit
+	;;
 
 '--uninstall')
-        uninstall
-        exit
-        ;;
+	uninstall
+	exit
+	;;
 
 *)
-        help
+	help
 esac