2012-04-20 Ramon Novoa <rnovoa@artica.es>
* pandora_agent_installer: Backup and restore conf file and daemon launcher. Moved the code that sets PANDORA_USER back to its original place and set the variable properly instead. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6071 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
1e25daff32
commit
724a989d7f
|
@ -1,3 +1,9 @@
|
|||
2012-04-20 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* pandora_agent_installer: Backup and restore conf file and daemon
|
||||
launcher. Moved the code that sets PANDORA_USER back to its original
|
||||
place and set the variable properly instead.
|
||||
|
||||
2012-04-19 Koichiro Kikuchi <koichiro@rworks.jp>
|
||||
|
||||
* pandora_agent: Also added the temporal directory to the file path
|
||||
|
|
|
@ -28,7 +28,12 @@ PANDORA_MAN=/usr/share/man
|
|||
|
||||
MODE=$1
|
||||
PANDORA_BASE=`echo $2 | sed -e 's/\/$//'`
|
||||
PANDORA_USER=$3
|
||||
if [ "$3" != "" ]
|
||||
then
|
||||
PANDORA_USER=$3
|
||||
else
|
||||
PANDORA_USER="root"
|
||||
fi
|
||||
|
||||
# Check for Perl 5.6.x or higher available
|
||||
PERL_VERSION=`perl -v | egrep 'v5.6|v5.7|v5.8|v5.9|v5.1[0-9]' | grep perl`
|
||||
|
@ -156,6 +161,7 @@ install () {
|
|||
OS_VERSION=`uname -r`
|
||||
OS_NAME=`uname -s`
|
||||
OLDFILENAMETMP=`date +"%Y-%m-%d"`
|
||||
PANDORA_CFG_BAK="/tmp/pandora_agent.conf.bak"
|
||||
|
||||
if [ "$OS_NAME" = "FreeBSD" ]
|
||||
then
|
||||
|
@ -188,17 +194,6 @@ install () {
|
|||
echo "Checking Pandora FMS Agent on $PANDORA_BASE$PANDORA_BIN...."
|
||||
fi
|
||||
|
||||
# Set the user the agent will run as
|
||||
if [ "$PANDORA_USER" != "" ]
|
||||
then
|
||||
sed -e "s/.*pandora_user .*/pandora_user $PANDORA_USER/" $AGENT_CFG > $AGENT_CFG_TEMP 2> /dev/null && \
|
||||
mv $AGENT_CFG_TEMP $AGENT_CFG
|
||||
chmod 755 pandora_agent_daemon
|
||||
chown -R $PANDORA_USER $PANDORA_BASE
|
||||
else
|
||||
PANDORA_USER="root"
|
||||
fi
|
||||
|
||||
# Alter dynamically the daemon launcher and setup the new path
|
||||
# if PANDORA_BASE is customized.
|
||||
|
||||
|
@ -213,9 +208,15 @@ install () {
|
|||
DAEMON_TEMP=pandora_agent_daemon_temp
|
||||
fi
|
||||
|
||||
# Backup the daemon script
|
||||
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"
|
||||
|
||||
echo $PANDORA_BASE > PANDORA_BASE.temp
|
||||
sed 's/\//\\\//g' PANDORA_BASE.temp > PANDORA_BASE.temp2
|
||||
|
||||
|
@ -281,6 +282,15 @@ install () {
|
|||
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
|
||||
chmod 755 pandora_agent_daemon
|
||||
chown -R $PANDORA_USER $PANDORA_BASE
|
||||
fi
|
||||
|
||||
# Create logfile
|
||||
if [ ! -z "`touch $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG`" ]
|
||||
then
|
||||
|
@ -433,6 +443,14 @@ install () {
|
|||
echo "to start automatically when system restarts":
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
||||
}
|
||||
|
||||
if [ ! -f "pandora_agent" ]
|
||||
|
|
Loading…
Reference in New Issue