From 4bc10e503b6306c646d2ae85e0b36cae35e54103 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 30 Apr 2018 15:53:09 +0200 Subject: [PATCH] Modified launch daemon Tentacle script to use configuration file --- pandora_server/conf/tentacle_server.conf.new | 4 +-- pandora_server/util/tentacle_serverd | 26 +++++++++++--------- pandora_server/util/tentacle_serverd.service | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/pandora_server/conf/tentacle_server.conf.new b/pandora_server/conf/tentacle_server.conf.new index 5260a213aa..d4ebe4a71f 100644 --- a/pandora_server/conf/tentacle_server.conf.new +++ b/pandora_server/conf/tentacle_server.conf.new @@ -9,7 +9,7 @@ addresses 0.0.0.0 # [-p] Port to listen on -# port 41121 +port 41121 # [-c] Maximum number of simultaneous connections # max_connections 10 @@ -54,7 +54,7 @@ directory /var/spool/pandora/data_in # verbose 0 # [-l] Log file -# log_file /path/to/log/file +log_file /dev/null # [-x] Server password # password PASSWORD diff --git a/pandora_server/util/tentacle_serverd b/pandora_server/util/tentacle_serverd index fdfe3e0d67..0c3fa7590d 100755 --- a/pandora_server/util/tentacle_serverd +++ b/pandora_server/util/tentacle_serverd @@ -57,7 +57,7 @@ function get_pid { # 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_PORT" | grep -v grep | tail -1 | awk '{ print $2 }'` + TENTACLE_PID=`ps -Af | grep "$TENTACLE_PATH$TENTACLE_DAEMON" | grep "$TENTACLE_CONFIG_FILE" | grep -v grep | tail -1 | awk '{ print $2 }'` echo $TENTACLE_PID } @@ -71,18 +71,12 @@ function get_all_pid { echo $TENTACLE_PID } -# Pandora server settings -PANDORA_SERVER_PATH="/var/spool/pandora/data_in" - # Tentacle server settings TENTACLE_DAEMON="tentacle_server" TENTACLE_PATH="/usr/bin" TENTACLE_USER="pandora" - -TENTACLE_ADDR="0.0.0.0" -TENTACLE_PORT="41121" -TENTACLE_EXT_OPTS="-i.*\.conf:conf;.*\.md5:md5;.*\.zip:collections;.*\.lock:trans" -TENTACLE_LOG_FILE="/dev/null" +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. @@ -90,7 +84,7 @@ TENTACLE_LOG_FILE="/dev/null" umask 0007 # Main script -TENTACLE_OPTS="-a $TENTACLE_ADDR -p $TENTACLE_PORT -s $PANDORA_SERVER_PATH $TENTACLE_EXT_OPTS -d -l $TENTACLE_LOG_FILE -v" +TENTACLE_OPTS="-F $TENTACLE_CONFIG_FILE $TENTACLE_EXT_OPTS" # Fix TENTACLE_PATH case "$TENTACLE_PATH" in @@ -114,7 +108,15 @@ case "$1" in echo "Tentacle Server is already running with PID $TENTACLE_PID" rc_exit # running start on a service already running fi - + + # Try to change the privileges of configuration file + chown $TENTACLE_USER $TENTACLE_CONFIG_FILE > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "Cannot change the owner of $TENTACLE_CONFIG_FILE configuration file to $TENTACLE_USER user." + rc_exit + fi + + # Init the tentacle process sudo -u $TENTACLE_USER ${TENTACLE_PATH}$TENTACLE_DAEMON $TENTACLE_OPTS sleep 1 @@ -124,7 +126,7 @@ case "$1" in rc_status -v else echo "Tentacle Server could not be started." - echo "Verify that port $TENTACLE_PORT is not used." + echo "Verify that Tentacle port is not used." rc_failed 7 # program not running fi diff --git a/pandora_server/util/tentacle_serverd.service b/pandora_server/util/tentacle_serverd.service index 488bc3d4a8..e5c3bfad3e 100644 --- a/pandora_server/util/tentacle_serverd.service +++ b/pandora_server/util/tentacle_serverd.service @@ -4,7 +4,7 @@ After=network-online.target [Service] Type=forking -ExecStart=/usr/bin/tentacle_server -a 0.0.0.0 -p 41121 -s /var/spool/pandora/data_in -i.*\.conf:conf;.*\.md5:md5;.*\.zip:collections -d +ExecStart=/usr/bin/tentacle_server -F /etc/tentacle/tentacle_server.conf User=pandora [Install]