2009-10-30 10:09:00 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#Pandora FMS- http:#pandorafms.com
|
|
|
|
# ==================================================
|
|
|
|
# Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
|
|
|
|
# Please see http:#pandorafms.org for full contribution list
|
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public License
|
|
|
|
# as published by the Free Software Foundation; version 2
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
2009-11-29 14:35:16 +01:00
|
|
|
pandora_agent_version="3.0.0.RC3"
|
2009-10-30 10:09:00 +01:00
|
|
|
|
2009-11-04 16:39:35 +01:00
|
|
|
echo "Test if you has the tools for to make the packages."
|
2009-10-30 10:09:00 +01:00
|
|
|
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
|
|
|
if [ $? = 1 ]
|
|
|
|
then
|
2009-11-04 16:39:35 +01:00
|
|
|
echo "No found \"dpkg-deb\" aplication, please install."
|
2009-10-30 10:09:00 +01:00
|
|
|
exit 1
|
|
|
|
else
|
2009-11-04 16:39:35 +01:00
|
|
|
echo "Found \"dpkg-debs\"."
|
2009-10-30 10:09:00 +01:00
|
|
|
fi
|
|
|
|
|
2009-11-10 01:52:18 +01:00
|
|
|
cd ..
|
|
|
|
|
2009-11-04 16:39:35 +01:00
|
|
|
echo "Make a \"temp_package\" temp dir for job."
|
|
|
|
mkdir -p temp_package/usr/share/pandora_agent
|
|
|
|
mkdir -p temp_package/var/spool/pandora/data_out
|
|
|
|
mkdir -p temp_package/var/log/pandora/
|
|
|
|
mkdir -p temp_package/etc/pandora
|
|
|
|
mkdir -p temp_package/etc/init.d/
|
2009-11-10 01:52:18 +01:00
|
|
|
mkdir -p temp_package/usr/bin
|
2009-11-04 16:39:35 +01:00
|
|
|
|
|
|
|
echo "Make directory system tree for package."
|
2009-10-30 10:09:00 +01:00
|
|
|
cp DEBIAN temp_package -R
|
|
|
|
|
|
|
|
PANDORA_LOG=temp_package/var/log/pandora/pandora_agent.log
|
2009-11-10 01:52:18 +01:00
|
|
|
PANDORA_BIN=temp_package/usr/bin/pandora_agent
|
2009-10-30 10:09:00 +01:00
|
|
|
PANDORA_HOME=temp_package/usr/share/pandora_agent
|
|
|
|
TENTACLE=temp_package/usr/bin/tentacle_client
|
|
|
|
PANDORA_CFG=temp_package/etc/pandora
|
|
|
|
PANDORA_STARTUP=temp_package/etc/init.d/pandora_agent_daemon
|
|
|
|
|
|
|
|
# Create logfile
|
|
|
|
if [ ! -z "`touch $PANDORA_LOG`" ]
|
|
|
|
then
|
|
|
|
echo "Seems to be a problem generating logfile ($PANDORA_LOG) please check it";
|
|
|
|
exit
|
|
|
|
else
|
|
|
|
echo "Creating logfile at $PANDORA_LOG..."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Copying agent
|
|
|
|
echo "Copying Pandora FMS Agent to $PANDORA_BIN..."
|
|
|
|
cp pandora_agent $PANDORA_BIN
|
|
|
|
|
|
|
|
echo "Copying Pandora FMS Agent contrib dir to $PANDORA_HOME/..."
|
|
|
|
cp pandora_agent_daemon $PANDORA_HOME
|
|
|
|
|
|
|
|
echo "Copying default agent configuration to $PANDORA_HOME/pandora_agent.conf"
|
|
|
|
cp pandora_agent.conf $PANDORA_HOME/pandora_agent.conf
|
|
|
|
|
|
|
|
echo "Copying Pandora FMS Agent plugins to $PANDORA_HOME/plugins..."
|
|
|
|
cp -r plugins $PANDORA_HOME
|
|
|
|
|
|
|
|
echo "Copying tentacle client to $TENTACLE"
|
|
|
|
cp tentacle_client $TENTACLE
|
|
|
|
|
|
|
|
echo "Linking start-up daemon script at $PANDORA_STARTUP";
|
|
|
|
cp pandora_agent_daemon $PANDORA_STARTUP
|
|
|
|
|
|
|
|
touch $PANDORA_CFG/pandora_agent.conf
|
|
|
|
|
2009-11-04 16:39:35 +01:00
|
|
|
echo "Remove the SVN files and other temp files."
|
2009-10-30 10:09:00 +01:00
|
|
|
for item in `find temp_package`
|
|
|
|
do
|
|
|
|
echo -n "."
|
|
|
|
echo $item | grep "svn" > /dev/null
|
|
|
|
#last command success
|
|
|
|
if [ $? -eq 0 ]
|
|
|
|
then
|
|
|
|
rm -rf $item
|
|
|
|
fi
|
2009-11-04 16:39:35 +01:00
|
|
|
|
|
|
|
echo $item | grep "make_deb_package.sh" > /dev/null
|
|
|
|
#last command success
|
|
|
|
if [ $? -eq 0 ]
|
|
|
|
then
|
|
|
|
rm -rf $item
|
|
|
|
fi
|
2009-10-30 10:09:00 +01:00
|
|
|
done
|
2009-11-04 16:39:35 +01:00
|
|
|
echo "END"
|
2009-10-30 10:09:00 +01:00
|
|
|
|
2009-11-04 16:39:35 +01:00
|
|
|
echo "Calcule md5sum for md5sums file control of package"
|
2009-10-30 10:09:00 +01:00
|
|
|
for item in `find temp_package`
|
|
|
|
do
|
|
|
|
echo -n "."
|
|
|
|
if [ ! -d $item ]
|
|
|
|
then
|
|
|
|
echo $item | grep "DEBIAN" > /dev/null
|
|
|
|
#last command success
|
|
|
|
if [ $? -eq 1 ]
|
|
|
|
then
|
|
|
|
md5=`md5sum $item | cut -d" " -f1`
|
|
|
|
|
|
|
|
#delete "temp_package" in the path
|
|
|
|
final_path=${item#temp_package}
|
|
|
|
echo $md5" "$final_path >> temp_package/DEBIAN/md5sums
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2009-11-04 16:39:35 +01:00
|
|
|
echo "END"
|
2009-10-30 10:09:00 +01:00
|
|
|
|
2009-11-04 16:39:35 +01:00
|
|
|
echo "Make the package \"Pandorafms console\"."
|
2009-10-30 10:09:00 +01:00
|
|
|
dpkg-deb --build temp_package
|
|
|
|
mv temp_package.deb pandorafms.agent_$pandora_agent_version.deb
|
|
|
|
|
2009-11-04 16:39:35 +01:00
|
|
|
echo "Delete the \"temp_package\" temp dir for job."
|
2009-10-30 10:09:00 +01:00
|
|
|
rm -rf temp_package
|