From 13eb80112acb88728379be04f8e34c2e8dd754a9 Mon Sep 17 00:00:00 2001
From: jsatoh <junichi@rworks.jp>
Date: Mon, 7 Jun 2010 01:36:45 +0000
Subject: [PATCH] 2010-06-07  Junichi Satoh  <junichi@rworks.jp>

	* unix/pandora_agent_installer: Added support for FreeBSD.

	* unix/FreeBSD/pandora_agent: Added startup script for FreeBSD.

	* unix/FreeBSD/pandora_agent.conf: Added configuration file for FreeBSD.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2863 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_agents/ChangeLog                      |   8 +
 pandora_agents/unix/ChangeLog                 |   8 +
 pandora_agents/unix/FreeBSD/pandora_agent     |  65 ++++++
 .../unix/FreeBSD/pandora_agent.conf           | 196 ++++++++++++++++++
 pandora_agents/unix/pandora_agent_installer   | 149 +++++++++----
 5 files changed, 391 insertions(+), 35 deletions(-)
 create mode 100755 pandora_agents/unix/FreeBSD/pandora_agent
 create mode 100755 pandora_agents/unix/FreeBSD/pandora_agent.conf

diff --git a/pandora_agents/ChangeLog b/pandora_agents/ChangeLog
index 88687d5418..cd805ad9f2 100644
--- a/pandora_agents/ChangeLog
+++ b/pandora_agents/ChangeLog
@@ -1,3 +1,11 @@
+2010-06-07  Junichi Satoh  <junichi@rworks.jp>
+
+	* unix/pandora_agent_installer: Added support for FreeBSD.
+
+	* unix/FreeBSD/pandora_agent: Added startup script for FreeBSD.
+
+	* unix/FreeBSD/pandora_agent.conf: Added configuration file for FreeBSD.
+
 2010-06-01  Miguel de Dios  <miguel.dedios@artica.es>
 
 	* unix/DEBIAN/prerm: disabled the erase conf file and plugin dir.
diff --git a/pandora_agents/unix/ChangeLog b/pandora_agents/unix/ChangeLog
index 20555e155b..d2203e8a23 100644
--- a/pandora_agents/unix/ChangeLog
+++ b/pandora_agents/unix/ChangeLog
@@ -1,3 +1,11 @@
+2010-06-07  Junichi Satoh  <junichi@rworks.jp>
+
+	* pandora_agent_installer: Added support for FreeBSD.
+
+	* FreeBSD/pandora_agent: Added startup script for FreeBSD.
+
+	* FreeBSD/pandora_agent.conf: Added configuration file for FreeBSD.
+
 2010-06-04  Ramon Novoa  <rnovoa@artica.es>
 
 	* pandora_agent.spec: Fixed. Upgrading an RPM broke the installation.
diff --git a/pandora_agents/unix/FreeBSD/pandora_agent b/pandora_agents/unix/FreeBSD/pandora_agent
new file mode 100755
index 0000000000..7d878cef29
--- /dev/null
+++ b/pandora_agents/unix/FreeBSD/pandora_agent
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+# **********************************************************************
+# Pandora FMS Agent Daemon launcher for FreeBSD
+# (c) 2010 Junichi Satoh <junichi@rworks.jp>
+#
+# **********************************************************************
+
+# PROVIDE: pandora_agent
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+
+# Add the following line to /etc/rc.conf to enable `pandora_agent':
+#
+# pandora_agent_enable="YES"
+#
+
+. "/etc/rc.subr"
+
+name="pandora_agent"
+
+# read configuration and set defaults
+pandora_agent_enable=${pandora_agent_enable:-"NO"}
+load_rc_config "$name"
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
+
+command=/usr/local/bin/pandora_agent
+command_args="/usr/local/etc/pandora &"
+procname=pandora_agent
+
+pidfile=/var/run/$name.pid
+required_files="/usr/local/etc/pandora/pandora_agent.conf"
+start_precmd=start_precmd
+start_postcmd=start_postcmd
+stop_cmd=pandora_agent_stop
+
+start_precmd()
+{
+	if [ -f $pidfile ]; then
+		PANDORA_PID=`cat $pidfile`
+		echo "pandora_agent is currently running on this machine with PID $PANDORA_PID"
+		echo "Cannot launch again. Aborting."
+		exit 1
+	fi
+}
+
+start_postcmd()
+{
+	PANDORA_PID=`ps auxww | grep $command | grep -v grep | head -1 | awk '{ print $2 }'`
+	echo $PANDORA_PID > $pidfile
+}
+
+pandora_agent_stop()
+{
+	if [ -f $pidfile ]; then
+		echo "Stopping pandora_agent."
+		kill `cat $pidfile`
+		rm -f $pidfile
+	else
+		echo "pandora_agent is not running."
+	fi
+}
+
+run_rc_command "$1"
diff --git a/pandora_agents/unix/FreeBSD/pandora_agent.conf b/pandora_agents/unix/FreeBSD/pandora_agent.conf
new file mode 100755
index 0000000000..d6620d0f40
--- /dev/null
+++ b/pandora_agents/unix/FreeBSD/pandora_agent.conf
@@ -0,0 +1,196 @@
+# Base config file for Pandora FMS agents
+# Version 3.1, FreeBSD Version
+# Licensed under GPL license v2,
+# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
+# http://www.pandorafms.com
+
+# General Parameters
+# ==================
+
+server_ip 	localhost
+server_path 	/var/spool/pandora/data_in
+temporal    	/tmp
+logfile		/var/log/pandora/pandora_agent.log
+
+# Interval in seconds, 300 by default
+interval    	300
+
+# Debug mode only generate XML, and stop after first execution, 
+# and does not copy XML to server.
+debug 		0	
+
+# By default, agent takes machine name
+#agent_name     adama
+
+#Parent agent_name
+#parent_agent_name parent_name
+
+# Agent description
+#description Demo agent
+
+# Group assigned for this agent (descriptive, p.e: Servers)
+#group Servers
+
+# Autotime: Enforce to server to ignore timestamp coming from this
+# agent, used when agents has no timer or it's inestable. 1 to enable
+# this feature
+# autotime 1
+
+# Timezone offset: Difference with the server timezone
+#timezone_offset 0
+
+# Agent position paramters
+# Those parameters define the geographical position of the agent 
+
+# latitude 
+#latitude 0
+# longitude
+#longitude 0
+# altitude
+#altitude 0
+
+#Position description
+#position_description Madrid, centro
+
+# By default agent try to take default encoding defined in host.
+# encoding 	iso-8859-15
+
+# Listening TCP port for remote server. By default is 41121 (for tentacle)
+# if you want to use SSH use 22, and FTP uses 21.
+server_port	41121
+
+# Transfer mode: tentacle, ftp, ssh or local 
+transfer_mode tentacle
+
+# Server password (Tentacle or FTP). Leave empty for no password (default).
+# server_pwd mypassword
+
+# Set to yes/no to enable/disable OpenSSL support for Tentacle (disabled by default).
+# server_ssl no
+
+# Extra options for the Tentacle client (for example, server_opts "-v -r 5").
+# server_opts
+
+# delayed_startup defines number of MINUTES before start execution
+# for first time when startup Pandora FMS Agent
+# delayed_startup 10
+
+# Pandora nice defines priority of execution. Less priority means more intensive execution
+# A recommended value is 10. 0 priority means no Pandora CPU protection enabled (default)
+# pandora_nice 0
+
+# Cron mode replace Pandora FMS own task schedule each XX interval seconds by the use
+# of old style cron. You should add to crontab Pandora FMS agent script to use this mode.
+# This is disabled by default, and is not recommended.  Use Pandora FMS internal scheduler
+# is much more safe.
+# cron_mode 
+
+# If set to 1 allows the agent to be configured via the web console (Only Enterprise version) 
+# remote_config 1
+
+# Secondary server configuration
+# ==============================
+
+# If secondary_mode is set to on_error, data files are copied to the secondary
+# server only if the primary server fails. If set to always, data files are
+# always copied to the secondary server.
+# secondary_mode on_error
+# secondary_server_ip localhost
+# secondary_server_path /var/spool/pandora/data_in
+# secondary_server_port 41121
+# secondary_transfer_mode tentacle
+# secondary_server_pwd mypassword
+# secondary_server_ssl no
+# secondary_server_opts
+
+# Module Definition
+# =================
+
+# System information
+
+# vmstat syntax depends on system configuration, please check before use it
+module_begin 
+module_name cpu_user
+module_type generic_data
+module_interval 1
+module_exec vmstat 1 2 | tail -1 | awk '{ print $17 }'
+module_max 100
+module_min 0
+module_description User CPU Usage (%)
+module_end
+
+module_begin
+module_name cpu_system
+module_type generic_data
+module_interval 1   
+module_exec vmstat 1 2 | tail -1 | awk '{ print $18 }'
+module_max 100
+module_min 0
+module_description System CPU Usage (%)
+module_end
+
+module_begin
+module_name cpu_idle
+module_type generic_data
+module_interval 1
+module_exec vmstat 1 2 | tail -1 | awk '{ print $19 }'
+module_max 100
+module_min 0
+module_description CPU Idle (%)
+module_end
+
+module_begin 
+module_name Load Average
+module_type generic_data
+module_exec uptime | cut -d "," -f 4 | cut -d ":" -f 2 | sed "s/ //g" 
+module_description Average process in CPU (Last minute) 
+module_end
+
+module_begin 
+module_name disk_root_free
+module_type generic_data
+module_exec df -kh / | tail -1 | awk '{ print 100-$5 }'
+module_max 100
+module_min 0
+module_description Free disk Percentage of root partition
+module_end
+
+module_begin
+module_name memfree
+module_type generic_data
+module_exec vmstat -H 1 2 | tail -1 | awk '{print $5}'
+module_description Unused RAM memory
+module_end
+
+module_begin
+module_name proctotal
+module_type generic_data
+module_exec ps -A | wc -l | sed "s/ //g"
+module_end
+
+# Process information
+
+module_begin
+module_name sshDaemon
+module_type generic_proc
+module_exec ps -Af | grep sshd | grep -v "grep" | wc -l | sed "s/ //g"
+module_end
+
+# Async data example
+ 
+module_begin
+module_name LastLogin
+module_type async_string
+module_exec last | head -1
+module_end
+
+# Plugin example
+
+# This parses /var/log/auth.log file, under the module name "syslog"
+# And search for "sshd" string into it, sending only that information.
+
+module_plugin grep_log /var/log/auth.log Syslog sshd
+
+# Plugin for inventory on the agent (Only Enterprise)
+
+# module_plugin inventory 1 cpu ram video nic hd cdrom software
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index 0d5560d86b..89da7bdcd2 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -5,7 +5,7 @@
 # (c) 2008-2010 Artica ST
 # (c) 2008-2010 Sancho Lerena <slerena@gmail.com>
 # 
-# This is a generic installer for all Unix-like systems.(AIX, HP-UX, SunOS, Linux)
+# This is a generic installer for all Unix-like systems.(AIX, HP-UX, SunOS, Linux, FreeBSD)
 # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
 # **********************************************************************
 
@@ -22,6 +22,7 @@ PANDORA_CFG=/etc/pandora
 PANDORA_LOG_DIR=/var/log/pandora
 PANDORA_LOG=pandora_agent.log
 TENTACLE=/usr/bin/tentacle_client
+PANDORA_MAN=/usr/share/man
 
 MODE=$1
 PANDORA_BASE=$2
@@ -38,7 +39,7 @@ then
 fi
 
 UNIX_KIND=`uname -s`
-if [ -z "`echo Linux HP-UX SunOS AIX Solaris Darwin BSD bsd | grep \"$UNIX_KIND\"`" ]
+if [ -z "`echo Linux HP-UX SunOS AIX Solaris Darwin BSD bsd FreeBSD | grep \"$UNIX_KIND\"`" ]
 then
 	echo "This system: '$UNIX_KIND' is not supported by this script"
 	echo "Please make the install yourself as it's described in documentation"
@@ -76,6 +77,16 @@ then
 fi
 
 uninstall () {
+	OS_NAME=`uname -s`
+        if [ "$OS_NAME" = "FreeBSD" ]
+        then
+		PANDORA_HOME=/usr/local/share/pandora_agent
+		PANDORA_BIN=/usr/local/bin/pandora_agent
+		PANDORA_CFG=/usr/local/etc/pandora
+		TENTACLE=/usr/local/bin/tentacle_client
+		PANDORA_MAN=/usr/local/man
+        fi
+
 	echo "Removing Pandora FMS Agent..."
 	rm -Rf $PANDORA_BASE$PANDORA_BIN 2> /dev/null
 	
@@ -93,15 +104,19 @@ uninstall () {
 	rm -Rf $PANDORA_BASE/etc/rc.pandora_agent_daemon 2> /dev/null
 	rm -Rf $PANDORA_BASE/etc/rc?.d/S90pandora_agent_daemon 2> /dev/null
 	rm -Rf $PANDORA_BASE/sbin/rc?.d/S90pandora_agent_daemon 2> /dev/null
+	rm -Rf $PANDORA_BASE/usr/local/etc/rc.d/pandora_agent 2> /dev/null
 	
 	rm -Rf $PANDORA_BASE$PANDORA_HOME 2> /dev/null
 	rm -Rf $PANDORA_BASE$PANDORA_LOG_DIR 2> /dev/null
 	rm -Rf $PANDORA_BASE$TENTACLE 2> /dev/null
 
+	rm -Rf $PANDORA_BASE$PANDORA_MAN/{man1,cat1}/tentacle_client.1.gz 2> /dev/null
+	rm -Rf $PANDORA_BASE$PANDORA_MAN/{man1,cat1}/pandora_agent.1.gz 2> /dev/null
+
 	# Skip delete of /etc/pandora if exists configuration of a server
-	if [ ! -f $PANDORA_BASE/etc/pandora/pandora_server.conf ]
+	if [ ! -f $PANDORA_BASE/$PANDORA_CFG/pandora_server.conf ]
 	then
-		rm -Rf $PANDORA_BASE/etc/pandora 2> /dev/null
+		rm -Rf $PANDORA_BASE/$PANDORA_CFG 2> /dev/null
 	fi
 
     if [ ! -z "$PANDORA_BASE" ]
@@ -118,6 +133,16 @@ install () {
 	OS_VERSION=`uname -r`
 	OS_NAME=`uname -s`
 	OLDFILENAMETMP=`date +"%Y-%m-%d"`
+
+	if [ "$OS_NAME" = "FreeBSD" ]
+	then
+		PANDORA_HOME=/usr/local/share/pandora_agent
+		PANDORA_BIN=/usr/local/bin/pandora_agent
+		PANDORA_CFG=/usr/local/etc/pandora
+		TENTACLE=/usr/local/bin/tentacle_client
+		PANDORA_MAN=/usr/local/man
+	fi
+
 	echo "Detecting Unix distribution: $OS_NAME version $OS_VERSION"
 	if [ -f $PANDORA_BASE$PANDORA_HOME ] && [ "$FORCE" = "0" ]
 	then
@@ -141,10 +166,15 @@ install () {
     echo "Creating Pandora FMS Agent home directory at $PANDORA_BASE$PANDORA_HOME"
     if [ ! -z "$PANDORA_BASE" ]
     then
-        mkdir -p $PANDORA_BASE 2> /dev/null
-        mkdir -p $PANDORA_BASE/usr/bin 2> /dev/null
-        mkdir -p $PANDORA_BASE/var/log 2> /dev/null
-        mkdir -p $PANDORA_BASE/usr/share/man/man1 2> /dev/null
+	mkdir -p $PANDORA_BASE 2> /dev/null
+	mkdir -p $PANDORA_BASE/var/log 2> /dev/null
+	mkdir -p $PANDORA_BASE/$PANDORA_MAN/man1 2> /dev/null
+	if [ "$OS_NAME" = "FreeBSD" ]
+	then
+            mkdir -p $PANDORA_BASE/usr/local/bin 2> /dev/null
+	else
+            mkdir -p $PANDORA_BASE/usr/bin 2> /dev/null
+	fi
     fi
 
 	mkdir -p $PANDORA_BASE$PANDORA_HOME 2> /dev/null
@@ -169,13 +199,18 @@ install () {
 	echo "Copying Pandora FMS Agent to $PANDORA_BASE$PANDORA_BIN..."
 	cp pandora_agent $PANDORA_BASE$PANDORA_BIN
 	chmod 755 $PANDORA_BASE$PANDORA_BIN
-	chown root:root $PANDORA_BASE$PANDORA_BIN
-	
-	echo "Copying Pandora FMS Agent configuration file to $PANDORA_BASE$PANDORA_HOME/pandora_agent.conf..."
-	if [ -f $PANDORA_BASE/etc/pandora/pandora_agent.conf ]
+	if [ "$OS_NAME" = "FreeBSD" ]
 	then
-		cp $PANDORA_BASE/etc/pandora/pandora_agent.conf $PANDORA_BASE/etc/pandora/pandora_agent.conf.$OLDFILENAMETMP
-		echo "Backing up old configuration file to $PANDORA_BASE/etc/pandora_agent.conf.$OLDFILENAMETMP"
+		chown root:wheel $PANDORA_BASE$PANDORA_BIN
+	else
+		chown root:root $PANDORA_BASE$PANDORA_BIN
+	fi
+
+	echo "Copying Pandora FMS Agent configuration file to $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf..."
+	if [ -f $PANDORA_BASE/$PANDORA_CFG/pandora_agent.conf ]
+	then
+		cp $PANDORA_BASE/$PANDORA_CFG/pandora_agent.conf $PANDORA_BASE/$PANDORA_CFG/pandora_agent.conf.$OLDFILENAMETMP
+		echo "Backing up old configuration file to $PANDORA_BASE/$PANDORA_CFG/pandora_agent.conf.$OLDFILENAMETMP"
 	fi
 
 	echo "Copying Pandora FMS Agent plugins to $PANDORA_BASE$PANDORA_HOME/plugins..."
@@ -190,26 +225,39 @@ install () {
 	echo "Installing Tentacle Client manual"
     if [ -f ../man/man1/tentacle_client.1.gz ]
     then 
-    	cp ../man/man1/tentacle_client.1.gz $PANDORA_BASE/usr/share/man/man1
+    	cp ../man/man1/tentacle_client.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
     else
-    	cp man/man1/tentacle_client.1.gz $PANDORA_BASE/usr/share/man/man1
+    	cp man/man1/tentacle_client.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
     fi
-    chmod 644 $PANDORA_BASE/usr/share/man/man1/tentacle_client.1.gz
+    chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/tentacle_client.1.gz
 
 	echo "Setting secure permissions and ownership for all Pandora FMS Agent files..."
 	chown -R root $PANDORA_BASE$PANDORA_HOME
 	chmod -R 600 $PANDORA_BASE$PANDORA_TEMP
 	chown root $PANDORA_BASE$PANDORA_TEMP
 	chmod 640 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
-	chown root:root $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
+	if [ "$OS_NAME" = "FreeBSD" ]
+	then
+	    chown root:wheel $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG	
+	    chown root:daemon $PANDORA_BASE$PANDORA_TEMP
+	    chmod -R 770 $PANDORA_BASE$PANDORA_TEMP
+	else
+	    chown root:root $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
+	fi
 
     # Alter dynamically the daemon launcher and setup the new path 
     # if PANDORA_BASE is customized.
 
     if [ ! -z "$PANDORA_BASE" ]
     then
-        DAEMON_SCRIPT=pandora_agent_daemon
-        DAEMON_TEMP=pandora_agent_daemon_temp
+	if [ "$OS_NAME" = "FreeBSD" ]
+	then
+	    DAEMON_SCRIPT=FreeBSD/pandora_agent
+            DAEMON_TEMP=pandora_agent_daemon_temp
+	else
+            DAEMON_SCRIPT=pandora_agent_daemon
+            DAEMON_TEMP=pandora_agent_daemon_temp
+	fi
         
         AGENT_CFG=$OS_NAME/pandora_agent.conf
         AGENT_CFG_TEMP=$OS_NAME/pandora_agent.conf.temp
@@ -220,17 +268,32 @@ install () {
         PANDORA_BASE_DECODED=`cat PANDORA_BASE.temp2`
         rm PANDORA_BASE.temp PANDORA_BASE.temp2
 
-        sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP
-        mv  $DAEMON_TEMP $DAEMON_SCRIPT
+	if [ "$OS_NAME" = "FreeBSD" ]
+	then
+	    sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/local\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP
+	    mv $DAEMON_TEMP $DAEMON_SCRIPT
 
-        sed -e "s/^PANDORA_PATH\=[.]*/PANDORA_PATH\=$PANDORA_BASE_DECODED/g"  $DAEMON_SCRIPT > $DAEMON_TEMP
-        mv  $DAEMON_TEMP $DAEMON_SCRIPT
+	    sed -e "s/^command\=[.]*/command\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP
+	    mv $DAEMON_TEMP $DAEMON_SCRIPT
 
-        sed -e "s/^LOGFILE\=[.]*/LOGFILE\=$PANDORA_BASE_DECODED/g"  $DAEMON_SCRIPT > $DAEMON_TEMP
-        mv  $DAEMON_TEMP $DAEMON_SCRIPT
+	    sed -e 's/^command_args\=\"[.]*/command_args\=\"$PANDORA_BASE_DECODED/g' $DAEMON_SCRIPT > $DAEMON_TEMP
+	    mv $DAEMON_TEMP $DAEMON_SCRIPT
 
-        sed -e "s/^DAEMON\=[.]*/DAEMON\=$PANDORA_BASE_DECODED/g"  $DAEMON_SCRIPT > $DAEMON_TEMP
-        mv  $DAEMON_TEMP $DAEMON_SCRIPT
+	    sed -e 's/^required_files\=\"[.]*/required_files\=\"$PANDORA_BASE_DECODED/g' $DAEMON_SCRIPT > $DAEMON_TEMP
+	    mv $DAEMON_TEMP $DAEMON_SCRIPT
+	else
+            sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP
+            mv  $DAEMON_TEMP $DAEMON_SCRIPT
+
+            sed -e "s/^PANDORA_PATH\=[.]*/PANDORA_PATH\=$PANDORA_BASE_DECODED/g"  $DAEMON_SCRIPT > $DAEMON_TEMP
+            mv  $DAEMON_TEMP $DAEMON_SCRIPT
+
+            sed -e "s/^LOGFILE\=[.]*/LOGFILE\=$PANDORA_BASE_DECODED/g"  $DAEMON_SCRIPT > $DAEMON_TEMP
+            mv  $DAEMON_TEMP $DAEMON_SCRIPT
+
+            sed -e "s/^DAEMON\=[.]*/DAEMON\=$PANDORA_BASE_DECODED/g"  $DAEMON_SCRIPT > $DAEMON_TEMP
+            mv  $DAEMON_TEMP $DAEMON_SCRIPT
+	fi
 
         sed -e "s/^temporal [.]*/temporal $PANDORA_BASE_DECODED/g" $AGENT_CFG > $AGENT_CFG_TEMP
         mv $AGENT_CFG_TEMP $AGENT_CFG
@@ -239,13 +302,18 @@ install () {
         mv $AGENT_CFG_TEMP $AGENT_CFG
     fi
 
-    echo "Copying default agent configuration to $PANDORA_BASE$PANDORA_HOME/pandora_agent.conf"
+    echo "Copying default agent configuration to $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf"
 
 	cp $OS_NAME/pandora_agent.conf $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf
 	chmod 600 $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf
 	chown root $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf
 
-	echo "Linking start-up daemon script 'pandora_agent_daemon' on $OS_NAME";
+	if [ "$OS_NAME" = "FreeBSD" ]
+	then
+		echo "Linking start-up daemon script 'pandora_agent' on $OS_NAME";
+	else
+		echo "Linking start-up daemon script 'pandora_agent_daemon' on $OS_NAME";
+	fi
 
 	if [ "$OS_NAME" = "AIX" ]
 	then
@@ -285,14 +353,20 @@ install () {
 		fi
 	fi
 
+	if [ "$OS_NAME" = "FreeBSD" ]
+	then
+	PANDORA_STARTUP=/usr/local/etc/rc.d/pandora_agent
+		cp FreeBSD/pandora_agent $PANDORA_STARTUP
+	fi
+
 	echo "Installing Pandora Agent manual"
     if [ -e ../man/man1/pandora_agent.1.gz ]
     then
-    	cp ../man/man1/pandora_agent.1.gz $PANDORA_BASE/usr/share/man/man1
+    	cp ../man/man1/pandora_agent.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
     else
-    	cp man/man1/pandora_agent.1.gz $PANDORA_BASE/usr/share/man/man1
+    	cp man/man1/pandora_agent.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
     fi
-    chmod 644 $PANDORA_BASE/usr/share/man/man1/pandora_agent.1.gz
+    chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/pandora_agent.1.gz
 
 	echo "Done."
 	echo " "
@@ -306,8 +380,13 @@ install () {
 	echo " "
 	echo "You also need to setup your $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf config file"
 	echo " "
-	echo "Check your startup configuration to be sure Pandora FMS Agent is ready "
-	echo "to start automatically when system restarts":
+	if [ "$OS_NAME" = "FreeBSD" ]
+	then
+	    echo "Define 'pandora_agent=\"YES\"' in /etc/rc.conf to enable the daemon."
+	else
+	    echo "Check your startup configuration to be sure Pandora FMS Agent is ready "
+	    echo "to start automatically when system restarts":
+	fi
 
 }