2009-11-05 19:26:54 +01:00
|
|
|
#!/bin/sh
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
|
2009-11-05 19:26:54 +01:00
|
|
|
# **********************************************************************
|
|
|
|
# Pandora FMS Agent Installer for Unix (generic installer)
|
2015-11-13 04:02:03 +01:00
|
|
|
# (c) 2008-2015 Artica ST
|
2010-05-18 18:09:06 +02:00
|
|
|
# (c) 2008-2010 Sancho Lerena <slerena@gmail.com>
|
2009-11-05 19:26:54 +01:00
|
|
|
#
|
2013-04-21 02:36:33 +02:00
|
|
|
# This is a generic installer for all Unix-like systems.(AIX, HP-UX, SunOS, Linux, FreeBSD, NetBSD)
|
2010-05-18 18:09:06 +02:00
|
|
|
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
# **********************************************************************
|
|
|
|
|
2020-10-15 10:19:42 +02:00
|
|
|
PI_VERSION="7.0NG.750"
|
2020-11-23 01:00:16 +01:00
|
|
|
PI_BUILD="201123"
|
2009-11-05 19:26:54 +01:00
|
|
|
OS_NAME=`uname -s`
|
|
|
|
|
2010-05-18 18:09:06 +02:00
|
|
|
FORCE=0
|
|
|
|
LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`
|
2014-08-13 16:53:16 +02:00
|
|
|
|
|
|
|
PREFIX=/usr
|
2020-08-13 12:49:45 +02:00
|
|
|
if [ "$OS_NAME" = "FreeBSD" ] || [ "$OS_NAME" = "NetBSD" ] || [ "$OS_NAME" = "Darwin" ]
|
2014-08-13 16:53:16 +02:00
|
|
|
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
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
PANDORA_TEMP=/var/spool/pandora
|
|
|
|
PANDORA_CFG=/etc/pandora
|
2009-11-05 19:26:54 +01:00
|
|
|
PANDORA_LOG_DIR=/var/log/pandora
|
|
|
|
PANDORA_LOG=pandora_agent.log
|
2014-08-13 16:53:16 +02:00
|
|
|
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
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
|
|
|
|
MODE=$1
|
2014-08-13 16:53:16 +02:00
|
|
|
|
|
|
|
# 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|/$||'`
|
2012-04-20 15:29:22 +02:00
|
|
|
if [ "$3" != "" ]
|
|
|
|
then
|
|
|
|
PANDORA_USER=$3
|
2014-08-13 16:53:16 +02:00
|
|
|
if [ -z "$PANDORA_BASE" ]
|
2013-09-19 14:07:31 +02:00
|
|
|
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
|
2012-04-20 15:29:22 +02:00
|
|
|
fi
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
|
2014-08-13 16:53:16 +02:00
|
|
|
[ "$4" ] && PANDORA_PERL_PATH=$4
|
2013-02-27 16:35:35 +01:00
|
|
|
|
2010-05-18 18:09:06 +02:00
|
|
|
# Check for Perl 5.6.x or higher available
|
2019-12-05 02:26:50 +01:00
|
|
|
PERL_VERSION=`$PANDORA_PERL_PATH -v | egrep 'v5.[6-9]|v5.[1-3][0-9]' | grep perl`
|
2009-11-05 19:26:54 +01:00
|
|
|
|
|
|
|
if [ -z "$PERL_VERSION" ]
|
|
|
|
then
|
2010-05-18 18:09:06 +02:00
|
|
|
echo "Perl 5.6.x or higher is not detected. This is required for Pandora FMS"
|
2009-11-05 19:26:54 +01:00
|
|
|
echo "Detected: $PERL_VERSION "
|
|
|
|
echo "Aborting install..."
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2014-08-13 16:53:16 +02:00
|
|
|
if [ -z "`echo Linux HP-UX SunOS AIX Solaris Darwin BSD bsd FreeBSD NetBSD | grep \"$OS_NAME\"`" ]
|
2009-11-05 19:26:54 +01:00
|
|
|
then
|
2014-08-13 16:53:16 +02:00
|
|
|
echo "This system: '$OS_NAME' is not supported by this script"
|
2009-11-05 19:26:54 +01:00
|
|
|
echo "Please make the install yourself as it's described in documentation"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# check for root to do the install
|
2014-08-13 16:53:16 +02:00
|
|
|
if [ $FAKEROOT -ne 1 ] && [ -z "`id | grep \"uid=0(root)\"`" ]
|
2009-11-05 19:26:54 +01:00
|
|
|
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"
|
|
|
|
echo " "
|
|
|
|
echo "Aborting install"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2010-06-18 14:36:19 +02:00
|
|
|
help () {
|
|
|
|
echo "Syntax":
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
echo " "
|
2014-08-13 16:53:16 +02:00
|
|
|
echo " ./pandora_agent_installer < --mode > [ --option ] [ destination_path ] [ user_to_run_as ] [custom_perl_path]"
|
2010-05-18 18:09:06 +02:00
|
|
|
echo " "
|
2010-06-18 14:36:19 +02:00
|
|
|
echo "Modes:"
|
2009-11-05 19:26:54 +01:00
|
|
|
echo " "
|
2010-06-18 14:36:19 +02:00
|
|
|
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/remove Pandora FMS Agent on this System"
|
|
|
|
echo " "
|
2014-08-13 16:53:16 +02:00
|
|
|
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 " "
|
2010-05-18 18:09:06 +02:00
|
|
|
echo "Some exaples of how to use the installer:"
|
|
|
|
echo " "
|
2009-11-05 19:26:54 +01:00
|
|
|
echo " ./pandora_agent_installer --install"
|
2010-05-18 18:09:06 +02:00
|
|
|
echo " ./pandora_agent_installer --install /opt/pandora"
|
2010-06-18 14:36:19 +02:00
|
|
|
echo " ./pandora_agent_installer --install \"\" pandora"
|
2013-02-27 16:35:35 +01:00
|
|
|
echo " ./pandora_agent_installer --install /opt/pandora root /opt/pandora/perl5/usr/local/bin/perl"
|
2010-06-18 14:36:19 +02:00
|
|
|
echo " ./pandora_agent_installer --uninstall /opt/pandora"
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
echo " "
|
2010-06-18 14:36:19 +02:00
|
|
|
}
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
|
2009-11-05 19:26:54 +01:00
|
|
|
uninstall () {
|
2014-05-26 16:59:54 +02:00
|
|
|
if [ "$OS_NAME" = "Darwin" ]
|
|
|
|
then
|
2020-08-13 12:49:45 +02:00
|
|
|
launchctl stop com.pandorafms.pandorafms
|
2014-05-26 16:59:54 +02:00
|
|
|
launchctl remove com.pandorafms.pandorafms
|
|
|
|
rm /Library/LaunchDaemons/com.pandorafms.pandorafms.plist 2> /dev/null
|
|
|
|
fi
|
|
|
|
|
2017-07-18 17:28:26 +02:00
|
|
|
# Stops the agent on uninstall
|
|
|
|
if [ -f $PANDORA_BASE/etc/init.d/pandora_agent_daemon ]; then
|
|
|
|
$PANDORA_BASE/etc/init.d/pandora_agent_daemon stop 12> /dev/null
|
|
|
|
else
|
|
|
|
echo "$PANDORA_BASE/etc/init.d/pandora_agent_daemon not found to stop agent"
|
|
|
|
fi
|
|
|
|
|
2009-11-05 19:26:54 +01:00
|
|
|
echo "Removing Pandora FMS Agent..."
|
2010-05-18 18:09:06 +02:00
|
|
|
rm -Rf $PANDORA_BASE$PANDORA_BIN 2> /dev/null
|
2010-06-18 14:36:19 +02:00
|
|
|
rm -Rf $PANDORA_BASE$PANDORA_EXEC_BIN 2> /dev/null
|
2013-03-12 18:53:25 +01:00
|
|
|
rm -Rf $PANDORA_BASE$PANDORA_REVENT_BIN 2> /dev/null
|
2015-11-02 16:52:30 +01:00
|
|
|
rm -f $DESTDIR/etc/logrotate.d/pandora_agent
|
2020-08-13 12:49:45 +02:00
|
|
|
rm -f $DESTDIR/etc/newsyslog.d/pandora_agent.conf
|
2019-09-04 12:43:30 +02:00
|
|
|
|
|
|
|
# Remove systemd service if exists
|
2020-05-28 15:50:49 +02:00
|
|
|
if [ `systemctl --v 2> /dev/null | grep systemd | wc -l` != 0 ]
|
2019-09-04 12:43:30 +02:00
|
|
|
then
|
|
|
|
PANDORA_AGENT_SERVICE="/etc/systemd/system/pandora_agent_daemon.service"
|
|
|
|
rm -f $PANDORA_AGENT_SERVICE
|
|
|
|
systemctl reset-failed
|
|
|
|
fi
|
|
|
|
|
2010-02-11 18:21:42 +01:00
|
|
|
#Test if exist Pandora Server in this machine
|
2010-05-18 18:09:06 +02:00
|
|
|
if [ -d $PANDORA_BASE$PANDORA_TEMP/data_in ]
|
2010-02-11 18:21:42 +01:00
|
|
|
then
|
|
|
|
echo "You have a Pandora Server in this machine. Then don't delete "$PANDORA_TEMP
|
2010-07-20 13:37:29 +02:00
|
|
|
rm -Rf $PANDORA_BASE$PANDORA_TEMP/data_out 2> /dev/null
|
2010-02-11 18:21:42 +01:00
|
|
|
else
|
2010-05-18 18:09:06 +02:00
|
|
|
rm -Rf $PANDORA_BASE$PANDORA_TEMP 2> /dev/null
|
2011-04-11 18:35:45 +02:00
|
|
|
rm -Rf $PANDORA_BASE$TENTACLE_SERVER 2> /dev/null
|
2010-05-18 18:09:06 +02:00
|
|
|
fi
|
|
|
|
rm -Rf $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf 2> /dev/null
|
2009-11-05 19:26:54 +01:00
|
|
|
|
2010-05-18 18:09:06 +02:00
|
|
|
rm -Rf $PANDORA_BASE/etc/init.d/pandora_agent_daemon 2> /dev/null
|
|
|
|
rm -Rf $PANDORA_BASE/sbin/init.d/pandora_agent_daemon 2> /dev/null
|
|
|
|
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
|
2010-11-29 13:50:14 +01:00
|
|
|
rm -Rf $PANDORA_BASE/etc/rc?.d/S90pandora_agent 2> /dev/null
|
|
|
|
rm -Rf $PANDORA_BASE/sbin/rc?.d/S90pandora_agent 2> /dev/null
|
|
|
|
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
|
2010-06-07 03:36:45 +02:00
|
|
|
rm -Rf $PANDORA_BASE/usr/local/etc/rc.d/pandora_agent 2> /dev/null
|
2014-08-13 16:53:16 +02:00
|
|
|
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
|
2009-11-05 19:26:54 +01:00
|
|
|
|
2010-05-18 18:09:06 +02:00
|
|
|
rm -Rf $PANDORA_BASE$PANDORA_HOME 2> /dev/null
|
2014-09-18 19:06:16 +02:00
|
|
|
rm -Rf $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG 2> /dev/null
|
2010-05-18 18:09:06 +02:00
|
|
|
rm -Rf $PANDORA_BASE$TENTACLE 2> /dev/null
|
2009-11-05 19:26:54 +01:00
|
|
|
|
2010-06-07 03:36:45 +02:00
|
|
|
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
|
|
|
|
|
2015-08-19 10:59:38 +02:00
|
|
|
# Skip delete of /etc/pandora if exists configuration of a server or satellite
|
|
|
|
if [ ! -f $PANDORA_BASE/$PANDORA_CFG/pandora_server.conf -a ! -f $PANDORA_BASE/$PANDORA_CFG/satellite_server.conf ]
|
2009-11-05 19:26:54 +01:00
|
|
|
then
|
2010-06-07 03:36:45 +02:00
|
|
|
rm -Rf $PANDORA_BASE/$PANDORA_CFG 2> /dev/null
|
2009-11-05 19:26:54 +01:00
|
|
|
fi
|
|
|
|
|
2010-11-15 11:32:23 +01:00
|
|
|
if [ ! -z "$PANDORA_BASE" ]
|
|
|
|
then
|
|
|
|
echo "Please delete manually $PANDORA_BASE for complete uninstall"
|
|
|
|
fi
|
2010-05-18 18:09:06 +02:00
|
|
|
|
2009-11-05 19:26:54 +01:00
|
|
|
echo " "
|
|
|
|
echo "Done"
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
}
|
|
|
|
|
2014-08-13 16:53:16 +02:00
|
|
|
#
|
|
|
|
# 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"
|
|
|
|
|
|
|
|
# do install
|
|
|
|
if echo $PANDORA_PERL_PATH | grep "/" > /dev/null && [ "$PANDORA_PERL_PATH" != "/usr/bin/perl" ]
|
2010-06-07 03:36:45 +02:00
|
|
|
then
|
2014-08-13 16:53:16 +02:00
|
|
|
sed -e "s:^#\!.*:#\!$PANDORA_PERL_PATH:g" $SRC > $DEST
|
|
|
|
else
|
|
|
|
cp $SRC $DEST
|
2010-06-07 03:36:45 +02:00
|
|
|
fi
|
|
|
|
|
2014-08-13 16:53:16 +02:00
|
|
|
# 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"`
|
2013-04-21 02:36:33 +02:00
|
|
|
|
2009-11-05 19:26:54 +01:00
|
|
|
echo "Detecting Unix distribution: $OS_NAME version $OS_VERSION"
|
2010-05-18 18:09:06 +02:00
|
|
|
if [ -f $PANDORA_BASE$PANDORA_HOME ] && [ "$FORCE" = "0" ]
|
2009-11-05 19:26:54 +01:00
|
|
|
then
|
2011-12-07 11:07:43 +01:00
|
|
|
echo "Seems that default dir already exists. Please use --force-install to"
|
2010-05-18 18:09:06 +02:00
|
|
|
echo "force installer to install on $PANDORA_BASE$PANDORA_HOME"
|
2009-11-05 19:26:54 +01:00
|
|
|
exit
|
|
|
|
else
|
2010-05-18 18:09:06 +02:00
|
|
|
echo "Checking default dir $PANDORA_BASE$PANDORA_HOME..."
|
2009-11-05 19:26:54 +01:00
|
|
|
fi
|
|
|
|
|
2010-05-18 18:09:06 +02:00
|
|
|
if [ -f $PANDORA_BASE$PANDORA_BIN ] && [ "$FORCE" = "0" ]
|
2009-11-05 19:26:54 +01:00
|
|
|
then
|
2011-12-07 11:07:43 +01:00
|
|
|
echo "Seems that $PANDORA_BASE$PANDORA_BIN already exists. Please use --force-install to"
|
2009-11-05 19:26:54 +01:00
|
|
|
echo "force installer to reinstall overwriting it"
|
|
|
|
echo " "
|
|
|
|
exit
|
|
|
|
else
|
2010-05-18 18:09:06 +02:00
|
|
|
echo "Checking Pandora FMS Agent on $PANDORA_BASE$PANDORA_BIN...."
|
2009-11-05 19:26:54 +01:00
|
|
|
fi
|
|
|
|
|
2011-12-07 11:07:43 +01:00
|
|
|
# Alter dynamically the daemon launcher and setup the new path
|
|
|
|
# if PANDORA_BASE is customized.
|
2014-08-13 16:53:16 +02:00
|
|
|
if [ "$PANDORA_BASE" ] && [ $FAKEROOT -ne 1 ]
|
2010-11-19 15:18:34 +01:00
|
|
|
then
|
2014-08-13 16:53:16 +02:00
|
|
|
DAEMON_TEMP=pandora_agent_daemon_temp
|
2014-05-26 16:59:54 +02:00
|
|
|
|
2012-04-20 15:29:22 +02:00
|
|
|
# Backup the daemon script
|
2014-08-13 16:53:16 +02:00
|
|
|
cp -f "$DAEMON_SCRIPT" "${DAEMON_SCRIPT}.bak"
|
2012-04-20 15:29:22 +02:00
|
|
|
|
2011-12-07 11:07:43 +01:00
|
|
|
AGENT_CFG=$OS_NAME/pandora_agent.conf
|
|
|
|
AGENT_CFG_TEMP=$OS_NAME/pandora_agent.conf.temp
|
2010-11-19 15:18:34 +01:00
|
|
|
|
2012-04-20 15:29:22 +02:00
|
|
|
# Backup the configuration file
|
2014-08-13 16:53:16 +02:00
|
|
|
cp -f "$AGENT_CFG" "${AGENT_CFG}.bak"
|
2012-04-20 15:29:22 +02:00
|
|
|
|
2020-08-13 12:49:45 +02:00
|
|
|
if [ "$OS_NAME" = "FreeBSD" ] || [ "$OS_NAME" = "NetBSD" ] || [ "$OS_NAME" = "Darwin" ]
|
2011-12-07 11:07:43 +01:00
|
|
|
then
|
2014-08-13 16:53:16 +02:00
|
|
|
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
|
2011-12-07 11:07:43 +01:00
|
|
|
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
|
|
|
else
|
2014-08-13 16:53:16 +02:00
|
|
|
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
|
2011-12-07 11:07:43 +01:00
|
|
|
mv $DAEMON_TEMP $DAEMON_SCRIPT
|
|
|
|
fi
|
2010-11-19 15:18:34 +01:00
|
|
|
|
2014-09-19 11:24:51 +02:00
|
|
|
sed -e "s|^temporal[ \t][ \t]*|temporal $PANDORA_BASE|" \
|
|
|
|
-e "s|^logfile[ \t][ \t]*|logfile $PANDORA_BASE|" \
|
2014-08-13 16:53:16 +02:00
|
|
|
$AGENT_CFG > $AGENT_CFG_TEMP
|
2011-12-07 11:07:43 +01:00
|
|
|
mv $AGENT_CFG_TEMP $AGENT_CFG
|
|
|
|
fi
|
|
|
|
echo "Creating Pandora FMS Agent home directory at $PANDORA_BASE$PANDORA_HOME"
|
2014-08-13 16:53:16 +02:00
|
|
|
if [ "$PANDORA_BASE" ]
|
2010-06-07 03:36:45 +02:00
|
|
|
then
|
2011-12-07 11:07:43 +01:00
|
|
|
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
|
2014-08-13 16:53:16 +02:00
|
|
|
mkdir -p $PANDORA_BASE$PREFIX/bin 2> /dev/null
|
2010-06-07 03:36:45 +02:00
|
|
|
fi
|
2010-05-18 18:09:06 +02:00
|
|
|
|
|
|
|
mkdir -p $PANDORA_BASE$PANDORA_HOME 2> /dev/null
|
|
|
|
|
|
|
|
# Create directories based on PANDORA_BASE
|
|
|
|
|
|
|
|
mkdir -p $PANDORA_BASE/tmp 2> /dev/null
|
|
|
|
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
|
2014-08-13 16:53:16 +02:00
|
|
|
|
2012-04-20 15:29:22 +02:00
|
|
|
# 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 && \
|
2014-08-13 16:53:16 +02:00
|
|
|
mv $AGENT_CFG_TEMP $AGENT_CFG
|
2012-04-20 15:29:22 +02:00
|
|
|
chmod 755 pandora_agent_daemon
|
2014-08-13 16:53:16 +02:00
|
|
|
chown -R $PANDORA_USER $PANDORA_BASE 2>/dev/null
|
2012-04-20 15:29:22 +02:00
|
|
|
fi
|
|
|
|
|
2009-11-05 19:26:54 +01:00
|
|
|
# Create logfile
|
2010-05-18 18:09:06 +02:00
|
|
|
if [ ! -z "`touch $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG`" ]
|
2009-11-05 19:26:54 +01:00
|
|
|
then
|
2010-05-18 18:09:06 +02:00
|
|
|
echo "Seems to be a problem generating logfile ($PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG) please check it";
|
2009-11-05 19:26:54 +01:00
|
|
|
else
|
2010-05-18 18:09:06 +02:00
|
|
|
echo "Created logfile at $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG..."
|
2009-11-05 19:26:54 +01:00
|
|
|
fi
|
2010-05-18 18:09:06 +02:00
|
|
|
echo "$LOG_TIMESTAMP Pandora FMS installer has created this file at startup" > $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
|
2009-11-05 19:26:54 +01:00
|
|
|
|
|
|
|
# Copying agent and securing it
|
2010-05-18 18:09:06 +02:00
|
|
|
echo "Copying Pandora FMS Agent to $PANDORA_BASE$PANDORA_BIN..."
|
2014-08-13 16:53:16 +02:00
|
|
|
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
|
2010-06-07 03:36:45 +02:00
|
|
|
|
|
|
|
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"
|
2009-11-05 19:26:54 +01:00
|
|
|
fi
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
|
2010-05-18 18:09:06 +02:00
|
|
|
echo "Copying Pandora FMS Agent plugins to $PANDORA_BASE$PANDORA_HOME/plugins..."
|
2013-04-21 02:36:33 +02:00
|
|
|
|
2014-08-13 16:53:16 +02:00
|
|
|
[ -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
|
2013-04-21 02:36:33 +02:00
|
|
|
then
|
2014-08-13 16:53:16 +02:00
|
|
|
install_perl_script $PLUGIN $PANDORA_BASE$PANDORA_HOME/$PLUGIN
|
|
|
|
else
|
|
|
|
cp $PLUGIN $PANDORA_BASE$PANDORA_HOME/plugins
|
2013-04-21 02:36:33 +02:00
|
|
|
fi
|
2014-08-13 16:53:16 +02:00
|
|
|
done
|
2010-05-18 18:09:06 +02:00
|
|
|
chmod -R 700 $PANDORA_BASE$PANDORA_HOME/plugins
|
2014-08-13 16:53:16 +02:00
|
|
|
|
2014-08-14 06:28:27 +02:00
|
|
|
PANDORA_BASE_REAL="$PANDORA_BASE"
|
|
|
|
[ $FAKEROOT -eq 1 ] && PANDORA_BASE_REAL=""
|
2014-08-13 16:53:16 +02:00
|
|
|
|
2014-08-14 06:28:27 +02:00
|
|
|
ln -s $PANDORA_BASE_REAL$PANDORA_HOME/plugins $PANDORA_BASE$PANDORA_CFG
|
2010-07-20 12:45:55 +02:00
|
|
|
|
2018-09-19 18:39:19 +02:00
|
|
|
echo "Creating the collections directory in to $PANDORA_BASE$PANDORA_HOME/collections..."
|
|
|
|
mkdir -p $PANDORA_BASE$PANDORA_HOME/collections
|
2010-07-20 12:45:55 +02:00
|
|
|
chmod -R 700 $PANDORA_BASE$PANDORA_HOME/collections
|
2014-08-14 06:28:27 +02:00
|
|
|
ln -s $PANDORA_BASE_REAL$PANDORA_HOME/collections $PANDORA_BASE$PANDORA_CFG
|
2019-11-21 18:21:46 +01:00
|
|
|
|
|
|
|
echo "Creating the commands directory in $PANDORA_BASE$PANDORA_HOME/commands..."
|
|
|
|
mkdir -p $PANDORA_BASE$PANDORA_HOME/commands
|
|
|
|
chmod -R 700 $PANDORA_BASE$PANDORA_HOME/commands
|
|
|
|
ln -s $PANDORA_BASE_REAL$PANDORA_HOME/commands $PANDORA_BASE$PANDORA_CFG
|
2011-04-11 18:35:45 +02:00
|
|
|
|
2014-08-13 16:53:16 +02:00
|
|
|
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
|
2011-04-11 18:35:45 +02:00
|
|
|
|
2010-05-18 18:09:06 +02:00
|
|
|
echo "Copying tentacle client to $PANDORA_BASE$TENTACLE"
|
2014-08-13 16:53:16 +02:00
|
|
|
install_perl_script -m 755 -o $PANDORA_USER -g 0 tentacle_client $PANDORA_BASE$TENTACLE
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
|
2010-06-09 13:29:23 +02:00
|
|
|
echo "Installing the Pandora Agent and Tentacle Client manuals"
|
2010-11-15 11:32:23 +01:00
|
|
|
cp man/man1/tentacle_client.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
|
|
|
|
chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/tentacle_client.1.gz
|
|
|
|
cp man/man1/pandora_agent.1.gz $PANDORA_BASE/$PANDORA_MAN/man1
|
|
|
|
chmod 644 $PANDORA_BASE/$PANDORA_MAN/man1/pandora_agent.1.gz
|
2010-05-12 17:03:10 +02:00
|
|
|
|
2010-05-18 18:09:06 +02:00
|
|
|
echo "Setting secure permissions and ownership for all Pandora FMS Agent files..."
|
2014-08-13 16:53:16 +02:00
|
|
|
chown -R $PANDORA_USER $PANDORA_BASE$PANDORA_HOME 2>/dev/null
|
2010-07-20 13:37:29 +02:00
|
|
|
chmod -R 700 $PANDORA_BASE$PANDORA_TEMP/data_out
|
2013-02-19 11:28:33 +01:00
|
|
|
chmod 711 $PANDORA_BASE$PANDORA_LOG_DIR
|
2010-05-18 18:09:06 +02:00
|
|
|
chmod 640 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG
|
2014-08-13 16:53:16 +02:00
|
|
|
chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG 2>/dev/null
|
|
|
|
if [ "$OS_NAME" = "FreeBSD" ] || [ "$OS_NAME" = "NetBSD" ]
|
2010-06-07 03:36:45 +02:00
|
|
|
then
|
2014-08-13 16:53:16 +02:00
|
|
|
chown $PANDORA_USER:daemon $PANDORA_BASE$PANDORA_TEMP 2>/dev/null
|
2010-11-15 11:32:23 +01:00
|
|
|
chmod -R 770 $PANDORA_BASE$PANDORA_TEMP
|
|
|
|
chmod 775 $PANDORA_BASE$PANDORA_TEMP
|
2010-06-07 03:36:45 +02:00
|
|
|
fi
|
2010-05-18 18:09:06 +02:00
|
|
|
|
2011-12-07 11:07:43 +01:00
|
|
|
echo "Copying default agent configuration to $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf"
|
2010-05-18 18:09:06 +02:00
|
|
|
|
|
|
|
cp $OS_NAME/pandora_agent.conf $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf
|
|
|
|
chmod 600 $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf
|
2014-08-13 16:53:16 +02:00
|
|
|
chown $PANDORA_USER $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf 2>/dev/null
|
2009-11-05 19:26:54 +01:00
|
|
|
|
2014-08-13 16:53:16 +02:00
|
|
|
echo "Linking start-up daemon script '$DAEMON_SCRIPT' on $OS_NAME";
|
2009-11-05 19:26:54 +01:00
|
|
|
|
2014-05-26 16:59:54 +02:00
|
|
|
if [ "$OS_NAME" = "Darwin" ]
|
2009-11-05 19:26:54 +01:00
|
|
|
then
|
2014-08-13 16:53:16 +02:00
|
|
|
# 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
|
2014-08-14 06:28:27 +02:00
|
|
|
DESTDIR=""
|
|
|
|
[ "$PANDORA_BASE" ] && [ $FAKEROOT -eq 1 ] && DESTDIR=$PANDORA_BASE
|
|
|
|
|
2014-08-13 16:53:16 +02:00
|
|
|
cp $DAEMON_SCRIPT $DESTDIR$PANDORA_STARTUP
|
|
|
|
chmod 755 $DESTDIR$PANDORA_STARTUP
|
|
|
|
chown root:0 $DESTDIR$PANDORA_STARTUP 2>/dev/null
|
|
|
|
|
|
|
|
RCDIRS=""
|
|
|
|
MSG=""
|
|
|
|
if [ "$OS_NAME" = "AIX" ]
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
then
|
2014-08-13 16:53:16 +02:00
|
|
|
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
|
2019-09-04 12:43:30 +02:00
|
|
|
|
|
|
|
# Create systemd service
|
2020-05-28 15:50:49 +02:00
|
|
|
if [ `systemctl --v 2> /dev/null | grep systemd | wc -l` != 0 ]
|
2019-09-04 12:43:30 +02:00
|
|
|
then
|
|
|
|
echo "Creating systemd service for pandora_agent_daemon"
|
|
|
|
|
|
|
|
PANDORA_AGENT_SERVICE="/etc/systemd/system/pandora_agent_daemon.service"
|
|
|
|
EXEC_START='ExecStart='$PANDORA_BASE$PANDORA_BIN' '$PANDORA_BASE$PANDORA_CFG
|
|
|
|
|
|
|
|
rm -f $PANDORA_AGENT_SERVICE
|
|
|
|
cp pandora_agent_daemon.service $PANDORA_AGENT_SERVICE
|
|
|
|
|
|
|
|
sed -i "s|^ExecStart=.*$|$EXEC_START|g" $PANDORA_AGENT_SERVICE
|
|
|
|
|
|
|
|
systemctl daemon-reload
|
|
|
|
fi
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
fi
|
2014-08-13 16:53:16 +02:00
|
|
|
[ "$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"
|
2013-04-21 02:36:33 +02:00
|
|
|
fi
|
2015-11-02 16:52:30 +01:00
|
|
|
|
2020-08-13 12:49:45 +02:00
|
|
|
if [ -d /etc/logrotate.d ] && [ "$OS_NAME" != "Darwin" ]
|
2015-11-02 16:52:30 +01:00
|
|
|
then
|
|
|
|
[ -d $DESTDIR/etc/logrotate.d ] && mkdir -p $DESTDIR/etc/logrotate.d
|
|
|
|
echo "Creating logrotate.d entry for Pandora FMS log management"
|
2016-03-03 05:02:45 +01:00
|
|
|
sed -e "s|^/var/log/pandora/pandora_agent.log|$PANDORA_BASE_REAL$PANDORA_LOG_DIR/$PANDORA_LOG|" pandora_agent_logrotate \
|
|
|
|
> $DESTDIR/etc/logrotate.d/pandora_agent
|
2020-08-13 12:49:45 +02:00
|
|
|
elif [ "$OS_NAME" = "Darwin" ]
|
|
|
|
then
|
|
|
|
echo "Creating newsyslog entry for Pandora FMS log management"
|
|
|
|
echo "/var/log/pandora/pandora_agent.log : 640 5 2048 * Z" > $DESTDIR/etc/newsyslog.d/pandora_agent.conf
|
2015-11-02 16:52:30 +01:00
|
|
|
else
|
|
|
|
echo "Please add a log rotation schedule manually to your log rotation daemon (if any)"
|
|
|
|
fi
|
2013-04-21 02:36:33 +02:00
|
|
|
|
2009-11-05 19:26:54 +01:00
|
|
|
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."
|
2010-11-15 11:32:23 +01:00
|
|
|
echo " "
|
2009-11-05 19:26:54 +01:00
|
|
|
echo "If you want to use SSH, firstly you need to copy your public SSH keys "
|
|
|
|
echo " ($HOME/.ssh/id_dsa) under /home/pandora/.ssh/authorized_keys "
|
|
|
|
echo "on your Pandora FMS Server host"
|
|
|
|
echo " "
|
2016-01-26 17:55:42 +01:00
|
|
|
echo "You may need to install manually some additional required dependencies:"
|
|
|
|
echo "perl-Sys-Syslog"
|
|
|
|
echo " "
|
2014-08-14 06:28:27 +02:00
|
|
|
echo "You also need to setup your $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf config file"
|
2009-11-05 19:26:54 +01:00
|
|
|
echo " "
|
2010-06-07 03:36:45 +02:00
|
|
|
if [ "$OS_NAME" = "FreeBSD" ]
|
|
|
|
then
|
2010-11-15 11:32:23 +01:00
|
|
|
echo "Define 'pandora_agent_enable=\"YES\"' in /etc/rc.conf to enable the daemon."
|
2013-04-21 02:36:33 +02:00
|
|
|
elif [ "$OS_NAME" = "NetBSD" ]
|
|
|
|
then
|
|
|
|
echo "Define 'pandora_agent=\"YES\"' in /etc/rc.conf to enable the daemon."
|
2010-06-07 03:36:45 +02:00
|
|
|
else
|
2010-11-15 11:32:23 +01:00
|
|
|
echo "Check your startup configuration to be sure Pandora FMS Agent is ready "
|
|
|
|
echo "to start automatically when system restarts":
|
2010-06-07 03:36:45 +02:00
|
|
|
fi
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
|
2012-04-20 15:29:22 +02:00
|
|
|
# Restore the daemon script
|
|
|
|
cp -f "$DAEMON_SCRIPT.bak" "$DAEMON_SCRIPT" >/dev/null 2>&1
|
|
|
|
rm -f "$DAEMON_SCRIPT.bak" >/dev/null 2>&1
|
|
|
|
|
|
|
|
# Restore the configuration file
|
|
|
|
cp -f "$AGENT_CFG.bak" "$AGENT_CFG" >/dev/null 2>&1
|
|
|
|
rm -f "$AGENT_CFG.bak" >/dev/null 2>&1
|
|
|
|
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
}
|
|
|
|
|
2010-06-18 14:36:19 +02:00
|
|
|
if [ ! -f "pandora_agent" ]
|
|
|
|
then
|
2010-05-18 18:09:06 +02:00
|
|
|
echo " "
|
2010-06-18 14:36:19 +02:00
|
|
|
echo "Execute installer from the directory where you have your files. "
|
|
|
|
help
|
|
|
|
exit 1
|
|
|
|
fi
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
|
|
|
|
# Script banner at start
|
|
|
|
echo " "
|
2015-11-13 04:02:03 +01:00
|
|
|
echo "Pandora FMS Agent UNIX Installer $PI_VERSION $PI_BUILD (c) 2008-2015 ArticaST"
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
echo "This program is licensed under GPL2 Terms. http://pandorafms.com"
|
|
|
|
echo " "
|
|
|
|
|
2010-05-18 18:09:06 +02:00
|
|
|
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
case "$MODE" in
|
|
|
|
|
|
|
|
'--force-install')
|
2010-11-15 11:32:23 +01:00
|
|
|
FORCE=1
|
|
|
|
install
|
|
|
|
exit
|
|
|
|
;;
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
|
|
|
|
'--install')
|
2010-11-15 11:32:23 +01:00
|
|
|
install
|
|
|
|
exit
|
|
|
|
;;
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
|
|
|
|
'--uninstall')
|
2010-11-15 11:32:23 +01:00
|
|
|
uninstall
|
|
|
|
exit
|
|
|
|
;;
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
|
|
|
|
*)
|
2010-11-15 11:32:23 +01:00
|
|
|
help
|
|
|
|
;;
|
2009-09-14 Ramon Novoa <rnovoa@artica.es>
* unix, unix/pandora_agent_installer,
unix/plugins, unix/pandora_agent,
unix/pandora_agent_daemon, unix/AUTHORS,
unix/pandora_agent.conf, unix/COPYING,
unix/pandora_agent.spec, unix/tentacle_client,
unix/README: Added to repository. Generic Pandora FMS Unix agent
written in PERL. The skeleton files where copied from the linux
subdirectory.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1940 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-09-14 17:57:00 +02:00
|
|
|
esac
|
|
|
|
|