2008-03-25 17:39:21 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2009-08-12 17:01:55 +02:00
|
|
|
# Tentacle server simple startup script
|
2009-06-08 17:12:32 +02:00
|
|
|
# Copyright (c) 2007 Artica Soluciones Tecnologicas S.L.
|
2008-03-25 17:39:21 +01:00
|
|
|
# Linux Version (generic)
|
2009-08-27 19:47:50 +02:00
|
|
|
# v0.1 Build 090827
|
2008-03-25 17:39:21 +01:00
|
|
|
|
2009-08-12 17:01:55 +02:00
|
|
|
### BEGIN INIT INTO
|
|
|
|
# Provides: tentacle_server
|
|
|
|
# Default-Start: 2 3 5
|
|
|
|
# Default-Stop: 0 1 2 3 5
|
|
|
|
# Required-Start: $network
|
|
|
|
# Required-Stop: $network
|
2009-08-19 03:41:25 +02:00
|
|
|
# Short-Description: Tentacle Server startup script
|
2009-08-12 17:01:55 +02:00
|
|
|
### END INIT INFO
|
2008-03-25 17:39:21 +01:00
|
|
|
|
|
|
|
# Pandora server settings
|
|
|
|
PANDORA_SERVER_PATH="/var/spool/pandora/data_in"
|
|
|
|
|
|
|
|
# Tentacle server settings
|
|
|
|
TENTACLE_DAEMON="tentacle_server"
|
|
|
|
TENTACLE_PATH="/usr/local/bin"
|
|
|
|
TENTACLE_USER="pandora"
|
|
|
|
|
2008-04-01 12:01:29 +02:00
|
|
|
TENTACLE_ADDR="0.0.0.0"
|
|
|
|
TENTACLE_PORT="41121"
|
2009-08-27 19:47:50 +02:00
|
|
|
TENTACLE_EXT_OPTS="-i.*\.conf:conf;.*\.md5:md5"
|
2008-03-25 17:39:21 +01:00
|
|
|
|
2009-08-15 05:00:21 +02:00
|
|
|
# Set umask to 0002, because group MUST have access to write files to
|
|
|
|
# use remote file management on Pandora FMS Enterprise.
|
|
|
|
|
|
|
|
umask 0007
|
|
|
|
|
2008-03-25 17:39:21 +01:00
|
|
|
# Sets the shell variable TENTACLE_PID to the PID of the Tentacle server (empty
|
|
|
|
# if not running). Can be a list of PIDs if multiple instances are running.
|
2009-08-11 18:26:09 +02:00
|
|
|
|
2008-03-25 17:39:21 +01:00
|
|
|
function get_pid {
|
2009-08-11 18:26:09 +02:00
|
|
|
TENTACLE_PID=`ps aux | grep $TENTACLE_PATH$TENTACLE_DAEMON | grep -v grep | tail -1 | awk '{ print $2 }'`
|
|
|
|
echo $TENTACLE_PID
|
2008-03-25 17:39:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Main script
|
|
|
|
TENTACLE_OPTS="-a $TENTACLE_ADDR -p $TENTACLE_PORT -s $PANDORA_SERVER_PATH $TENTACLE_EXT_OPTS -d"
|
|
|
|
|
|
|
|
# Fix TENTACLE_PATH
|
|
|
|
case "$TENTACLE_PATH" in
|
|
|
|
*\/)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
TENTACLE_PATH="${TENTACLE_PATH}/"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ ! -f "${TENTACLE_PATH}$TENTACLE_DAEMON" ]; then
|
2009-08-11 18:26:09 +02:00
|
|
|
echo "Tentacle server not found in ${TENTACLE_PATH}$TENTACLE_DAEMON."
|
|
|
|
exit 1
|
2008-03-25 17:39:21 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
2009-08-11 18:26:09 +02:00
|
|
|
start)
|
|
|
|
TENTACLE_PID=`get_pid`
|
2008-03-25 17:39:21 +01:00
|
|
|
if [ ! -z "$TENTACLE_PID" ]; then
|
|
|
|
echo "Tentacle server is already running with PID $TENTACLE_PID."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2009-09-04 14:18:42 +02:00
|
|
|
sudo -u $TENTACLE_USER ${TENTACLE_PATH}$TENTACLE_DAEMON $TENTACLE_OPTS
|
2008-03-25 17:39:21 +01:00
|
|
|
sleep 1
|
|
|
|
|
2009-08-11 18:26:09 +02:00
|
|
|
TENTACLE_PID=`get_pid`
|
2008-03-25 17:39:21 +01:00
|
|
|
if [ ! -z "$TENTACLE_PID" ]; then
|
|
|
|
echo "Tentacle server is now running with PID $TENTACLE_PID."
|
|
|
|
else
|
|
|
|
echo "Tentacle server could not be started."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|
2009-08-11 18:26:09 +02:00
|
|
|
;;
|
2008-03-25 17:39:21 +01:00
|
|
|
|
|
|
|
stop)
|
2009-08-11 18:26:09 +02:00
|
|
|
TENTACLE_PID=`get_pid`
|
2008-03-25 17:39:21 +01:00
|
|
|
if [ -z "$TENTACLE_PID" ]; then
|
|
|
|
echo "Tentacle server does not seem to be running."
|
|
|
|
exit 1;
|
|
|
|
else
|
|
|
|
kill $TENTACLE_PID > /dev/null 2>&1
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
get_pid
|
|
|
|
if [ ! -z "$TENTACLE_PID" ]; then
|
|
|
|
echo "Tentacle server could not be stopped."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Tentacle server stopped."
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
force-reload|restart)
|
2009-08-11 18:26:09 +02:00
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
;;
|
2008-03-25 17:39:21 +01:00
|
|
|
|
|
|
|
status)
|
2009-08-11 18:26:09 +02:00
|
|
|
TENTACLE_PID=`get_pid`
|
2008-03-25 17:39:21 +01:00
|
|
|
if [ -z "$TENTACLE_PID" ]; then
|
|
|
|
echo "Tentacle server is not running."
|
|
|
|
else
|
|
|
|
echo "Tentacle server is running with PID $TENTACLE_PID."
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|
2009-08-11 18:26:09 +02:00
|
|
|
;;
|
2008-03-25 17:39:21 +01:00
|
|
|
|
|
|
|
*)
|
2009-08-11 18:26:09 +02:00
|
|
|
echo "Usage: $0 {start | stop | restart | status}"
|
2008-03-25 17:39:21 +01:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|