Merge branch 'ent-8673-13219-r-works-instalador-de-tentacle_server' into 'develop'
ent-8673-13219-r-works-instalador-de-tentacle_server See merge request artica/pandorafms!4958
This commit is contained in:
commit
0bbfa02498
|
@ -0,0 +1,4 @@
|
|||
dist/
|
||||
blib/
|
||||
Makefile
|
||||
pm_to_blib
|
|
@ -0,0 +1,22 @@
|
|||
use 5.000;
|
||||
use ExtUtils::MakeMaker;
|
||||
|
||||
my %ARGV = map { my @r = split /=/,$_; defined $r[1] or $r[1]=1; @r } @ARGV;
|
||||
my @exe_files = qw(tentacle_server);
|
||||
|
||||
WriteMakefile(
|
||||
INSTALLSITELIB => '/usr/lib/perl5',
|
||||
(($^O eq 'freebsd')
|
||||
? (INSTALLSITELIB => '') : ()
|
||||
),
|
||||
($^O eq 'netbsd') ? (
|
||||
INSTALLSITELIB => '',
|
||||
INSTALLSITESCRIPT => '/usr/local/bin',
|
||||
) :(),
|
||||
|
||||
NAME => 'PandoraFMS',
|
||||
AUTHOR => 'Artica ST <info@artica.es>',
|
||||
EXE_FILES => [ @exe_files ],
|
||||
PMLIBDIRS => [ 'lib' ],
|
||||
'dist' => { 'TAR' => 'tar', 'TARFLAGS' => 'cvfz', 'SUFFIX' => '.gz', 'COMPRESS' => 'gzip'}
|
||||
);
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
CODEHOME=$HOME/code/pandorafms
|
||||
|
||||
# Add build string for nightly builds
|
||||
if [ "$1" == "nightly" ]; then
|
||||
LOCAL_VERSION="$VERSION-$BUILD"
|
||||
else
|
||||
LOCAL_VERSION=$1
|
||||
fi
|
||||
|
||||
if [ ! -d $CODEHOME/tentacle/dist ]; then
|
||||
mkdir -p $CODEHOME/tentacle/dist || exit 1
|
||||
fi
|
||||
|
||||
echo "Creating source tarballs in $(pwd)/dist"
|
||||
|
||||
# Server
|
||||
cd $CODEHOME && tar zcvf $CODEHOME/tentacle/dist/tentacle_server-$LOCAL_VERSION.tar.gz \
|
||||
--exclude \.svn \
|
||||
--exclude \.exe \
|
||||
--exclude dist \
|
||||
--exclude build_tentacle_server.sh \
|
||||
tentacle || exit 1
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,75 @@
|
|||
##########################################################################
|
||||
# Tentacle Server Parameters
|
||||
# See https://pandorafms.com/manual/en/documentation/08_technical_reference/09_tentacle
|
||||
# for protocol description.
|
||||
# Tentacle have IANA assigned port tpc/41121 as official port.
|
||||
##########################################################################
|
||||
|
||||
# [-a] IPv4 address to listen on. Several IPs cam be selected separating if by comma.
|
||||
addresses 0.0.0.0
|
||||
|
||||
# [-p] Port to listen on
|
||||
port 41121
|
||||
|
||||
# [-c] Maximum number of simultaneous connections
|
||||
# max_connections 10
|
||||
|
||||
# [-d] Run as daemon. 1 true, 0 false
|
||||
daemon 1
|
||||
|
||||
# [-i] Enable insecure mode
|
||||
# insecure 0
|
||||
|
||||
# Filters (regexp:dir;regexp:dir...)
|
||||
filters .*\.conf:conf;.*\.md5:md5;.*\.zip:collections;.*\.lock:trans;.*\.rcmd:commands
|
||||
|
||||
# [-m] Maximum file size allowed by the server in bytes
|
||||
#max_size 2000000
|
||||
|
||||
# [-o] Accept files with a repeated name
|
||||
# overwrite 0
|
||||
|
||||
# [-q] Do not output error messages.
|
||||
# quiet 0
|
||||
|
||||
# [-r] Number of retries for socket read/write operations
|
||||
# retries 3
|
||||
|
||||
# [-s] Storage directory
|
||||
directory /var/spool/pandora/data_in
|
||||
|
||||
# [-b] Address to proxy client requests to
|
||||
# proxy_ip 127.0.0.1
|
||||
|
||||
# [-g] Port to proxy client requests to
|
||||
# proxy_port 41121
|
||||
|
||||
# [-t] Timeout for socket read/write operations in seconds
|
||||
# timeout 1
|
||||
|
||||
# [-v and -V] Verbose level
|
||||
# 0: Do not display any informative messages
|
||||
# 1: Display only important messages [-v]
|
||||
# 2: Display all messages [-V]
|
||||
# verbose 0
|
||||
|
||||
# [-l] Log file
|
||||
log_file /dev/null
|
||||
|
||||
# [-x] Server password
|
||||
# password PASSWORD
|
||||
|
||||
# [-e] SSL certificate file full path
|
||||
# ssl_cert /path/to/ssl/cert
|
||||
|
||||
# [-f] SSL CA file full path
|
||||
# ssl_ca /path/to/ssl/ca
|
||||
|
||||
# [-k] SSL private key file
|
||||
# ssl_key /path/to/private/key/file
|
||||
|
||||
# [-w] SSL password. Set to 1 to ask for password by command line
|
||||
# ssl_password 0
|
||||
|
||||
# [-T] Use libwrap library (Authen::Libwrap perl module)
|
||||
# use_libwrap 0
|
Binary file not shown.
|
@ -0,0 +1,404 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Tentacle Server Installer
|
||||
# Linux/FreeBSD Version (generic), for SuSe, Debian/Ubuntu and FreeBSD only
|
||||
# other Linux distros could not work properly without modifications
|
||||
# Please see http://www.pandorafms.org
|
||||
# v1.0 Build 13062022
|
||||
# This code is licensed under GPL 2.0 license.
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.762"
|
||||
PI_BUILD="220613"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
shift
|
||||
fi
|
||||
|
||||
# Defaults
|
||||
PREFIX=/usr
|
||||
PANDORA_SPOOL=/var/spool/pandora
|
||||
TENTACLE_SERVER=/etc/init.d/tentacle_serverd
|
||||
TENTACLE_CFG_DIR=/etc/tentacle
|
||||
TENTACLE_CFG_FILE=$TENTACLE_CFG_DIR/tentacle_server.conf
|
||||
TENTACLE_CFG_FILE_DIST=conf/tentacle_server.conf.new
|
||||
TENTACLE_INIT_SCRIPT=util/tentacle_serverd
|
||||
PERL=perl
|
||||
MANDIR=$PREFIX/share/man/man1
|
||||
INITDIR=/etc/init.d
|
||||
WITHOUT_TENTACLE=0
|
||||
|
||||
#
|
||||
# set_global_vars
|
||||
# Check platform and set DISTRO, OS_VERSION and LINUX.
|
||||
# Also, define some platform sepcific variables (e.g. PANDORA_RC_VAR for (Free|Net)BSD)
|
||||
# and override some of defaults defined above if needed.
|
||||
#
|
||||
set_global_vars () {
|
||||
# Default
|
||||
LINUX=NO
|
||||
OS_VERSION=`uname -r`
|
||||
DISTRO=`uname -s`
|
||||
|
||||
# set correct value for LINUX_DISTRO
|
||||
case $DISTRO in
|
||||
Linux)
|
||||
# Default for Linux
|
||||
LINUX=YES
|
||||
DISTRO="GENERIC"
|
||||
# Get Linux Distro type and version
|
||||
# We assume we are on Linux unless told otherwise
|
||||
if [ -f "/etc/SuSE-release" ]
|
||||
then
|
||||
OS_VERSION=`cat /etc/SuSE-release | grep VERSION | cut -f 3 -d " "`
|
||||
DISTRO=SUSE
|
||||
elif [ -f "/etc/lsb-release" ] && [ ! -f "/etc/redhat-release" ]
|
||||
then
|
||||
OS_VERSION=`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -f 2 -d "="`
|
||||
DISTRO=UBUNTU
|
||||
OS_VERSION="UBUNTU $OS_VERSION"
|
||||
elif [ -f "/etc/debian_version" ]
|
||||
then
|
||||
OS_VERSION=`cat /etc/debian_version`
|
||||
OS_VERSION="DEBIAN $OS_VERSION"
|
||||
DISTRO=DEBIAN
|
||||
elif [ -f "/etc/fedora-release" ]
|
||||
then
|
||||
OS_VERSION=`cat /etc/fedora-release | cut -f 4 -d " "`
|
||||
OS_VERSION="FEDORA $OS_VERSION"
|
||||
DISTRO=FEDORA
|
||||
fi
|
||||
;;
|
||||
Darwin|AIX)
|
||||
# For future reference, Darwin doesn't have /etc/init.d but uses LaunchDaemons.
|
||||
# AIX doesn't have /etc/init.d
|
||||
;;
|
||||
SunOS)
|
||||
# Some Solaris and other Unices don't have /etc/init.d, some have /usr/spool instead of /var/spool
|
||||
DISTRO="Solaris"
|
||||
;;
|
||||
FreeBSD)
|
||||
PREFIX=/usr/local
|
||||
TENTACLE_SERVER=$PREFIX/etc/rc.d/tentacle_server
|
||||
TENTACLE_CFG_DIR=$PREFIX/etc/tentacle
|
||||
TENTACLE_CFG_FILE=$TENTACLE_CFG_DIR/tentacle_server.conf
|
||||
TENTACLE_INIT_SCRIPT=$DISTRO/tentacle_server
|
||||
MANDIR=$PREFIX/man/man1
|
||||
INITDIR=$PREFIX/etc/rc.d
|
||||
PERL=/usr/local/bin/perl
|
||||
TENTACLE_RC_VAR="tentacle_server_enable"
|
||||
;;
|
||||
NetBSD)
|
||||
PREFIX=/usr/local
|
||||
TENTACLE_CFG_DIR=$PREFIX/etc/tentacle
|
||||
TENTACLE_CFG_FILE=$TENTACLE_CFG_DIR/tentacle_server.conf
|
||||
TENTACLE_SERVER=/etc/rc.d/tentacle_server
|
||||
TENTACLE_INIT_SCRIPT=$DISTRO/tentacle_server
|
||||
PERL=/usr/pkg/bin/perl
|
||||
INITDIR=/etc/rc.d
|
||||
PANDORA_RC_VAR="pandora_server"
|
||||
TENTACLE_RC_VAR="tentacle_server"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#
|
||||
# install_startup_script [options...] SRC
|
||||
# copy SRC into the $INITDIR and do additional required operation according to $DISTRO
|
||||
# if $INITDIR is not set or empty, do nothing.
|
||||
# If $DESTDIR is set, skip enabling service
|
||||
# OPTIONS:
|
||||
# -s SPRIO specify startup priority for service
|
||||
#
|
||||
install_startup_script () {
|
||||
[ "$INITDIR" ] || return 1
|
||||
if [ "$1" = "-s" ]
|
||||
then
|
||||
SPRIO=$2
|
||||
shift;shift
|
||||
fi
|
||||
SRC=$1
|
||||
SCRIPT_NAME=`basename $SRC`
|
||||
|
||||
echo "Copying the daemon script into $DESTDIR$INITDIR"
|
||||
[ -d $DESTDIR$INITDIR ] || mkdir -p $DESTDIR$INITDIR
|
||||
cp $SRC $DESTDIR$INITDIR
|
||||
|
||||
[ "$DESTDIR" ] && return
|
||||
|
||||
case $DISTRO in
|
||||
UBUNTU|DEBIAN)
|
||||
echo "Linking startup script to /etc/rc2.d"
|
||||
update-rc.d $SCRIPT_NAME defaults
|
||||
;;
|
||||
SUSE)
|
||||
echo "Creating startup daemons"
|
||||
insserv $SCRIPT_NAME
|
||||
;;
|
||||
FeeBSD|NetBSD)
|
||||
chmod 555 $DESTDIR$INITDIR/$SCRIPT_NAME
|
||||
;;
|
||||
*)
|
||||
if [ "$LINUX" = YES ]
|
||||
then
|
||||
# Pandora FMS Server install (Other Distros)
|
||||
INITLV=`grep '[0-9]:initdefault' /etc/inittab | cut -f 2 -d ':'`
|
||||
: ${INITLV:=2}
|
||||
echo "Linking startup script to /etc/rc.d/rc$INITLV.d/S$SPRIO$SCRIPT_NAME"
|
||||
ln -s $INITDIR/$SCRIPT_NAME /etc/rc.d/rc$INITLV.d/S$SPRIO$SCRIPT_NAME
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
install () {
|
||||
set_global_vars
|
||||
|
||||
FORCE=0
|
||||
|
||||
# parse options
|
||||
while :
|
||||
do
|
||||
case $1 in
|
||||
--force) FORCE=1;;
|
||||
--destdir) DESTDIR=$2;shift;;
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "$LINUX" = YES ]
|
||||
then
|
||||
echo "$DISTRO distribution detected"
|
||||
else
|
||||
echo "$DISTRO detected"
|
||||
fi
|
||||
|
||||
$PERL -v &> /dev/null
|
||||
if [ $? != 0 ]; then
|
||||
echo ' '
|
||||
echo 'Error, no PERL Interpeter found, please install perl on your system'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Check dependenciaes.
|
||||
if [ $FORCE -eq 0 ]; then
|
||||
# Execute tools check
|
||||
execute_cmd "ps --version" 'Checking dependencies: ps' "Error ps not found, please install procps"
|
||||
execute_cmd "sudo --version" 'Checking dependencies: sudo' "Error sudo not found, please install sudo"
|
||||
execute_cmd "perl -MIO::Compress::Zip -le 'pass'" 'Checking dependencies: perl IO::Compress' "Error perl IO::Compress not found, please install perl IO::Compress"
|
||||
fi
|
||||
|
||||
# install tentacle
|
||||
[ -d $DESTDIR$PREFIX/bin/ ] || mkdir -p $DESTDIR$PREFIX/bin/
|
||||
echo ">Installing the tentacle_server binary to $DESTDIR$PREFIX/bin/..."
|
||||
cp -f tentacle_server "$DESTDIR$PREFIX/bin/"
|
||||
|
||||
echo ">Installing the tentacle_client binary to $DESTDIR$PREFIX/bin/..."
|
||||
cp -f tentacle_client "$DESTDIR$PREFIX/bin/"
|
||||
|
||||
echo "Creating common Pandora FMS directories"
|
||||
id pandora 2> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo " "
|
||||
echo "User pandora does exist, make sure the SSH directories are correct"
|
||||
else
|
||||
echo "Are you sure we can create a standard 'pandora' user locally? [y/N]"
|
||||
read AREYOUSURE
|
||||
if [ "$AREYOUSURE" = "y" ]; then
|
||||
if [ "$DISTRO" = "FreeBSD" ]
|
||||
then
|
||||
echo "pandora:41121:::::Pandora FMS:/home/pandora:/usr/sbin/nologin:" | adduser -f - -w no 2> /dev/null
|
||||
else
|
||||
useradd pandora
|
||||
mkdir /home/pandora 2> /dev/null
|
||||
mkdir /home/pandora/.ssh 2> /dev/null
|
||||
chown -R pandora /home/pandora
|
||||
fi
|
||||
else
|
||||
echo "Please create the 'pandora' user manually according to your authentication scheme, then start again the installation"
|
||||
echo "Aborting..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p $DESTDIR$PANDORA_SPOOL/data_in 2> /dev/null
|
||||
chmod 2770 $DESTDIR$PANDORA_SPOOL/data_in
|
||||
mkdir $DESTDIR$PANDORA_SPOOL/data_in/conf 2> /dev/null
|
||||
chmod 2770 $DESTDIR$PANDORA_SPOOL/data_in/conf
|
||||
mkdir $DESTDIR$PANDORA_SPOOL/data_in/md5 2> /dev/null
|
||||
chmod 2770 $DESTDIR$PANDORA_SPOOL/data_in/md5
|
||||
mkdir $DESTDIR$PANDORA_SPOOL/data_in/collections 2> /dev/null
|
||||
chmod 2770 $DESTDIR$PANDORA_SPOOL/data_in/collections
|
||||
mkdir $DESTDIR$PANDORA_SPOOL/data_in/netflow 2> /dev/null
|
||||
chmod 2770 $DESTDIR$PANDORA_SPOOL/data_in/netflow
|
||||
mkdir $DESTDIR$PANDORA_SPOOL/data_in/trans 2> /dev/null
|
||||
chmod 2770 $DESTDIR$PANDORA_SPOOL/data_in/trans
|
||||
mkdir $DESTDIR$PANDORA_SPOOL/data_in/commands 2> /dev/null
|
||||
chmod 2770 $DESTDIR$PANDORA_SPOOL/data_in/commands
|
||||
|
||||
|
||||
echo "Giving proper permission to $DESTDIR$PANDORA_SPOOL/"
|
||||
for group in "www-data" wwwrun www apache
|
||||
do
|
||||
IDGROUP=`id -g "$group" 2> /dev/null`
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
GROUPNAME=`grep ":$IDGROUP:" /etc/group | awk -F":" '{print $1}'`
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$GROUPNAME" ]
|
||||
then
|
||||
echo "No web server user found, some functionality might not perform correctly"
|
||||
GROUPNAME=0
|
||||
fi
|
||||
# when fakeroot installation, this can fail
|
||||
chown -R pandora:$GROUPNAME $DESTDIR$PANDORA_SPOOL 2>/dev/null
|
||||
|
||||
chown apache:$GROUPNAME $DESTDIR$PANDORA_SPOOL/data_in/customer_key 2>/dev/null
|
||||
|
||||
# install tentacle_server
|
||||
install_startup_script -s 80 $TENTACLE_INIT_SCRIPT
|
||||
|
||||
# Create the directory to locate the Tentacle configuration file
|
||||
echo "Creating setup Tentacle directory in $DESTDIR$TENTACLE_CFG_DIR"
|
||||
mkdir -p $DESTDIR$TENTACLE_CFG_DIR 2> /dev/null
|
||||
if [ -f "$DESTDIR$TENTACLE_CFG_FILE" ]
|
||||
then
|
||||
echo cp $TENTACLE_CFG_FILE_DIST $DESTDIR$TENTACLE_CFG_DIR
|
||||
cp $TENTACLE_CFG_FILE_DIST $DESTDIR$TENTACLE_CFG_DIR
|
||||
else
|
||||
echo cp $TENTACLE_CFG_FILE_DIST $DESTDIR$TENTACLE_CFG_FILE
|
||||
cp $TENTACLE_CFG_FILE_DIST $DESTDIR$TENTACLE_CFG_FILE
|
||||
chmod 774 $DESTDIR$TENTACLE_CFG_FILE
|
||||
fi
|
||||
|
||||
echo "Installing Tentacle Server manual"
|
||||
[ -d $DESTDIR$MANDIR ] || mkdir -p $DESTDIR$MANDIR
|
||||
cp man/man1/tentacle_server.1.gz $DESTDIR$MANDIR
|
||||
|
||||
# Fix util paths
|
||||
sed -i -e "s|directory.*|directory $DESTDIR$PANDORA_SPOOL/data_in|g" $DESTDIR$TENTACLE_CFG_FILE
|
||||
sed -i -e "s|TENTACLE_PATH=\"/usr/bin\"|TENTACLE_PATH=$DESTDIR$PREFIX/bin|g" $DESTDIR$TENTACLE_SERVER
|
||||
sed -i -e "s|^TENTACLE_CONFIG_FILE=.*|TENTACLE_CONFIG_FILE=$DESTDIR$TENTACLE_CFG_FILE|g" $DESTDIR$TENTACLE_SERVER
|
||||
|
||||
echo "Tentacle Server installed"
|
||||
|
||||
|
||||
}
|
||||
|
||||
uninstall () {
|
||||
set_global_vars
|
||||
|
||||
# parse options
|
||||
while :
|
||||
do
|
||||
case $1 in
|
||||
--destdir) DESTDIR=$2;shift;;
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "$LINUX" != "YES" ] && [ "$DISTRO" != "FreeBSD" ] && [ "$DISTRO" != "NetBSD" ]
|
||||
then
|
||||
echo "This is not a Linux-based distro. Uninstaller is currently not working for your OS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
echo "Removing Tentacle Server"
|
||||
if [ -d $DESTDIR$PANDORA_SPOOL/data_out ]; then
|
||||
rm -Rf $DESTDIR$PANDORA_SPOOL/data_in
|
||||
else
|
||||
rm -Rf $DESTDIR$PANDORA_SPOOL
|
||||
fi
|
||||
|
||||
echo "If the user Pandora is not being used for any other operations, please delete using the following commands:"
|
||||
if [ "$DISTRO" != "FreeBSD" ] || [ "$DISTRO" != "NetBSD" ]
|
||||
then
|
||||
echo " rmuser pandora"
|
||||
else
|
||||
echo " userdel pandora"
|
||||
echo " rm -Rf /home/pandora/"
|
||||
fi
|
||||
|
||||
## Just to clarify here. Some people (like me) are using the pandora user
|
||||
## for other purposes and/or using an LDAP-based user management
|
||||
## I would hate to have a script clear out this users' information without any notification
|
||||
|
||||
|
||||
rm -f $DESTDIR$TENTACLE_CFG_FILE 2> /dev/null
|
||||
rm -f "$DESTDIR$TENTACLE_CFG_FILE.new" 2> /dev/null
|
||||
# Do not remove tentacle files if agent is still installed...
|
||||
[ -e $DESTDIR$PREFIX/bin/pandora_agent ] || rm -f $DESTDIR$PREFIX/bin/tentacle_server 2> /dev/null
|
||||
[ -e $DESTDIR$PREFIX/bin/pandora_agent ] || rm -f $DESTDIR$PREFIX/bin/tentacle_client 2> /dev/null
|
||||
if [ "$DESTDIR" ]
|
||||
then
|
||||
rm -f $DESTDIR$TENTACLE_SERVER
|
||||
elif [ "$DISTRO" = "UBUNTU" ] || [ "$DISTRO" = "DEBIAN" ]
|
||||
then
|
||||
update-rc.d -f tentacle_serverd remove
|
||||
fi
|
||||
|
||||
rm -f $DESTDIR/etc/rc2.d/S80tentacle_serverd 2> /dev/null
|
||||
rm -f $DESTDIR/etc/rc.d/rc3.d/S80tentacle_serverd 2> /dev/null
|
||||
|
||||
echo "Done"
|
||||
echo $DESTDIR$TENTACLE_SERVER
|
||||
}
|
||||
|
||||
help () {
|
||||
echo " --install To install Pandora FMS Servers on this system (You have to be root)"
|
||||
echo " --uninstall To uninstall and remove Pandora FMS Servers on this System"
|
||||
echo " "
|
||||
echo " Additional second parameter (after --install) "
|
||||
echo " "
|
||||
echo " --force Ignore dependency problems and do the install"
|
||||
echo " --destdir DIR Specify root directory for \"fakeroot\" installation"
|
||||
echo " "
|
||||
}
|
||||
|
||||
execute_cmd () {
|
||||
cmd="$1"
|
||||
msg="$2"
|
||||
|
||||
echo "$msg"
|
||||
$cmd &>> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Fail"
|
||||
[ "$3" ] && echo "$3"
|
||||
echo "Error installing Tentacle server"
|
||||
exit 1
|
||||
else
|
||||
echo "Ok"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
##Main
|
||||
|
||||
# Script banner at start
|
||||
echo " "
|
||||
echo "Tentacle Server Installer $PI_VERSION $PI_BUILD (c) 2008-2022 Artica ST"
|
||||
echo "This program is licensed under GPL2 Terms. http://pandorafms.com"
|
||||
echo " "
|
||||
|
||||
case "$MODE" in
|
||||
|
||||
'--install')
|
||||
install "$@"
|
||||
exit 0
|
||||
;;
|
||||
|
||||
'--uninstall')
|
||||
uninstall "$@"
|
||||
exit 0
|
||||
;;
|
||||
|
||||
*)
|
||||
help
|
||||
esac
|
||||
|
|
@ -0,0 +1,185 @@
|
|||
#!/bin/bash
|
||||
# Copyright (c) 2005-2010 Artica ST
|
||||
#
|
||||
# Author: Sancho Lerena <slerena@artica.es> 2006-2010
|
||||
#
|
||||
# /etc/init.d/tentacle_server
|
||||
#
|
||||
# System startup script for Tentacle Server
|
||||
#
|
||||
# Comments to support chkconfig on RedHat Linux
|
||||
# chkconfig: 2345 90 90
|
||||
# description: Tentacle Server startup script
|
||||
#
|
||||
# Comments to support LSB init script conventions
|
||||
### BEGIN INIT INFO
|
||||
# Provides: tentacle_server
|
||||
# Required-Start: $network
|
||||
# Should-Start: $syslog
|
||||
# Required-Stop: $network
|
||||
# Should-Stop: $network
|
||||
# Default-Start: 2 3 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Tentacle Server startup script
|
||||
# Description: Tentacle Server startup script
|
||||
### END INIT INFO
|
||||
|
||||
if [ -x /lib/lsb/init-functions ]; then
|
||||
. /lib/lsb/init-functions
|
||||
fi
|
||||
|
||||
# Uses a wait limit before sending a KILL signal, before trying to stop
|
||||
# Pandora FMS server nicely. Some big systems need some time before close
|
||||
# all pending tasks / threads.
|
||||
|
||||
export MAXWAIT=60
|
||||
|
||||
# Check for SUSE status scripts
|
||||
if [ -f /etc/rc.status ]
|
||||
then
|
||||
. /etc/rc.status
|
||||
rc_reset
|
||||
else
|
||||
# Define part of rc functions for non-suse systems
|
||||
function rc_status () {
|
||||
RETVAL=$?
|
||||
case $1 in
|
||||
-v) RETVAL=0;;
|
||||
esac
|
||||
}
|
||||
function rc_exit () { exit $RETVAL; }
|
||||
function rc_failed () { RETVAL=${1:-1}; }
|
||||
RETVAL=0
|
||||
fi
|
||||
|
||||
function get_pid {
|
||||
# This sets COLUMNS to XXX chars, because if command is run
|
||||
# in a "strech" term, ps aux don't report more than COLUMNS
|
||||
# characters and this will not work.
|
||||
COLUMNS=300
|
||||
TENTACLE_PID=`ps -Af | grep "$TENTACLE_PATH$TENTACLE_DAEMON" | grep "$TENTACLE_CONFIG_FILE" | grep -v grep | tail -1 | awk '{ print $2 }'`
|
||||
echo $TENTACLE_PID
|
||||
}
|
||||
|
||||
function get_all_pid {
|
||||
# This sets COLUMNS to XXX chars, because if command is run
|
||||
# in a "strech" term, ps aux don't report more than COLUMNS
|
||||
# characters and this will not work.
|
||||
COLUMNS=300
|
||||
TENTACLE_PIDS=`ps aux | grep "$TENTACLE_PATH$TENTACLE_DAEMON" | grep -v grep | awk '{ print $2 }'`
|
||||
TENTACLE_PID="${TENTACLE_PIDS//\\n/' '}"
|
||||
echo $TENTACLE_PID
|
||||
}
|
||||
|
||||
# Tentacle server settings
|
||||
TENTACLE_DAEMON="tentacle_server"
|
||||
TENTACLE_PATH="/usr/bin"
|
||||
TENTACLE_USER="pandora"
|
||||
TENTACLE_CONFIG_FILE="/etc/tentacle/tentacle_server.conf"
|
||||
TENTACLE_EXT_OPTS=""
|
||||
|
||||
# Set umask to 0002, because group MUST have access to write files to
|
||||
# use remote file management on Pandora FMS Enterprise.
|
||||
|
||||
umask 0007
|
||||
|
||||
# Main script
|
||||
TENTACLE_OPTS="-F $TENTACLE_CONFIG_FILE $TENTACLE_EXT_OPTS"
|
||||
|
||||
# Fix TENTACLE_PATH
|
||||
case "$TENTACLE_PATH" in
|
||||
*\/)
|
||||
;;
|
||||
*)
|
||||
TENTACLE_PATH="${TENTACLE_PATH}/"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -f "${TENTACLE_PATH}$TENTACLE_DAEMON" ]; then
|
||||
echo "Tentacle Server not found in ${TENTACLE_PATH}$TENTACLE_DAEMON"
|
||||
rc_failed 5 # program is not installed
|
||||
rc_exit
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
TENTACLE_PID=`get_pid`
|
||||
if [ ! -z "$TENTACLE_PID" ]; then
|
||||
echo "Tentacle Server is already running with PID $TENTACLE_PID"
|
||||
rc_exit # running start on a service already running
|
||||
fi
|
||||
|
||||
# Init the tentacle process
|
||||
sudo -u $TENTACLE_USER ${TENTACLE_PATH}$TENTACLE_DAEMON $TENTACLE_OPTS
|
||||
sleep 1
|
||||
|
||||
TENTACLE_PID=`get_pid`
|
||||
if [ ! -z "$TENTACLE_PID" ]; then
|
||||
echo "Tentacle Server is now running with PID $TENTACLE_PID"
|
||||
rc_status -v
|
||||
else
|
||||
echo "Tentacle Server could not be started."
|
||||
echo "Verify that Tentacle port is not used."
|
||||
rc_failed 7 # program not running
|
||||
fi
|
||||
|
||||
;;
|
||||
|
||||
stop)
|
||||
TENTACLE_PID=`get_all_pid`
|
||||
if [ -z "$TENTACLE_PID" ]; then
|
||||
echo "Tentacle Server does not seem to be running"
|
||||
rc_exit # running stop on a service already stopped or not running
|
||||
else
|
||||
kill $TENTACLE_PID
|
||||
|
||||
COUNTER=0
|
||||
while [ $COUNTER -lt $MAXWAIT ]
|
||||
do
|
||||
_PID=`get_all_pid`
|
||||
if [ "$_PID" != "$TENTACLE_PID" ]
|
||||
# tentacle already stopped
|
||||
then
|
||||
COUNTER=$MAXWAIT
|
||||
fi
|
||||
COUNTER=`expr $COUNTER + 1`
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ "$_PID" = "$TENTACLE_PID" ]
|
||||
then
|
||||
kill -9 $TENTACLE_PID > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
echo "Stopping Tentacle Server"
|
||||
rc_status -v
|
||||
fi
|
||||
|
||||
;;
|
||||
|
||||
force-reload|restart)
|
||||
$0 stop
|
||||
sleep 1
|
||||
$0 start
|
||||
rc_status
|
||||
;;
|
||||
|
||||
status)
|
||||
TENTACLE_PID=`get_pid`
|
||||
if [ -z "$TENTACLE_PID" ]; then
|
||||
echo "Tentacle Server is not running."
|
||||
rc_failed 7 # program is not running
|
||||
else
|
||||
echo "Tentacle Server is running with PID $TENTACLE_PID."
|
||||
rc_status
|
||||
fi
|
||||
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start | stop | restart | status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
rc_exit
|
|
@ -0,0 +1,14 @@
|
|||
[Unit]
|
||||
Description=Tentacle server daemon
|
||||
After=network-online.target
|
||||
Requires=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart=/usr/bin/tentacle_server -F /etc/tentacle/tentacle_server.conf
|
||||
User=pandora
|
||||
Restart=on-failure
|
||||
RestartPreventExitStatus=1
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in New Issue