diff --git a/pandora_agents/unix/ChangeLog b/pandora_agents/unix/ChangeLog index 368b816ecd..1ba85c5711 100644 --- a/pandora_agents/unix/ChangeLog +++ b/pandora_agents/unix/ChangeLog @@ -1,3 +1,11 @@ +2011-12-07 KIKUCHI Koichiro + + * pandora_agent_installer: Removed duplicated lines and spaces to + tabs. Also removed lines that set group to wheel (gid of wheel is 0). + * plugins/files_indir: Added support for FreeBSD. + * plugins/pandora_update: Fixed $conf_path for FreeBSD and spaces + to tabs. + 2011-11-15 Ramon Novoa * pandora_agent: Re-wrote broker agent code (was not working properly). diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 2804ea3b12..73b4e11475 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -171,7 +171,7 @@ install () { echo "Detecting Unix distribution: $OS_NAME version $OS_VERSION" if [ -f $PANDORA_BASE$PANDORA_HOME ] && [ "$FORCE" = "0" ] then - echo "Seems that default dir already exists. Please use --force to" + echo "Seems that default dir already exists. Please use --force-install to" echo "force installer to install on $PANDORA_BASE$PANDORA_HOME" exit else @@ -180,7 +180,7 @@ install () { if [ -f $PANDORA_BASE$PANDORA_BIN ] && [ "$FORCE" = "0" ] then - echo "Seems that $PANDORA_BASE$PANDORA_BIN already exists. Please use --force to" + echo "Seems that $PANDORA_BASE$PANDORA_BIN already exists. Please use --force-install to" echo "force installer to reinstall overwriting it" echo " " exit @@ -188,78 +188,78 @@ install () { echo "Checking Pandora FMS Agent on $PANDORA_BASE$PANDORA_BIN...." fi - # Alter dynamically the daemon launcher and setup the new path - # if PANDORA_BASE is customized. + # Alter dynamically the daemon launcher and setup the new path + # if PANDORA_BASE is customized. - if [ ! -z "$PANDORA_BASE" ] - then - if [ "$OS_NAME" = "FreeBSD" ] + if [ ! -z "$PANDORA_BASE" ] then - DAEMON_SCRIPT=FreeBSD/pandora_agent - DAEMON_TEMP=pandora_agent_daemon_temp - else - DAEMON_SCRIPT=pandora_agent_daemon - DAEMON_TEMP=pandora_agent_daemon_temp - fi - - AGENT_CFG=$OS_NAME/pandora_agent.conf - AGENT_CFG_TEMP=$OS_NAME/pandora_agent.conf.temp + if [ "$OS_NAME" = "FreeBSD" ] + then + DAEMON_SCRIPT=FreeBSD/pandora_agent + DAEMON_TEMP=pandora_agent_daemon_temp + else + DAEMON_SCRIPT=pandora_agent_daemon + DAEMON_TEMP=pandora_agent_daemon_temp + fi + + AGENT_CFG=$OS_NAME/pandora_agent.conf + AGENT_CFG_TEMP=$OS_NAME/pandora_agent.conf.temp - echo $PANDORA_BASE > PANDORA_BASE.temp - sed 's/\//\\\//g' PANDORA_BASE.temp > PANDORA_BASE.temp2 + echo $PANDORA_BASE > PANDORA_BASE.temp + sed 's/\//\\\//g' PANDORA_BASE.temp > PANDORA_BASE.temp2 - PANDORA_BASE_DECODED=`cat PANDORA_BASE.temp2` - rm PANDORA_BASE.temp PANDORA_BASE.temp2 + PANDORA_BASE_DECODED=`cat PANDORA_BASE.temp2` + rm PANDORA_BASE.temp PANDORA_BASE.temp2 - if [ "$OS_NAME" = "FreeBSD" ] - then - sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/local\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP - mv $DAEMON_TEMP $DAEMON_SCRIPT + if [ "$OS_NAME" = "FreeBSD" ] + then + sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/local\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP + mv $DAEMON_TEMP $DAEMON_SCRIPT - sed -e "s/^command\=[.]*/command\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP - mv $DAEMON_TEMP $DAEMON_SCRIPT + sed -e "s/^command\=[.]*/command\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP + mv $DAEMON_TEMP $DAEMON_SCRIPT - sed -e 's/^command_args\=\"[.]*/command_args\=\"$PANDORA_BASE_DECODED/g' $DAEMON_SCRIPT > $DAEMON_TEMP - mv $DAEMON_TEMP $DAEMON_SCRIPT + sed -e 's/^command_args\=\"[.]*/command_args\=\"$PANDORA_BASE_DECODED/g' $DAEMON_SCRIPT > $DAEMON_TEMP + mv $DAEMON_TEMP $DAEMON_SCRIPT - sed -e 's/^required_files\=\"[.]*/required_files\=\"$PANDORA_BASE_DECODED/g' $DAEMON_SCRIPT > $DAEMON_TEMP - mv $DAEMON_TEMP $DAEMON_SCRIPT - else - sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP - mv $DAEMON_TEMP $DAEMON_SCRIPT + sed -e 's/^required_files\=\"[.]*/required_files\=\"$PANDORA_BASE_DECODED/g' $DAEMON_SCRIPT > $DAEMON_TEMP + mv $DAEMON_TEMP $DAEMON_SCRIPT + else + sed -e "s/^PATH\=[.]*/PATH\=$PANDORA_BASE_DECODED\/usr\/bin\:/g" $DAEMON_SCRIPT > $DAEMON_TEMP + mv $DAEMON_TEMP $DAEMON_SCRIPT - sed -e "s/^PANDORA_PATH\=[.]*/PANDORA_PATH\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP - mv $DAEMON_TEMP $DAEMON_SCRIPT + sed -e "s/^PANDORA_PATH\=[.]*/PANDORA_PATH\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP + mv $DAEMON_TEMP $DAEMON_SCRIPT - sed -e "s/^LOGFILE\=[.]*/LOGFILE\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP - mv $DAEMON_TEMP $DAEMON_SCRIPT + sed -e "s/^LOGFILE\=[.]*/LOGFILE\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP + mv $DAEMON_TEMP $DAEMON_SCRIPT - sed -e "s/^DAEMON\=[.]*/DAEMON\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP - mv $DAEMON_TEMP $DAEMON_SCRIPT + sed -e "s/^DAEMON\=[.]*/DAEMON\=$PANDORA_BASE_DECODED/g" $DAEMON_SCRIPT > $DAEMON_TEMP + mv $DAEMON_TEMP $DAEMON_SCRIPT - sed -e "s/^PANDORA_USER\=.*/PANDORA_USER\=$PANDORA_USER/g" $DAEMON_SCRIPT > $DAEMON_TEMP - mv $DAEMON_TEMP $DAEMON_SCRIPT + sed -e "s/^PANDORA_USER\=.*/PANDORA_USER\=$PANDORA_USER/g" $DAEMON_SCRIPT > $DAEMON_TEMP + mv $DAEMON_TEMP $DAEMON_SCRIPT + fi + + sed -e "s/^temporal [.]*/temporal $PANDORA_BASE_DECODED/g" $AGENT_CFG > $AGENT_CFG_TEMP + mv $AGENT_CFG_TEMP $AGENT_CFG + + sed -e "s/^logfile [.]*/logfile $PANDORA_BASE_DECODED/g" $AGENT_CFG > $AGENT_CFG_TEMP + mv $AGENT_CFG_TEMP $AGENT_CFG fi - - sed -e "s/^temporal [.]*/temporal $PANDORA_BASE_DECODED/g" $AGENT_CFG > $AGENT_CFG_TEMP - mv $AGENT_CFG_TEMP $AGENT_CFG - - sed -e "s/^logfile [.]*/logfile $PANDORA_BASE_DECODED/g" $AGENT_CFG > $AGENT_CFG_TEMP - mv $AGENT_CFG_TEMP $AGENT_CFG - fi - echo "Creating Pandora FMS Agent home directory at $PANDORA_BASE$PANDORA_HOME" - if [ ! -z "$PANDORA_BASE" ] - then - 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 - if [ "$OS_NAME" = "FreeBSD" ] + echo "Creating Pandora FMS Agent home directory at $PANDORA_BASE$PANDORA_HOME" + if [ ! -z "$PANDORA_BASE" ] then - mkdir -p $PANDORA_BASE/usr/local/bin 2> /dev/null - else - mkdir -p $PANDORA_BASE/usr/bin 2> /dev/null + 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 + if [ "$OS_NAME" = "FreeBSD" ] + then + mkdir -p $PANDORA_BASE/usr/local/bin 2> /dev/null + else + mkdir -p $PANDORA_BASE/usr/bin 2> /dev/null + fi fi - fi mkdir -p $PANDORA_BASE$PANDORA_HOME 2> /dev/null @@ -296,14 +296,8 @@ install () { chmod 755 $PANDORA_BASE$PANDORA_BIN cp pandora_agent_exec $PANDORA_BASE$PANDORA_EXEC_BIN chmod 755 $PANDORA_BASE$PANDORA_EXEC_BIN - if [ "$OS_NAME" = "FreeBSD" ] - then - chown $PANDORA_USER:wheel $PANDORA_BASE$PANDORA_BIN - chown $PANDORA_USER:wheel $PANDORA_BASE$PANDORA_EXEC_BIN - else - chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_BIN - chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_EXEC_BIN - fi + chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_BIN + chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_EXEC_BIN echo "Copying Pandora FMS Agent configuration file to $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf..." if [ -f $PANDORA_BASE/$PANDORA_CFG/pandora_agent.conf ] @@ -325,23 +319,12 @@ install () { echo "Copying tentacle server to $PANDORA_BASE$TENTACLE_SERVER" cp tentacle_server $PANDORA_BASE$TENTACLE_SERVER chmod 755 $PANDORA_BASE$TENTACLE_SERVER - if [ "$OS_NAME" = "FreeBSD" ] - then - chown $PANDORA_USER:wheel $PANDORA_BASE$TENTACLE_SERVER - else - chown $PANDORA_USER:0 $PANDORA_BASE$TENTACLE_SERVER - fi + chown $PANDORA_USER:0 $PANDORA_BASE$TENTACLE_SERVER echo "Copying tentacle client to $PANDORA_BASE$TENTACLE" cp tentacle_client $PANDORA_BASE$TENTACLE chmod 755 $PANDORA_BASE$TENTACLE - if [ "$OS_NAME" = "FreeBSD" ] - then - chown $PANDORA_USER:wheel $PANDORA_BASE$TENTACLE - else - chown $PANDORA_USER:0 $PANDORA_BASE$TENTACLE - fi - + chown $PANDORA_USER:0 $PANDORA_BASE$TENTACLE echo "Installing the Pandora Agent and Tentacle Client manuals" cp man/man1/tentacle_client.1.gz $PANDORA_BASE/$PANDORA_MAN/man1 @@ -353,17 +336,15 @@ install () { chown -R $PANDORA_USER $PANDORA_BASE$PANDORA_HOME chmod -R 700 $PANDORA_BASE$PANDORA_TEMP/data_out chmod 640 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG + chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG if [ "$OS_NAME" = "FreeBSD" ] then - chown $PANDORA_USER:wheel $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG chown $PANDORA_USER:daemon $PANDORA_BASE$PANDORA_TEMP chmod -R 770 $PANDORA_BASE$PANDORA_TEMP chmod 775 $PANDORA_BASE$PANDORA_TEMP - else - chown $PANDORA_USER:0 $PANDORA_BASE$PANDORA_LOG_DIR/$PANDORA_LOG fi - echo "Copying default agent configuration to $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf" + echo "Copying default agent configuration to $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf" cp $OS_NAME/pandora_agent.conf $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf chmod 600 $PANDORA_BASE$PANDORA_CFG/pandora_agent.conf @@ -432,12 +413,6 @@ install () { chown root:wheel $PANDORA_STARTUP fi - echo "Installing the Pandora Agent and Tentacle Client manuals" - 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 - echo "Done." echo " " echo "You have your startup script ready at $PANDORA_STARTUP" diff --git a/pandora_agents/unix/plugins/files_indir b/pandora_agents/unix/plugins/files_indir index 6dda84f561..dc29bcd051 100755 --- a/pandora_agents/unix/plugins/files_indir +++ b/pandora_agents/unix/plugins/files_indir @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Syntax: # @@ -13,10 +13,14 @@ then fi DIRE=$1 -DIRETMP=`echo $DIRE | md5sum | awk '{ print $1 }'` +if [ `uname -s` = "FreeBSD" ];then + DIRETMP=`echo $DIRE | /sbin/md5`; +else + DIRETMP=`echo $DIRE | md5sum | awk '{ print $1 }'` +fi DIRETMP=/tmp/$DIRETMP -CURRENT=`ls -la ${DIRE} | wc -l` +CURRENT=`ls -la ${DIRE} | wc -l | tr -d ' '` if [ -e $DIRETMP ] then diff --git a/pandora_agents/unix/plugins/pandora_update b/pandora_agents/unix/plugins/pandora_update index f1e8dfa4e4..cbbd16bc73 100755 --- a/pandora_agents/unix/plugins/pandora_update +++ b/pandora_agents/unix/plugins/pandora_update @@ -88,7 +88,7 @@ sub get_agent_pid ($$) { my $app_path = shift; $ENV{'COLUMNS'}=400; - my $os_name=`uname -s`; + my $os_name=`uname -s`; my $pid = ""; my $cmd = ""; @@ -106,9 +106,9 @@ sub get_agent_pid ($$) { if ( $zone =~ /global/) { $cmd ="ps -f -z global | grep \"$truncated_daemon\" | grep -v grep | head -1 | awk '{ print \$2 }'"; - } else { + } else { $cmd ="ps -Af | grep \"$truncated_daemon\" | grep -v grep | head -1 | awk '{ print \$2 }'"; - } + } } else { $cmd ="ps -Af | grep \"$daemon $app_path\" | grep -v grep | head -1 | awk '{ print \$2 }'"; } @@ -145,18 +145,17 @@ if (defined($ARGV[1])) { # Location of binaries # Unix -my $running_binary; -my $updated_binary; +my ($running_binary, $updated_binary, $conf_path); if ($^O eq 'freebsd') { - $running_binary = $opt_dir."/usr/local/bin/pandora_agent"; - $updated_binary = $opt_dir."/usr/local/etc/pandora/collections/$fc_path/pandora_agent"; + $running_binary = $opt_dir."/usr/local/bin/pandora_agent"; + $updated_binary = $opt_dir."/usr/local/etc/pandora/collections/$fc_path/pandora_agent"; + $conf_path = $opt_dir."/usr/local/etc/pandora"; } else { - $running_binary = $opt_dir."/usr/bin/pandora_agent"; - $updated_binary = $opt_dir."/etc/pandora/collections/$fc_path/pandora_agent"; + $running_binary = $opt_dir."/usr/bin/pandora_agent"; + $updated_binary = $opt_dir."/etc/pandora/collections/$fc_path/pandora_agent"; + $conf_path = $opt_dir."/etc/pandora"; } -my $conf_path = $opt_dir."/etc/pandora"; - # Windows #my $running_binary = $base_path."/../PandoraAgent.exe"; @@ -169,11 +168,11 @@ my $conf_path = $opt_dir."/etc/pandora"; my $start_pandora; my $stop_pandora; if ($^O eq 'freebsd') { - $start_pandora = $opt_dir."/usr/local/etc/rc.d/pandora_agent start"; - $stop_pandora = $opt_dir."/usr/local/etc/rc.d/pandora_agent stop"; + $start_pandora = $opt_dir."/usr/local/etc/rc.d/pandora_agent start"; + $stop_pandora = $opt_dir."/usr/local/etc/rc.d/pandora_agent stop"; } else { - $start_pandora = $opt_dir."/etc/init.d/pandora_agent_daemon start"; - $stop_pandora = $opt_dir."/etc/init.d/pandora_agent_daemon stop"; + $start_pandora = $opt_dir."/etc/init.d/pandora_agent_daemon start"; + $stop_pandora = $opt_dir."/etc/init.d/pandora_agent_daemon stop"; } # Windows stuff