Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Aug 2014 20:01:17 +0000 (UTC)
From:      William Grzybowski <wg@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r365508 - in head/net-mgmt: pandorafms_agent pandorafms_agent/files pandorafms_console pandorafms_console/files pandorafms_server pandorafms_server/files
Message-ID:  <201408202001.s7KK1H7n091367@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: wg
Date: Wed Aug 20 20:01:17 2014
New Revision: 365508
URL: http://svnweb.freebsd.org/changeset/ports/365508
QAT: https://qat.redports.org/buildarchive/r365508/

Log:
  net-mgmt/pandorafms_*: update to 5.1 and support stage
  
  - Pass maintainership back
  - Add patches already incorporated upstream
  
  PR:		192739
  Submitted by:	KIKUCHI Koichiro

Added:
  head/net-mgmt/pandorafms_agent/files/patch-update   (contents, props changed)
  head/net-mgmt/pandorafms_console/files/patch-update   (contents, props changed)
  head/net-mgmt/pandorafms_console/files/pkg-message.in   (contents, props changed)
  head/net-mgmt/pandorafms_server/files/patch-update   (contents, props changed)
Deleted:
  head/net-mgmt/pandorafms_agent/files/pandora_agent.in
  head/net-mgmt/pandorafms_agent/files/patch-pandora_agent_installer
  head/net-mgmt/pandorafms_console/files/patch-pandora_console_install
  head/net-mgmt/pandorafms_server/files/199.clean-pandoradb.in
  head/net-mgmt/pandorafms_server/files/pandora_server.in
  head/net-mgmt/pandorafms_server/files/patch-pandora_server_installer
  head/net-mgmt/pandorafms_server/files/tentacle_server.in
Modified:
  head/net-mgmt/pandorafms_agent/Makefile
  head/net-mgmt/pandorafms_agent/distinfo
  head/net-mgmt/pandorafms_agent/pkg-descr
  head/net-mgmt/pandorafms_agent/pkg-plist
  head/net-mgmt/pandorafms_console/Makefile
  head/net-mgmt/pandorafms_console/distinfo
  head/net-mgmt/pandorafms_console/pkg-descr
  head/net-mgmt/pandorafms_console/pkg-plist
  head/net-mgmt/pandorafms_server/Makefile
  head/net-mgmt/pandorafms_server/bsd.pandora.mk
  head/net-mgmt/pandorafms_server/distinfo
  head/net-mgmt/pandorafms_server/files/pkg-message.in
  head/net-mgmt/pandorafms_server/pkg-descr
  head/net-mgmt/pandorafms_server/pkg-plist
  head/net-mgmt/pandorafms_server/pkg-plist.spool

Modified: head/net-mgmt/pandorafms_agent/Makefile
==============================================================================
--- head/net-mgmt/pandorafms_agent/Makefile	Wed Aug 20 19:42:50 2014	(r365507)
+++ head/net-mgmt/pandorafms_agent/Makefile	Wed Aug 20 20:01:17 2014	(r365508)
@@ -2,84 +2,48 @@
 # $FreeBSD$
 
 PORTNAME=	pandora_agent
-PORTVERSION=	${PANDORA_VERSION}
-PORTREVISION=	1
 CATEGORIES=	net-mgmt
 
-MAINTAINER=	ports@FreeBSD.org
+MAINTAINER=	koichiro@rworks.jp
 COMMENT=	Pandora FMS agent, Perl version
 
 LICENSE=	${PANDORA_LICENSE}
 LICENSE_FILE=	${PANDORA_LICENSE_FILE}
 
-OPTIONS_DEFINE=	TENTACLE_SERVER
-OPTIONS_DEFAULT=	TENTACLE_SERVER
+OPTIONS_DEFINE=		DOCS TENTACLE_SERVER
+OPTIONS_DEFAULT=	DOCS TENTACLE_SERVER
 TENTACLE_SERVER_DESC=	Install tentalce_server
 
 USES=		perl5
-SUB_LIST+=	PERL="${PERL}"
-
-MAN1=		pandora_agent.1	tentacle_client.1
-MANCOMPRESSED=	yes
 
 SUB_FILES=	pkg-message
-USE_RC_SUBR=	${PORTNAME}
 
-NO_STAGE=	yes
 .include "${.CURDIR}/../pandorafms_server/bsd.pandora.mk"
 
 PORTDOCS+=	README
+PANDORA_INSTALLER_ARGS+=	--fakeroot
 
 .include <bsd.port.pre.mk>
 
 .if ${PORT_OPTIONS:MTENTACLE_SERVER}
-CONFLICTS=	pandora_server-4*
+CONFLICTS=	pandora_server-[45]*
 PLIST_SUB+=	TENTACLE_SERVER=""
 .else
 PLIST_SUB+=	TENTACLE_SERVER="@comment "
+PANDORA_INSTALLER_ARGS+=	--no-tentacle-server
 .endif
 
-post-patch:
-.if ! ${PORT_OPTIONS:MTENTACLE_SERVER}
-	@${REINPLACE_CMD} \
-		-e '/TENTACLE_SERVER/s/^/#/' \
-		${WRKSRC}/pandora_agent_installer
-.endif
-	@${REINPLACE_CMD} -E \
-		-e 's|%%PREFIX%%|${PREFIX}|g' \
-		-e 's|%%DATADIR%%|${DATADIR}|g' \
-		-e 's|%%MAN1PREFIX%%|${MAN1PREFIX}|g' \
-		-e 's|%%PANDORA_ETCDIR%%|${PANDORA_ETCDIR}|g' \
-		-e 's|%%PANDORA_HOMEDIR%%|${PANDORA_HOMEDIR}|g' \
-		${WRKSRC}/pandora_agent_installer
-	@${REINPLACE_CMD} -i "" \
-		-e 's,/bin/bash,/bin/sh,' \
-		-e 's,md5sum,md5 -r,' \
-		${WRKSRC}/plugins/files_indir
-	@${REINPLACE_CMD} -i "" \
-		-e 's,/usr/bin/perl,${PERL},g' \
-		`${GREP} -lr /usr/bin/perl ${WRKSRC} | ${GREP} -v pandora_agent_installer`
-	@${REINPLACE_CMD} -i "" \
-		-e 's,/usr/local,${PREFIX},g' \
-		${WRKSRC}/plugins/pandora_update
-	@${REINPLACE_CMD} \
-		-e 's,`ifconfig ,`/sbin/ifconfig ,g' \
-		-e 's,tentacle_client ,${PREFIX}/bin/tentacle_client ,g' \
-		${WRKSRC}/pandora_agent
+PANDORA_INSTALLER_ARGS+=	${STAGEDIR} root ${PERL}
 
-do-install:
-	@cd ${WRKSRC} && ${SH} pandora_agent_installer --force-install
+post-patch:
+	@${REINPLACE_CMD} -e '\|PREFIX=|s|=[^;]*|=${PREFIX}|' ${WRKSRC}/pandora_agent_installer
 
 post-install:
-.if ${PORT_OPTIONS:MDOCS}
-	@${MKDIR} ${DOCSDIR}
+	@${RM} -f ${STAGEDIR}${LOGDIR}/pandora_agent.log
+	@${MKDIR} ${STAGEDIR}${DOCSDIR}
 .for x in ${PORTDOCS}
-	@${INSTALL_DATA} ${WRKSRC}/${x} ${DOCSDIR}
+	${INSTALL_DATA} ${WRKSRC}/${x} ${STAGEDIR}${DOCSDIR}
 .endfor
-.endif
-	@if [ ! -e ${ETCDIR}/pandora_agent.conf ]; then \
-		cd ${ETCDIR} && ${CP} -p pandora_agent.conf.sample pandora_agent.conf; \
-	fi
-	@${CAT} ${PKGMESSAGE}
+	@${MV} ${STAGEDIR}${ETCDIR}/pandora_agent.conf ${STAGEDIR}${ETCDIR}/pandora_agent.conf.sample
 
 .include <bsd.port.post.mk>

Modified: head/net-mgmt/pandorafms_agent/distinfo
==============================================================================
--- head/net-mgmt/pandorafms_agent/distinfo	Wed Aug 20 19:42:50 2014	(r365507)
+++ head/net-mgmt/pandorafms_agent/distinfo	Wed Aug 20 20:01:17 2014	(r365508)
@@ -1,2 +1,2 @@
-SHA256 (pandora/pandorafms_agent_unix-4.0.1.tar.gz) = 0bae97d97f0fe628c7cd601d5d0304057a45b49a1277d63d9f30ae957173ed56
-SIZE (pandora/pandorafms_agent_unix-4.0.1.tar.gz) = 65952
+SHA256 (pandora/pandorafms_agent_unix-5.1.tar.gz) = 9d487573716c088a5121fbb89456000bd39226dbb317ed2d88970f46d4b2bc34
+SIZE (pandora/pandorafms_agent_unix-5.1.tar.gz) = 86100

Added: head/net-mgmt/pandorafms_agent/files/patch-update
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net-mgmt/pandorafms_agent/files/patch-update	Wed Aug 20 20:01:17 2014	(r365508)
@@ -0,0 +1,1288 @@
+Index: ChangeLog
+===================================================================
+--- ChangeLog	(revision 10314)
++++ ChangeLog	(working copy)
+@@ -1,3 +1,33 @@
++2014-08-14  Koichiro Kikuchi <koichiro@rworks.jp>
++
++	* pandora_agent_installer: Fixed symlink source path.
++
++2014-08-13  Koichiro Kikuchi <koichiro@rworks.jp>
++
++	* FreeBSD/pandora_agent: Small fixes: use proper rc variables,
++	 remove obsolete function "set_rcvar" call and use "daemon" command
++	 to start pandora_agent.
++
++	* pandora_agent_installer: Refactored implementation and added
++	 "fakeroot" installation support.
++
++	* plugins/who.sh: Converted to bourne shell script.
++
++	* pandora_agent_daemon: Small bug fixes and refactorings.
++
++2014-08-12  Ramon Novoa  <rnovoa@artica.es>
++
++	* pandora_agent: Fixed to make the 'Command Snapshot' feature work.
++
++2014-08-12  Ramon Novoa  <rnovoa@artica.es>
++
++	* pandora_agent: Trim leading and trailing whitespaces from module names
++	  (like policies and windows agents do).
++
++2014-08-07  Ramon Novoa  <rnovoa@artica.es>
++
++	* pandora_agent_daemon: Fixes the ps call on HP-UX.
++
+ 2014-06-04  Koichiro KIKUCHI <koichiro@rworks.jp>
+ 
+ 	* pandora_agent: Allow spaces in module group names.
+Index: pandora_agent_installer
+===================================================================
+--- pandora_agent_installer	(revision 10314)
++++ pandora_agent_installer	(working copy)
+@@ -15,49 +15,79 @@
+ 
+ FORCE=0
+ LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
+-PANDORA_HOME=/usr/share/pandora_agent
+-PANDORA_BIN=/usr/bin/pandora_agent
+-PANDORA_EXEC_BIN=/usr/bin/pandora_agent_exec
+-PANDORA_REVENT_BIN=/usr/bin/pandora_revent
++
++PREFIX=/usr
++if [ "$OS_NAME" = "FreeBSD" ] || [ "$OS_NAME" = "NetBSD" ]
++then
++	PREFIX=/usr/local
++fi
++PANDORA_HOME=$PREFIX/share/pandora_agent
++PANDORA_BIN=$PREFIX/bin/pandora_agent
++PANDORA_EXEC_BIN=$PREFIX/bin/pandora_agent_exec
++PANDORA_REVENT_BIN=$PREFIX/bin/pandora_revent
+ PANDORA_TEMP=/var/spool/pandora
+ PANDORA_CFG=/etc/pandora
+ PANDORA_LOG_DIR=/var/log/pandora
+ PANDORA_LOG=pandora_agent.log
+-TENTACLE=/usr/bin/tentacle_client
+-TENTACLE_SERVER=/usr/bin/tentacle_server
+-PANDORA_MAN=/usr/share/man
++TENTACLE=$PREFIX/bin/tentacle_client
++TENTACLE_SERVER=$PREFIX/bin/tentacle_server
++PANDORA_MAN=$PREFIX/share/man
++PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon
++DAEMON_SCRIPT=pandora_agent_daemon
++PANDORA_USER="root"
++PANDORA_PERL_PATH="perl"
++WITHOUT_TENTACLE_SERVER=0
++FAKEROOT=0
+ 
++# defaults for each platforms
++case $OS_NAME in
++AIX)
++    PANDORA_STARTUP=/etc/rc.pandora_agent_daemon
++	;;
++HP-UX)
++	PANDORA_STARTUP=/sbin/init.d/pandora_agent_daemon
++	;;
++FreeBSD)
++	PANDORA_CFG=$PREFIX/etc/pandora
++	PANDORA_MAN=$PREFIX/man
++	PANDORA_STARTUP=$PREFIX/etc/rc.d/pandora_agent
++	DAEMON_SCRIPT=$OS_NAME/pandora_agent
++	PANDORA_PERL_PATH=/usr/local/bin/perl
++	;;
++NetBSD)
++	PANDORA_CFG=/usr/local/etc/pandora
++	PANDORA_STARTUP=/etc/rc.d/pandora_agent
++	DAEMON_SCRIPT=$OS_NAME/pandora_agent
++	PANDORA_PERL_PATH=/usr/pkg/bin/perl
++	;;
++esac
++
+ MODE=$1
+-PANDORA_BASE=`echo $2 | sed -e 's/\/$//'`
++
++# options
++while :
++do
++	case "$2" in 
++	"--no-tentacle-server") WITHOUT_TENTACLE_SERVER=1;;
++	"--fakeroot") FAKEROOT=1;;
++	*) break;;
++	esac
++	shift
++done
++
++PANDORA_BASE=`echo $2 | sed -e 's|/$||'`
+ if [ "$3" != "" ]
+ then
+ 	PANDORA_USER=$3
+-	if [ "$PANDORA_BASE" = "" ]
++	if [ -z "$PANDORA_BASE" ]
+ 	then
+ 		echo "When specifying a custom user the agent must be installed to a custom location where that user has write permissions!"
+ 		exit 1
+ 	fi
+-else
+-	PANDORA_USER="root"
+ fi
+ 
+-if [ "$4" != "" ]
+-then
+-	PANDORA_PERL_PATH=$4
+-	echo $PANDORA_PERL_PATH > PANDORA_PERL_PATH.temp
+-        sed 's/\//\\\//g' PANDORA_PERL_PATH.temp > PANDORA_PERL_PATH.temp2
++[ "$4" ] && PANDORA_PERL_PATH=$4
+ 
+-        PANDORA_PERL_DECODED_PATH=`cat PANDORA_PERL_PATH.temp2`
+-        rm PANDORA_PERL_PATH.temp PANDORA_PERL_PATH.temp2
+-	#PANDORA_PERL_DECODED_PATH=`echo $PANDORA_PERL_PATH | sed -e "s.\/.\\\\\/.g"`
+-else
+-	PANDORA_PERL_PATH="perl"
+-	if [ "$OS_NAME" = "NetBSD" ]
+-	then
+-		PANDORA_PERL_DECODED_PATH="/usr/pkg/bin/perl"
+-	fi
+-fi
+-
+ # Check for Perl 5.6.x or higher available
+ PERL_VERSION=`$PANDORA_PERL_PATH -v | egrep 'v5.6|v5.7|v5.8|v5.9|v5.1[0-9]' | grep perl`
+ 
+@@ -69,17 +99,16 @@
+ 	exit 2
+ fi
+ 
+-UNIX_KIND=`uname -s`
+-if [ -z "`echo Linux HP-UX SunOS AIX Solaris Darwin BSD bsd FreeBSD NetBSD | grep \"$UNIX_KIND\"`" ]
++if [ -z "`echo Linux HP-UX SunOS AIX Solaris Darwin BSD bsd FreeBSD NetBSD | grep \"$OS_NAME\"`" ]
+ then
+-	echo "This system: '$UNIX_KIND' is not supported by this script"
++	echo "This system: '$OS_NAME' is not supported by this script"
+ 	echo "Please make the install yourself as it's described in documentation"
+ 	exit 1
+ fi
+ 
+ 
+ # check for root to do the install
+-if [ -z "`id | grep \"uid=0(root)\"`" ]
++if [ $FAKEROOT -ne 1 ] && [ -z "`id | grep \"uid=0(root)\"`" ]
+ then
+ 	echo "You need to be root to do the install. Please made a manual install"
+ 	echo "if you want to install Pandora FMS agent without root"
+@@ -91,7 +120,7 @@
+ help () {
+ 	echo "Syntax":
+ 	echo " "
+-	echo "    ./pandora_agent_installer < --mode > [ destination_path ] [ user_to_run_as ] [custom_perl_path]"
++	echo "    ./pandora_agent_installer < --mode > [ --option ] [ destination_path ] [ user_to_run_as ] [custom_perl_path]"
+ 	echo " "
+ 	echo "Modes:"
+ 	echo " "
+@@ -99,6 +128,11 @@
+ 	echo "  --install            To install Pandora FMS Agent on this system"
+ 	echo "  --uninstall          To uninstall/remove Pandora FMS Agent on this System"
+ 	echo " "	
++	echo "Option:"
++	echo " "
++	echo "  --no-tentacle-server  Skip tentacle server installation (by default tentalce server installed)"
++	echo "  --fakeroot            treate \"destination_path\" as root directory"
++	echo " "
+ 	echo "Some exaples of how to use the installer:"
+ 	echo " "
+ 	echo "   ./pandora_agent_installer --install"
+@@ -110,38 +144,12 @@
+ }
+ 
+ uninstall () {
+-	OS_NAME=`uname -s`
+-
+ 	if [ "$OS_NAME" = "Darwin" ]
+         then
+ 		launchctl remove com.pandorafms.pandorafms 
+ 		rm /Library/LaunchDaemons/com.pandorafms.pandorafms.plist 2> /dev/null
+ 	fi
+ 
+-
+-	if [ "$OS_NAME" = "FreeBSD" ]
+-	then
+-		PANDORA_HOME=/usr/local/share/pandora_agent
+-		PANDORA_BIN=/usr/local/bin/pandora_agent
+-		PANDORA_EXEC_BIN=/usr/local/bin/pandora_agent_exec
+-		PANDORA_REVENT_BIN=/usr/local/bin/pandora_revent
+-		PANDORA_CFG=/usr/local/etc/pandora
+-		TENTACLE=/usr/local/bin/tentacle_client
+-		TENTACLE_SERVER=/usr/local/bin/tentacle_server
+-		PANDORA_MAN=/usr/local/man
+-	fi
+-	if [ "$OS_NAME" = "NetBSD" ]
+-	then
+-		PANDORA_HOME=/usr/local/share/pandora_agent
+-		PANDORA_BIN=/usr/local/bin/pandora_agent
+-		PANDORA_EXEC_BIN=/usr/local/bin/pandora_agent_exec
+-		PANDORA_REVENT_BIN=/usr/local/bin/pandora_revent
+-		PANDORA_CFG=/usr/local/etc/pandora
+-		TENTACLE=/usr/local/bin/tentacle_client
+-		TENTACLE_SERVER=/usr/local/bin/tentacle_server
+-		PANDORA_MAN=/usr/share/man
+-	fi
+-
+ 	echo "Removing Pandora FMS Agent..."
+ 	rm -Rf $PANDORA_BASE$PANDORA_BIN 2> /dev/null
+ 	rm -Rf $PANDORA_BASE$PANDORA_EXEC_BIN 2> /dev/null
+@@ -168,16 +176,19 @@
+ 	rm -Rf $PANDORA_BASE/etc/rc.d/rc?.d/S90pandora_agent_daemon 2> /dev/null
+ 	rm -Rf $PANDORA_BASE/etc/rc.d/rc?.d/S90pandora_agent 2> /dev/null
+ 	rm -Rf $PANDORA_BASE/usr/local/etc/rc.d/pandora_agent 2> /dev/null
+-	rm -Rf /etc/init.d/pandora_agent_daemon 2> /dev/null
+-	rm -Rf /sbin/init.d/pandora_agent_daemon 2> /dev/null
+-	rm -Rf /etc/rc.pandora_agent_daemon 2> /dev/null
+-	rm -Rf /etc/rc?.d/S90pandora_agent_daemon 2> /dev/null
+-	rm -Rf /sbin/rc?.d/S90pandora_agent_daemon 2> /dev/null
+-	rm -Rf /etc/rc?.d/S90pandora_agent 2> /dev/null
+-	rm -Rf /sbin/rc?.d/S90pandora_agent 2> /dev/null
+-	rm -Rf /etc/rc.d/rc?.d/S90pandora_agent_daemon 2> /dev/null
+-	rm -Rf /etc/rc.d/rc?.d/S90pandora_agent 2> /dev/null
+-	rm -Rf /usr/local/etc/rc.d/pandora_agent 2> /dev/null
++	if [ $FAKEROOT -ne 1 ]
++	then
++		rm -Rf /etc/init.d/pandora_agent_daemon 2> /dev/null
++		rm -Rf /sbin/init.d/pandora_agent_daemon 2> /dev/null
++		rm -Rf /etc/rc.pandora_agent_daemon 2> /dev/null
++		rm -Rf /etc/rc?.d/S90pandora_agent_daemon 2> /dev/null
++		rm -Rf /sbin/rc?.d/S90pandora_agent_daemon 2> /dev/null
++		rm -Rf /etc/rc?.d/S90pandora_agent 2> /dev/null
++		rm -Rf /sbin/rc?.d/S90pandora_agent 2> /dev/null
++		rm -Rf /etc/rc.d/rc?.d/S90pandora_agent_daemon 2> /dev/null
++		rm -Rf /etc/rc.d/rc?.d/S90pandora_agent 2> /dev/null
++		rm -Rf /usr/local/etc/rc.d/pandora_agent 2> /dev/null
++	fi
+ 	
+ 	rm -Rf $PANDORA_BASE$PANDORA_HOME 2> /dev/null
+ 	rm -Rf $PANDORA_BASE$PANDORA_LOG_DIR 2> /dev/null
+@@ -201,36 +212,48 @@
+ 	echo "Done"
+ }
+ 
+-install () {
++#
++# install_perl_script [OPTIONS] SRCFILE DESTFILE
++#	Install perl script. If PANDORA_PERL_DECODED_PATH is set, path of the perl
++#	in shebang line is replaced with PANDORA_PERL_DECODED_PATH value.
++#	OPTIONS:
++#		-o OWNER  owner of the installed script
++#		-g GROUP  group of the installed script
++#		-m PREM   mode of the installed script
++#
++install_perl_script () {
++	OWNER=""; GROUP=""; PERM=""
++	while :
++	do
++		case $1 in
++		-o) OWNER=$2;;
++		-g) GROUP=$2;;
++		-m) PERM=$2;;
++		*)  break;;
++		esac
++		shift;shift
++	done
++	SRC="$1"
++	DEST="$2"
+ 
+-	OS_VERSION=`uname -r`
+-	OS_NAME=`uname -s`
+-	OLDFILENAMETMP=`date +"%Y-%m-%d"`
+-
+-	if [ "$OS_NAME" = "FreeBSD" ]
++	# do install
++	if echo $PANDORA_PERL_PATH | grep "/" > /dev/null && [ "$PANDORA_PERL_PATH" != "/usr/bin/perl" ]
+ 	then
+-		PANDORA_HOME=/usr/local/share/pandora_agent
+-		PANDORA_BIN=/usr/local/bin/pandora_agent
+-		PANDORA_EXEC_BIN=/usr/local/bin/pandora_agent_exec
+-		PANDORA_REVENT_BIN=/usr/local/bin/pandora_revent
+-		PANDORA_CFG=/usr/local/etc/pandora
+-		TENTACLE=/usr/local/bin/tentacle_client
+-		TENTACLE_SERVER=/usr/local/bin/tentacle_server
+-		PANDORA_MAN=/usr/local/man
++		sed -e "s:^#\!.*:#\!$PANDORA_PERL_PATH:g" $SRC > $DEST
++	else
++		cp $SRC $DEST
+ 	fi
+ 
+-	if [ "$OS_NAME" = "NetBSD" ]
+-	then
+-		PANDORA_HOME=/usr/local/share/pandora_agent
+-		PANDORA_BIN=/usr/local/bin/pandora_agent
+-		PANDORA_EXEC_BIN=/usr/local/bin/pandora_agent_exec
+-		PANDORA_REVENT_BIN=/usr/local/bin/pandora_revent
+-		PANDORA_CFG=/usr/local/etc/pandora
+-		TENTACLE=/usr/local/bin/tentacle_client
+-		TENTACLE_SERVER=/usr/local/bin/tentacle_server
+-		PANDORA_MAN=/usr/share/man
+-	fi
++	# set owner, group and permissions
++	[ "$OWNER" ] && chown $OWNER $DEST 2>/dev/null
++	[ "$GROUP" ] && chgrp $GROUP $DEST 2>/dev/null
++	[ "$PERM"  ] && chmod $PERM  $DEST
++}
+ 
++install () {
++	OS_VERSION=`uname -r`
++	OLDFILENAMETMP=`date +"%Y-%m-%d"`
++
+ 	echo "Detecting Unix distribution: $OS_NAME version $OS_VERSION"
+ 	if [ -f $PANDORA_BASE$PANDORA_HOME ] && [ "$FORCE" = "0" ]
+ 	then
+@@ -253,87 +276,49 @@
+ 
+ 	# Alter dynamically the daemon launcher and setup the new path 
+ 	# if PANDORA_BASE is customized.
+-	if [ ! -z "$PANDORA_BASE" ]
++	if [ "$PANDORA_BASE" ] && [ $FAKEROOT -ne 1 ]
+ 	then
+-		if [ "$OS_NAME" = "FreeBSD" ]
+-		then
+-			DAEMON_SCRIPT=FreeBSD/pandora_agent
+-			DAEMON_TEMP=pandora_agent_daemon_temp
+-		elif [ "$OS_NAME" = "NetBSD" ]
+-		then
+-			DAEMON_SCRIPT=NetBSD/pandora_agent
+-			DAEMON_TEMP=pandora_agent_daemon_temp
+-		else
+-			DAEMON_SCRIPT=pandora_agent_daemon
+-			DAEMON_TEMP=pandora_agent_daemon_temp
+-		fi
++		DAEMON_TEMP=pandora_agent_daemon_temp
+ 
+ 		# Backup the daemon script
+-		cp -f "$DAEMON_SCRIPT" "$DAEMON_SCRIPT.bak"
++		cp -f "$DAEMON_SCRIPT" "${DAEMON_SCRIPT}.bak"
+ 		
+ 		AGENT_CFG=$OS_NAME/pandora_agent.conf
+ 		AGENT_CFG_TEMP=$OS_NAME/pandora_agent.conf.temp
+ 
+ 		# Backup the configuration file
+-		cp -f "$AGENT_CFG" "$AGENT_CFG.bak"
++		cp -f "$AGENT_CFG" "${AGENT_CFG}.bak"
+ 
+-		echo $PANDORA_BASE > PANDORA_BASE.temp
+-		sed 's/\//\\\//g' PANDORA_BASE.temp > PANDORA_BASE.temp2
+-
+-		PANDORA_BASE_DECODED=`cat PANDORA_BASE.temp2`
+-		rm PANDORA_BASE.temp PANDORA_BASE.temp2
+-
+-		if [ "$OS_NAME" = "FreeBSD" -o "$OS_NAME" = "NetBSD" ]
++		if [ "$OS_NAME" = "FreeBSD" ] || [ "$OS_NAME" = "NetBSD" ]
+ 		then
+-			sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/local\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP
++			sed -e "\|^PATH=|s|=|=$PANDORA_BASE$PREFIX/bin:|" \
++				-e "s|/usr/local/etc/pandora|$PANDORA_BASE$PANDORA_CFG|g" \
++				-e "s|/usr/local/bin/pandora_agent|$PANDORA_BASE$PANDORA_BIN|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/^command_args\=\"[.]*/command_args\=\"$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
++			sed -e "\|^PATH=|s|=|=$PANDORA_BASE/usr/bin:|" \
++				-e "\|^PANDORA_PATH=|s|=|=$PANDORA_BASE|" \
++				-e "\|^LOGFILE=|s|=|=$PANDORA_BASE|" \
++				-e "\|^DAEMON=|s|=|=$PANDORA_BASE|" \
++				-e "\|^DAEMON_TENTACLE=|s|=|=$PANDORA_BASE|" \
++				-e "s/^PANDORA_USER=.*/PANDORA_USER=$PANDORA_USER/"  \
++				$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
+-
+-			sed -e "s/^DAEMON_TENTACLE\=[.]*/DAEMON_TENTACLE\=$PANDORA_BASE_DECODED/g"  $DAEMON_SCRIPT > $DAEMON_TEMP
+-                        mv  $DAEMON_TEMP $DAEMON_SCRIPT
+- 
+-			sed -e "s/^PANDORA_USER\=.*/PANDORA_USER\=$PANDORA_USER/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
++		sed -e "s|^temporal[ 	]*|temporal $PANDORA_BASE|" \
++			-e "s|^logfile[ 	]*|logfile $PANDORA_BASE|" \
++			$AGENT_CFG > $AGENT_CFG_TEMP
+ 		mv $AGENT_CFG_TEMP $AGENT_CFG
+-
+-		sed -e "s/^logfile [.]*/logfile $PANDORA_BASE_DECODED/g" $AGENT_CFG > $AGENT_CFG_TEMP
+-		mv $AGENT_CFG_TEMP $AGENT_CFG
+ 	fi
+ 	echo "Creating Pandora FMS Agent home directory at $PANDORA_BASE$PANDORA_HOME"
+-	if [ ! -z "$PANDORA_BASE" ]
++	if [ "$PANDORA_BASE" ]
+ 	then
+ 		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" -o "$OS_NAME" = "NetBSD" ]
+-		then
+-			mkdir -p $PANDORA_BASE/usr/local/bin 2> /dev/null
+-		else
+-			mkdir -p $PANDORA_BASE/usr/bin 2> /dev/null
+-		fi
++		mkdir -p $PANDORA_BASE$PREFIX/bin 2> /dev/null
+ 	fi
+ 
+ 	mkdir -p $PANDORA_BASE$PANDORA_HOME 2> /dev/null
+@@ -344,14 +329,14 @@
+ 	mkdir -p $PANDORA_BASE$PANDORA_TEMP/data_out 2> /dev/null
+ 	mkdir -p $PANDORA_BASE$PANDORA_CFG 2> /dev/null
+ 	mkdir -p $PANDORA_BASE$PANDORA_LOG_DIR 2> /dev/null
+-
++	
+ 	# Set the user the agent will run as
+ 	if [ "$PANDORA_USER" != "root" ]
+ 	then
+ 		sed -e "s/.*pandora_user .*/pandora_user $PANDORA_USER/" $AGENT_CFG > $AGENT_CFG_TEMP 2> /dev/null && \
+-		mv $AGENT_CFG_TEMP $AGENT_CFG
++			mv $AGENT_CFG_TEMP $AGENT_CFG
+ 		chmod 755 pandora_agent_daemon
+-		chown -R $PANDORA_USER $PANDORA_BASE
++		chown -R $PANDORA_USER $PANDORA_BASE 2>/dev/null
+ 	fi
+ 
+ 	# Create logfile
+@@ -365,32 +350,10 @@
+ 
+ 	# Copying agent and securing it
+ 	echo "Copying Pandora FMS Agent to $PANDORA_BASE$PANDORA_BIN..."
++	install_perl_script -m 755 -o $PANDORA_USER -g 0 pandora_agent $PANDORA_BASE$PANDORA_BIN
++	install_perl_script -m 755 -o $PANDORA_USER -g 0 pandora_agent_exec $PANDORA_BASE$PANDORA_EXEC_BIN
++	install_perl_script -m 755 -o $PANDORA_USER -g 0 pandora_revent $PANDORA_BASE$PANDORA_REVENT_BIN
+ 
+-	if [ "$PANDORA_PERL_DECODED_PATH" != "" ]
+-	then
+-        	sed -e "s:^#\!.*:#\!$PANDORA_PERL_DECODED_PATH:g" pandora_agent > $PANDORA_BASE$PANDORA_BIN
+-	else
+-        	cp pandora_agent $PANDORA_BASE$PANDORA_BIN
+-	fi
+-	chmod 755 $PANDORA_BASE$PANDORA_BIN
+-	if [ "$PANDORA_PERL_DECODED_PATH" != "" ]
+-        then
+-                sed -e "s:^#\!.*:#\!$PANDORA_PERL_DECODED_PATH:g" pandora_agent_exec > $PANDORA_BASE$PANDORA_EXEC_BIN
+-        else
+-                cp pandora_agent_exec $PANDORA_BASE$PANDORA_EXEC_BIN
+-        fi
+-	chmod 755 $PANDORA_BASE$PANDORA_EXEC_BIN
+-	if [ "$PANDORA_PERL_DECODED_PATH" != "" ]
+-        then
+-                sed -e "s:^#\!.*:#\!$PANDORA_PERL_DECODED_PATH:g" pandora_revent > $PANDORA_BASE$PANDORA_REVENT_BIN
+-        else
+-                cp pandora_revent $PANDORA_BASE$PANDORA_REVENT_BIN
+-        fi
+-	chmod 755 $PANDORA_BASE$PANDORA_REVENT_BIN
+-	chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_BIN
+-	chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_EXEC_BIN
+-	chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_REVENT_BIN
+-
+ 	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
+@@ -400,49 +363,36 @@
+ 
+ 	echo "Copying Pandora FMS Agent plugins to $PANDORA_BASE$PANDORA_HOME/plugins..."
+ 
+-	if [ "$OS_NAME" = "NetBSD" ]
+-	then
+-		if [ ! -d $PANDORA_BASE$PANDORA_HOME/plugins ]
++	[ -d $PANDORA_BASE$PANDORA_HOME/plugins ] || mkdir -p $PANDORA_BASE$PANDORA_HOME/plugins >/dev/null 2>&1
++	for PLUGIN in plugins/*
++	do
++		if grep '^#!.*/perl' $PLUGIN >/dev/null 2>&1
+ 		then
+-			mkdir -p $PANDORA_BASE$PANDORA_HOME/plugins
++			install_perl_script $PLUGIN $PANDORA_BASE$PANDORA_HOME/$PLUGIN
++		else
++			cp $PLUGIN $PANDORA_BASE$PANDORA_HOME/plugins
+ 		fi
+-		for i in `ls -1 plugins`
+-		do 
+-			sed s:/usr/bin/perl:/usr/pkg/bin/perl: plugins/$i > plugins/$i.tmp
+-			cp plugins/$i.tmp $PANDORA_BASE$PANDORA_HOME/plugins/$i
+-			rm plugins/$i.tmp
+-		done
+-	else
+-		cp -r plugins $PANDORA_BASE$PANDORA_HOME
+-	fi
+-
++	done
+ 	chmod -R 700 $PANDORA_BASE$PANDORA_HOME/plugins
+-	ln -s $PANDORA_BASE$PANDORA_HOME/plugins $PANDORA_BASE$PANDORA_CFG
+ 
++	PANDORA_BASE_REAL="$PANDORA_BASE"
++	[ $FAKEROOT -eq 1 ] && PANDORA_BASE_REAL=""
++
++	ln -s $PANDORA_BASE_REAL$PANDORA_HOME/plugins $PANDORA_BASE$PANDORA_CFG
++
+ 	echo "Copying Pandora FMS Agent collections to $PANDORA_BASE$PANDORA_HOME/collections..."
+ 	cp -r collections $PANDORA_BASE$PANDORA_HOME
+ 	chmod -R 700 $PANDORA_BASE$PANDORA_HOME/collections
+-	ln -s $PANDORA_BASE$PANDORA_HOME/collections $PANDORA_BASE$PANDORA_CFG
++	ln -s $PANDORA_BASE_REAL$PANDORA_HOME/collections $PANDORA_BASE$PANDORA_CFG
+ 	
+-	echo "Copying tentacle server to $PANDORA_BASE$TENTACLE_SERVER"
+-	if [ "$PANDORA_PERL_DECODED_PATH" != "" ]
+-        then
+-                sed -e "s:^#\!.*:#\!$PANDORA_PERL_DECODED_PATH:g" tentacle_server > $PANDORA_BASE$TENTACLE_SERVER
+-        else
+-                cp tentacle_server $PANDORA_BASE$TENTACLE_SERVER
+-        fi
+-	chmod 755 $PANDORA_BASE$TENTACLE_SERVER	
+-	chown $PANDORA_USER:0 $PANDORA_BASE$TENTACLE_SERVER
++	if [ $WITHOUT_TENTACLE_SERVER -eq 0 ]
++	then
++		echo "Copying tentacle server to $PANDORA_BASE$TENTACLE_SERVER"
++		install_perl_script -m 755 -o $PANDORA_USER -g 0 tentacle_server $PANDORA_BASE$TENTACLE_SERVER
++	fi
+ 	
+ 	echo "Copying tentacle client to $PANDORA_BASE$TENTACLE"
+-	if [ "$PANDORA_PERL_DECODED_PATH" != "" ]
+-        then
+-                sed -e "s:^#\!.*:#\!$PANDORA_PERL_DECODED_PATH:g" tentacle_client > $PANDORA_BASE$TENTACLE
+-        else
+-                cp tentacle_client $PANDORA_BASE$TENTACLE
+-        fi
+-	chmod 755 $PANDORA_BASE$TENTACLE
+-	chown $PANDORA_USER:0 $PANDORA_BASE$TENTACLE	
++	install_perl_script -m 755 -o $PANDORA_USER -g 0 tentacle_client $PANDORA_BASE$TENTACLE	
+ 
+ 	echo "Installing the Pandora Agent and Tentacle Client manuals"
+ 	cp man/man1/tentacle_client.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
+@@ -451,14 +401,14 @@
+ 	chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/pandora_agent.1.gz
+ 
+ 	echo "Setting secure permissions and ownership for all Pandora FMS Agent files..."
+-	chown -R $PANDORA_USER $PANDORA_BASE$PANDORA_HOME
++	chown -R $PANDORA_USER $PANDORA_BASE$PANDORA_HOME  2>/dev/null
+ 	chmod -R 700 $PANDORA_BASE$PANDORA_TEMP/data_out
+ 	chmod 711 $PANDORA_BASE$PANDORA_LOG_DIR
+ 	chmod 640 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
+-	chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
+-	if [ "$OS_NAME" = "FreeBSD" -o "$OS_NAME" = "NetBSD" ]
++	chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG  2>/dev/null
++	if [ "$OS_NAME" = "FreeBSD" ] || [ "$OS_NAME" = "NetBSD" ]
+ 	then
+-		chown $PANDORA_USER:daemon $PANDORA_BASE$PANDORA_TEMP
++		chown $PANDORA_USER:daemon $PANDORA_BASE$PANDORA_TEMP 2>/dev/null
+ 		chmod -R 770 $PANDORA_BASE$PANDORA_TEMP
+ 		chmod 775 $PANDORA_BASE$PANDORA_TEMP
+ 	fi
+@@ -467,85 +417,55 @@
+ 
+ 	cp $OS_NAME/pandora_agent.conf $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf
+ 	chmod 600 $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf
+-	chown $PANDORA_USER $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf
++	chown $PANDORA_USER $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf 2>/dev/null
+ 
+-	if [ "$OS_NAME" = "FreeBSD" -o "$OS_NAME" = "NetBSD" ]
++	echo "Linking start-up daemon script '$DAEMON_SCRIPT' on $OS_NAME";
++
++	if [ "$OS_NAME" = "Darwin" ]
+ 	then
+-		echo "Linking start-up daemon script 'pandora_agent' on $OS_NAME";
++		# Specific service install on Darwin/macOSX
++		launchctl load -F Darwin/com.pandorafms.pandorafms.plist
++		echo "Start Pandora FMS service with 'launchctl start com.pandorafms.pandorafms'"
++		echo "This service has been scheduled to launch on each system startup"
+ 	else
+-		echo "Linking start-up daemon script 'pandora_agent_daemon' on $OS_NAME";
+-	fi
++		DESTDIR=""
++		[ "$PANDORA_BASE" ] && [ $FAKEROOT -eq 1 ] && DESTDIR=$PANDORA_BASE
+ 
+-	if [ "$OS_NAME" = "Darwin" ]
+-        then
+-        	# Specific service install on Darwin/macOSX
+-                launchctl load -F Darwin/com.pandorafms.pandorafms.plist
+-                echo "Start Pandora FMS service with 'launchctl start com.pandorafms.pandorafms'"
+-                echo "This service has been scheduled to launch on each system startup"
+-        fi
++		cp $DAEMON_SCRIPT $DESTDIR$PANDORA_STARTUP
++		chmod 755 $DESTDIR$PANDORA_STARTUP
++		chown root:0 $DESTDIR$PANDORA_STARTUP 2>/dev/null
+ 
+-	if [ "$OS_NAME" = "AIX" ]
+-	then
+-		cp pandora_agent_daemon /etc/rc.pandora_agent_daemon		
+-		ln -s /etc/rc.pandora_agent_daemon /etc/rc.d/rc2.d/S90pandora_agent_daemon
+-		chmod 755 $PANDORA_STARTUP
+-		chown root:0 $PANDORA_STARTUP
+-		echo "Pandora FMS agent has been included in /etc/rc.d/rc2.d/S90pandora_agent_daemon"
+-	fi
+-	
+-	if [ $OS_NAME = "HP-UX" ]
+-	then
+-		PANDORA_STARTUP=/sbin/init.d/pandora_agent_daemon
+-		cp pandora_agent_daemon $PANDORA_STARTUP
+-		ln -s /sbin/init.d/pandora_agent_daemon /sbin/rc3.d/S90pandora_agent_daemon 2> /dev/null
+-		ln -s /sbin/init.d/pandora_agent_daemon /sbin/rc2.d/S90pandora_agent_daemon 2> /dev/null
+-		chmod 755 $PANDORA_STARTUP
+-		chown root:0 $PANDORA_STARTUP
+-		echo "Pandora FMS agent has been included in /sbin/rcX.d/S90pandora_agent_daemon"
+-	fi
+-	
+-	if [ $OS_NAME = "SunOS" ]
+-	then
+-		PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon
+-		cp pandora_agent_daemon $PANDORA_STARTUP 
+-		ln -s /etc/init.d/pandora_agent_daemon /etc/rc2.d/S90pandora_agent_daemon 2> /dev/null
+-		chmod 755 $PANDORA_STARTUP
+-		chown root:0 $PANDORA_STARTUP
+-		echo "Pandora FMS agent has been included in /etc/rc2.d/S90pandora_agent_daemon"
+-	fi
+-	
+-	if [ $OS_NAME = "Linux" ]
+-	then
+-		PANDORA_STARTUP=/etc/init.d/pandora_agent_daemon
+-		cp pandora_agent_daemon $PANDORA_STARTUP
+-		if [ -d /etc/rc.d/ ]
++		RCDIRS=""
++		MSG=""
++		if [ "$OS_NAME" = "AIX" ]
+ 		then
+-			ln -s /etc/init.d/pandora_agent_daemon /etc/rc.d/rc2.d/S90pandora_agent 2> /dev/null
+-			ln -s /etc/init.d/pandora_agent_daemon /etc/rc.d/rc3.d/S90pandora_agent 2> /dev/null
+-		else
+-			ln -s /etc/init.d/pandora_agent_daemon /etc/rc2.d/S90pandora_agent 2> /dev/null
+-			ln -s /etc/init.d/pandora_agent_daemon /etc/rc2.d/S90pandora_agent 2> /dev/null
++			RCDIRS=/etc/rc.d/rc2.d
++			MSG="Pandora FMS agent has been included in $DESTDIR/etc/rc.d/rc2.d/S90pandora_agent_daemon"
++		elif [ "$OS_NAME" = "HP-UX" ]
++		then
++			RCDIRS="/sbin/rc2.d /sbin/rc3.d"
++			MSG="Pandora FMS agent has been included in $DESTDIR/sbin/rcX.d/S90pandora_agent_daemon"
++		elif [ "$OS_NAME" = "SunOS" ]
++		then
++			RCDIRS=/etc/rc2.d
++			MSG="Pandora FMS agent has been included in $DESTDIR/etc/rc2.d/S90pandora_agent_daemon"
++		elif [ "$OS_NAME" = "Linux" ]
++		then
++			if [ -d /etc/rc.d/ ]
++			then
++				RCDIRS="/etc/rc.d/rc2.d /etc/rc.d/rc3.d"
++			else
++				RCDIRS="/etc/rc2.d /etc/rc3.d"
++			fi
+ 		fi
+-		chmod 755 $PANDORA_STARTUP
+-		chown root:0 $PANDORA_STARTUP
++		[ "$RCDIRS" ] && for RCDIR in $RCDIRS
++		do
++			[ $FAKEROOT -eq 1 ] && [ ! -d $DESTDIR$RCDIR ] && mkdir -p $DESTDIR$RCDIR >/dev/null 2>&1
++			ln -s $PANDORA_STARTUP $DESTDIR$RCDIR/S90pandora_agent 2> /dev/null
++		done
++		[ "$MSG" ] && echo "$MSG"
+ 	fi
+ 
+-	if [ "$OS_NAME" = "FreeBSD" ]
+-	then
+-		PANDORA_STARTUP=/usr/local/etc/rc.d/pandora_agent
+-		cp FreeBSD/pandora_agent $PANDORA_STARTUP
+-		chmod 555 $PANDORA_STARTUP
+-		chown root:wheel $PANDORA_STARTUP
+-	fi
+-
+-	if [ "$OS_NAME" = "NetBSD" ]
+-	then
+-		PANDORA_STARTUP=/etc/rc.d/pandora_agent
+-		cp NetBSD/pandora_agent $PANDORA_STARTUP
+-		chmod 555 $PANDORA_STARTUP
+-		chown root:wheel $PANDORA_STARTUP
+-	fi
+-
+ 	echo "Done."
+ 	echo " "
+ 	echo "You have your startup script ready at $PANDORA_STARTUP"
+Index: plugins/who.sh
+===================================================================
+--- plugins/who.sh	(revision 10314)
++++ plugins/who.sh	(working copy)
+@@ -1,10 +1,10 @@
+-#!/bin/bash
++#!/bin/sh
+ echo "<module>";
+ echo "<name>who</name>";
+ echo "<type>async_string</type>";
+ echo "<data><![CDATA["
+ WHO=`who`
+-if [ "$WHO" == "" ]; then
++if [ "$WHO" = "" ]; then
+ 	echo "None"
+ else
+ 	echo $WHO
+Index: tentacle_server
+===================================================================
+--- tentacle_server	(revision 10314)
++++ tentacle_server	(working copy)
+@@ -60,9 +60,15 @@
+ use warnings;
+ use Getopt::Std;
+ use IO::Select;
++use threads;
+ use Thread::Semaphore;
+ use POSIX ":sys_wait_h";
++use Time::HiRes qw(usleep);
+ 
++# Constants for Win32 services.
++use constant WIN32_SERVICE_STOPPED => 0x01;
++use constant WIN32_SERVICE_RUNNING => 0x04;
++
+ my $t_libwrap_installed = eval { require Authen::Libwrap } ? 1 : 0;
+ 
+ if ($t_libwrap_installed) {
+@@ -77,9 +83,8 @@
+       : eval { require IO::Socket::INET }  ? 'IO::Socket::INET'
+       : die $@;
+ 
+-if ($SOCKET_MODULE eq 'IO::Socket::INET') {
+-	print_log ("IO::Socket::INET6 is not found. IPv6 is disabled.");
+-}
++# Service name for Win32.
++my $SERVICE_NAME="Tentacle Server";
+ 
+ # Program version
+ our $VERSION = '0.4.0';
+@@ -130,7 +135,7 @@
+ my $t_select;
+ 
+ # Semaphore
+-my $t_sem;
++my $t_sem :shared;
+ 
+ # Server socket
+ my @t_server_sockets;
+@@ -197,6 +202,7 @@
+ 	print ("\t-p port\t\tPort to listen on (default $t_port).\n");
+ 	print ("\t-q\t\tQuiet. Do now print error messages.\n");
+ 	print ("\t-r number\tNumber of retries for network opertions (default $t_retries).\n");
++	print ("\t-S (install|uninstall|run) Manage the win32 service.\n");
+ 	print ("\t-t time\t\tTime-out for network operations in seconds (default ${t_timeout}s).\n");
+ 	print ("\t-v\t\tBe verbose.\n");
+ 	print ("\t-w\t\tPrompt for OpenSSL private key password.\n");
+@@ -241,27 +247,6 @@
+ }
+ 
+ ################################################################################
+-## SUB start_win_service
+-## Turn the current process into a Windows service.
+-################################################################################
+-#sub start_win_service {
+-#	require Win32::Daemon;
+-#
+-#	# Tell the OS to start the service
+-#	Win32::Daemon::StartService ();
+-#
+-#	# Wait until the service manager is ready
+-#	while (SERVICE_START_PENDING != Win32::Daemon::State()) {
+-#		sleep (1);
+-#	}
+-#
+-#	# Tell the service manager we are running
+-#	Win32::Daemon::State (SERVICE_RUNNING);
+-#
+-#	# Call Win32::Daemon::StopService() when done
+-#}
+-
+-################################################################################
+ ## SUB parse_options
+ ## Parse command line options and initialize global variables.
+ ################################################################################
+@@ -271,7 +256,7 @@
+ 	my @t_addresses_tmp;
+ 
+ 	# Get options
+-	if (getopts ('a:c:de:f:hi:k:m:op:qr:s:t:vwx:b:g:T', \%opts) == 0 || defined ($opts{'h'})) {
++	if (getopts ('a:b:c:de:f:g:hi:k:m:op:qr:s:S:t:Tvwx:', \%opts) == 0 || defined ($opts{'h'})) {
+ 		print_help ();
+ 		exit 1;
+ 	}
+@@ -467,19 +452,33 @@
+ 			error ("Authen::Libwrap is not installed.");
+ 		}
+ 	}
+-}
+ 
+-################################################################################
+-## SUB sigchld_handler
+-## Handle child process termination.
+-################################################################################
+-sub sigchld_handler {
++	# Win32 service management
++	if (defined ($opts{'S'})) {
++		my $service_action = $opts{'S'};
++		if ($^O ne 'MSWin32') {
++			error ("Windows services are only available on Win32.");
++		} else {
++			eval "use Win32::Daemon";
++			die($@) if ($@);
+ 
+-	while (waitpid(-1, &WNOHANG) > 0) {
+-		$t_sem->up ();
++			if ($service_action eq 'install') {
++				install_service();
++			} elsif ($service_action eq 'uninstall') {
++				uninstall_service();
++			} elsif ($service_action eq 'run') {
++				Win32::Daemon::RegisterCallbacks({
++			        start       =>  \&callback_start,
++			        running     =>  \&callback_running,
++			        stop        =>  \&callback_stop,
++				});
++				Win32::Daemon::StartService();
++				exit 0;
++			} else {
++				error("Unknown action: $service_action");
++			}
++		}
+ 	}
+-
+-	$SIG{CHLD} = \&sigchld_handler;
+ }
+ 
+ ################################################################################
+@@ -660,87 +659,86 @@
+ }
+ 
+ ################################################################################
+-## SUB accept_connection
+-## Accept an incoming connection and fork.
++## SUB accept_connections
++## Manage incoming connections.
+ ################################################################################
+-sub accept_connection {
++sub accept_connections {
+ 	my $pid;
+ 	my $t_server_socket;
+ 
+-	my @ready = $select->can_read;
++	# Start server
++	start_server ();
+ 
+-	foreach $t_server_socket (@ready) {
++	# Initialize semaphore
++	$t_sem = Thread::Semaphore->new ($t_max_conn);
+ 
+-		# Accept connection
+-		$t_client_socket = $t_server_socket->accept ();
++	while (1) {
++		my @ready = $select->can_read;
++		foreach $t_server_socket (@ready) {
+ 
+-		if (! defined ($t_client_socket)) {
++			# Accept connection
++			$t_client_socket = $t_server_socket->accept ();

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408202001.s7KK1H7n091367>