2010-05-24 18:38:04 +02:00
#!/bin/bash
# Automatically update Pandora FMS version and build where necessary.
2011-12-21 12:38:57 +01:00
source build_vars.sh
2010-05-24 18:38:04 +02:00
# Check command line arguments
2010-06-02 18:01:48 +02:00
if [ $# -lt 2 ] || [ $# -gt 3 ] ; then
2010-05-24 18:38:04 +02:00
echo " Usage: $0 <final|nightly> <version string> [build string] "
exit 1
fi
# Set some global vars
if [ " $1 " = = "nightly" ] ; then
NB = 1
else
NB = 0
fi
VERSION = $2
if [ $# = = 2 ] ; then
2018-12-31 11:44:06 +01:00
BUILD = ` date +%y%m%d`
2010-05-24 18:38:04 +02:00
else
2010-12-28 13:44:58 +01:00
BUILD = $3
2010-05-24 18:38:04 +02:00
fi
2011-12-21 12:38:57 +01:00
SPEC_FILES = " $CODEHOME /pandora_console/pandora_console.spec \
$CODEHOME /pandora_agents/unix/pandora_agent.spec \
2023-11-07 12:29:43 +01:00
$CODEHOME /pandora_agents/unix/pandora_agent.redhat_bin.el8.spec \
$CODEHOME /pandora_agents/unix/pandora_agent.redhat_bin.el9.spec \
$CODEHOME /pandora_agents/unix/pandora_agent.redhat_bin.spec \
$CODEHOME /pandora_agents/unix/pandora_agent.redhat.spec \
2011-12-21 12:38:57 +01:00
$CODEHOME /pandora_server/pandora_server.spec \
$PANDHOME_ENT /pandora_console/enterprise/pandora_console_enterprise.spec \
$PANDHOME_ENT /pandora_server/PandoraFMS-Enterprise/pandora_server_enterprise.spec \
$CODEHOME /pandora_console/pandora_console.redhat.spec \
2019-04-02 18:04:33 +02:00
$CODEHOME /pandora_console/pandora_console.rhel7.spec \
2011-12-21 12:38:57 +01:00
$CODEHOME /pandora_agents/unix/pandora_agent.redhat.spec \
$CODEHOME /pandora_server/pandora_server.redhat.spec \
2020-03-31 19:03:40 +02:00
$PANDHOME_ENT /pandora_agents/pandora_agent.spec \
2020-04-13 11:44:05 +02:00
$PANDHOME_ENT /pandora_server/pandora_server_enterprise.redhat.spec \
2011-12-21 12:38:57 +01:00
$PANDHOME_ENT /pandora_console/enterprise/pandora_console_enterprise.redhat.spec \
2019-04-17 09:45:08 +02:00
$PANDHOME_ENT /pandora_console/enterprise/pandora_console_enterprise.rhel7.spec \
2011-12-21 12:38:57 +01:00
$PANDHOME_ENT /pandora_server/PandoraFMS-Enterprise/pandora_server_enterprise.redhat.spec"
DEBIAN_FILES = " $CODEHOME /pandora_console/DEBIAN \
$CODEHOME /pandora_server/DEBIAN \
$CODEHOME /pandora_agents/unix/DEBIAN \
$PANDHOME_ENT /pandora_console/DEBIAN \
2020-04-20 10:46:22 +02:00
$PANDHOME_ENT /pandora_server/DEBIAN"
2015-11-13 04:02:03 +01:00
INSTALLER_FILES = " $CODEHOME /pandora_console/pandora_console_install \
$CODEHOME /pandora_server/pandora_server_installer \
$CODEHOME /pandora_agents/unix/pandora_agent_installer"
2011-12-21 12:38:57 +01:00
SERVER_FILE = " $CODEHOME /pandora_server/lib/PandoraFMS/Config.pm "
SERVER_DB_FILE = " $CODEHOME /pandora_server/util/pandora_db.pl "
SERVER_CLI_FILE = " $CODEHOME /pandora_server/util/pandora_manage.pl "
2013-09-30 16:34:09 +02:00
SERVER_CONF_FILE = " $CODEHOME /pandora_server/conf/pandora_server.conf.new "
2017-03-13 18:06:39 +01:00
SERVER_WIN_MPI_OPEN_FILE = " $PANDHOME_ENT /pandora_server/extras/nsis_installer/pandorafms_open.nsi "
SERVER_WIN_MPI_ENT_FILE = " $PANDHOME_ENT /pandora_server/extras/nsis_installer/pandorafms_ent.nsi "
2011-12-21 12:38:57 +01:00
CONSOLE_DB_FILE = " $CODEHOME /pandora_console/pandoradb_data.sql "
2015-09-08 15:42:26 +02:00
CONSOLE_DB_FILE_ORACLE = " $CODEHOME /pandora_console/pandoradb.data.oracle.sql "
2011-12-21 12:38:57 +01:00
CONSOLE_FILE = " $CODEHOME /pandora_console/include/config_process.php "
CONSOLE_INSTALL_FILE = " $CODEHOME /pandora_console/install.php "
2012-06-20 15:42:17 +02:00
AGENT_BASE_DIR = " $CODEHOME /pandora_agents/ "
2011-12-21 12:38:57 +01:00
AGENT_UNIX_FILE = " $CODEHOME /pandora_agents/unix/pandora_agent "
AGENT_WIN_FILE = " $CODEHOME /pandora_agents/win32/pandora.cc "
AGENT_WIN_MPI_FILE = " $CODEHOME /pandora_agents/win32/installer/pandora.mpi "
2012-02-21 15:35:48 +01:00
AGENT_WIN_RC_FILE = " $CODEHOME /pandora_agents/win32/versioninfo.rc "
2020-08-13 15:38:01 +02:00
AGENT_DARWIN_BUILDER = " $CODEHOME /pandora_agents/unix/Darwin/dmg/build_darwin_dmg.sh "
AGENT_DARWIN_DISTR = " $CODEHOME /pandora_agents/unix/Darwin/dmg/extras/distribution.xml "
AGENT_DARWIN_PLIST = " $CODEHOME /pandora_agents/unix/Darwin/dmg/files/pandorafms_uninstall/PandoraFMS agent uninstaller.app/Contents/Info.plist "
2014-06-17 13:16:23 +02:00
SATELLITE_FILE = " $PANDHOME_ENT /satellite_server/satellite_server.pl "
2019-02-25 11:09:29 +01:00
PERL_PLUGIN_FILES = " $PANDHOME_ENT /pandora_server/util/recon_script/vmware-plugin.pl \
$PANDHOME_ENT /pandora_server/util/recon_script/pcm_client.pl \
2018-06-27 12:21:21 +02:00
$PANDHOME_ENT /pandora_plugins/NGINX/nginx_requests_queued.pl \
2017-12-04 15:50:29 +01:00
$PANDHOME_ENT /pandora_plugins/Sybase/sybase_plugin.pl \
2018-06-27 12:21:21 +02:00
$PANDHOME_ENT /pandora_plugins/SNMP/dynamic_snmp.pl \
2018-07-09 16:34:20 +02:00
$PANDHOME_ENT /pandora_plugins/SNMP/snmp_bandwidth.pl \
2018-06-27 12:21:21 +02:00
$PANDHOME_ENT /pandora_plugins/laboratory/cacti/cacti2pandora.pl \
2017-12-04 15:50:29 +01:00
$PANDHOME_ENT /pandora_plugins/MarkLogic/pandora_marklogic.pl \
2018-06-27 12:21:21 +02:00
$PANDHOME_ENT /pandora_plugins/MySQL/pandora_mysql.pl \
$PANDHOME_ENT /pandora_plugins/JMX/pandora_plugin_jmx.pl \
2017-12-04 15:50:29 +01:00
$PANDHOME_ENT /pandora_plugins/Apache/pandora_apache.pl \
2018-06-27 12:21:21 +02:00
$PANDHOME_ENT /pandora_plugins/UX/pandora_ux.pl \
2017-12-04 15:50:29 +01:00
$PANDHOME_ENT /pandora_plugins/Oracle/Database/pandora_oracle.pl \
$PANDHOME_ENT /pandora_plugins/OpenNebula/pandora_opennebula.pl \
$PANDHOME_ENT /pandora_plugins/Nutanix/pandora_nutanix.pl \
$PANDHOME_ENT /pandora_plugins/MTL/pandora_mtl.pl \
$PANDHOME_ENT /pandora_plugins/Informix/informix.pl \
2018-06-27 12:21:21 +02:00
$PANDHOME_ENT /pandora_plugins/Docker/docker_services.pl \
$PANDHOME_ENT /pandora_plugins/Docker/docker_stats.pl \
$PANDHOME_ENT /pandora_plugins/Ruckus/ruckus.pl "
2017-12-04 15:50:29 +01:00
PLUGIN_LIB_FILE = " $CODEHOME /pandora_server/lib/PandoraFMS/PluginTools.pm "
2010-05-24 18:38:04 +02:00
# Update version in spec files
function update_spec_version {
FILE = $1
if [ $NB = = 1 ] ; then
2017-03-01 15:59:31 +01:00
sed -i -e " s/^\s*%define\s\s*release\s\s*.*/%define release $BUILD / " " $FILE "
2010-05-24 18:38:04 +02:00
else
2017-03-01 15:59:31 +01:00
sed -i -e "s/^\s*%define\s\s*release\s\s*.*/%define release 1/" " $FILE "
2010-05-24 18:38:04 +02:00
fi
2017-03-01 15:59:31 +01:00
sed -i -e " s/^\s*%define\s\s*version\s\s*.*/%define version $VERSION / " " $FILE "
2010-05-24 18:38:04 +02:00
}
# Update version in debian dirs
function update_deb_version {
DEBIAN_DIR = $1
2015-09-08 15:42:26 +02:00
2010-05-24 18:38:04 +02:00
if [ $NB = = 1 ] ; then
LOCAL_VERSION = " $VERSION - $BUILD "
else
LOCAL_VERSION = " $VERSION "
fi
2017-03-01 15:59:31 +01:00
sed -i -e " s/^pandora_version\s*=.*/pandora_version=\" $LOCAL_VERSION \"/ " " $DEBIAN_DIR /make_deb_package.sh " && sed -i -e " s/^Version:\s*.*/Version: $LOCAL_VERSION / " " $DEBIAN_DIR /control "
2010-05-24 18:38:04 +02:00
}
2015-11-13 04:02:03 +01:00
# Update version in installer
function update_installer_version {
FILE = $1
2017-03-01 15:59:31 +01:00
sed -i -e " /^PI_VERSION/s/=.*/=\" $VERSION \"/ " -e " /^PI_BUILD/s/=.*/=\" $BUILD \"/ " " $FILE "
2015-11-13 04:02:03 +01:00
}
2017-12-04 15:50:29 +01:00
# Update version in Perl files
function update_perl_version {
FILE = $1
sed -i -e " s/my\s\s*\$pandora_version\s*=.*/my \$pandora_version = \" $VERSION \";/ " " $FILE "
sed -i -e " s/my\s\s*\$pandora_build\s*=.*/my \$pandora_build = \" $BUILD \";/ " " $FILE "
}
2010-05-24 18:38:04 +02:00
# Spec files
for file in $SPEC_FILES ; do
echo " Updating spec file $file ... "
update_spec_version $file
done
# Debian dirs
for dir in $DEBIAN_FILES ; do
echo " Updating DEBIAN dir $dir ... "
update_deb_version $dir
done
2015-11-13 04:02:03 +01:00
# Installer files
for file in $INSTALLER_FILES ; do
echo " Updating installer file $file ... "
update_installer_version $file
done
2020-08-13 15:36:58 +02:00
# Darwin dmg installer files
echo "Updating DARWIN DMG files..."
2020-10-16 16:29:02 +02:00
sed -i -e " /VERSION/s/=\"7.0NG.*/=\" $VERSION \"/ " " $AGENT_DARWIN_BUILDER "
2020-08-13 15:36:58 +02:00
sed -i -r " s/(version=\").*(\"\s+onConclusion=)/\1 $VERSION \2/g " " $AGENT_DARWIN_DISTR "
sed -i -r " s/(CFBundleVersion<\/key>\s*<string>).*(<\/string>)/\1 $VERSION \2/g " " $AGENT_DARWIN_PLIST "
sed -i -r " s/(CFBundleShortVersionString<\/key>\s*<string>).*(<\/string>)/\1 $VERSION \2/g " " $AGENT_DARWIN_PLIST "
sed -i -r " s/(CFBundleGetInfoString<\/key>\s*<string>).*( Pandora FMS)/\1 $VERSION \2/g " " $AGENT_DARWIN_PLIST "
2017-12-04 15:50:29 +01:00
# Perl plugins files
for file in $PERL_PLUGIN_FILES ; do
2017-12-04 15:52:05 +01:00
echo " Updating plugin file $file ... "
2017-12-04 15:50:29 +01:00
update_perl_version $file
done
2010-05-24 18:38:04 +02:00
# Pandora Server
echo "Updating Pandora Server version..."
2017-03-01 15:59:31 +01:00
sed -i -e " s/my\s\s*\$pandora_version\s*=.*/my \$pandora_version = \" $VERSION \";/ " " $SERVER_FILE "
sed -i -e " s/my\s\s*\$pandora_build\s*=.*/my \$pandora_build = \" $BUILD \";/ " " $SERVER_FILE "
2011-12-14 15:12:27 +01:00
echo "Updating DB maintenance script version..."
2021-05-10 17:58:17 +02:00
sed -i -e " s/my\s\s*\$version\s*=.*/my \$version = \" $VERSION Build $BUILD \";/ " " $SERVER_DB_FILE "
2011-12-14 15:12:27 +01:00
echo "Updating CLI script version..."
2021-05-10 17:58:17 +02:00
sed -i -e " s/my\s\s*\$version\s*=.*/my \$version = \" $VERSION Build $BUILD \";/ " " $SERVER_CLI_FILE "
2017-03-01 15:59:31 +01:00
sed -i -e " s/\s*\#\s*\Version.*/\# Version $VERSION / " " $SERVER_CONF_FILE "
2017-03-13 18:06:39 +01:00
sed -i -e " s/\s*\!define PRODUCT_VERSION.*/\!define PRODUCT_VERSION \" $VERSION \"/ " " $SERVER_WIN_MPI_OPEN_FILE "
sed -i -e " s/\s*\!define PRODUCT_VERSION.*/\!define PRODUCT_VERSION \" $VERSION \"/ " " $SERVER_WIN_MPI_ENT_FILE "
2020-08-13 15:36:58 +02:00
echo "Updating Pandora PluginTools version..."
2017-12-04 15:50:29 +01:00
sed -i -e " s/my\s\s*\$pandora_version\s*=.*/my \$pandora_version = \" $VERSION \";/ " " $PLUGIN_LIB_FILE "
sed -i -e " s/my\s\s*\$pandora_build\s*=.*/my \$pandora_build = \" $BUILD \";/ " " $PLUGIN_LIB_FILE "
2010-05-24 18:38:04 +02:00
2014-06-17 13:16:23 +02:00
# Pandora Satellite Server
echo "Updating Pandora Satellite Server version..."
2017-03-01 15:59:31 +01:00
sed -i -e " s/\s*use constant SATELLITE_VERSION.*/use constant SATELLITE_VERSION \=\> \" $VERSION \";/ " " $SATELLITE_FILE "
sed -i -e " s/\s*use constant SATELLITE_BUILD.*/use constant SATELLITE_BUILD \=\> \" $BUILD \";/ " " $SATELLITE_FILE "
2014-06-17 13:16:23 +02:00
2010-05-24 18:38:04 +02:00
# Pandora Console
echo "Updating Pandora Console DB version..."
2017-03-01 15:59:31 +01:00
sed -i -e " s/\s*[(]\s*'db_scheme_version'\s*\,.*/('db_scheme_version'\,' $VERSION '),/ " " $CONSOLE_DB_FILE_ORACLE "
sed -i -e " s/\s*[(]\s*'db_scheme_build'\s*\,.*/('db_scheme_build'\,'PD $BUILD '),/ " " $CONSOLE_DB_FILE_ORACLE "
2015-09-08 15:42:26 +02:00
2017-03-01 15:59:31 +01:00
sed -i -e " s/\s*[(]\s*'db_scheme_version'\s*\,.*/('db_scheme_version'\,' $VERSION ');/ " " $CONSOLE_DB_FILE_ORACLE "
sed -i -e " s/\s*[(]\s*'db_scheme_build'\s*\,.*/('db_scheme_build'\,'PD $BUILD ');/ " " $CONSOLE_DB_FILE_ORACLE "
2015-09-08 15:42:26 +02:00
2010-05-24 18:38:04 +02:00
echo "Updating Pandora Console version..."
2017-03-01 15:59:31 +01:00
sed -i -e " s/\s*\$pandora_version\s*=.*/\$pandora_version = 'v $VERSION ';/ " " $CONSOLE_FILE "
sed -i -e " s/\s*\$build_version\s*=.*/\$build_version = 'PC $BUILD ';/ " " $CONSOLE_FILE "
2010-12-28 13:44:58 +01:00
echo "Updating Pandora Console installer version..."
2019-03-18 11:18:55 +01:00
sed -i -e " s/\(\s*\$version\s*=\s\).*/\1' $VERSION ';/ " " $CONSOLE_INSTALL_FILE "
sed -i -e " s/\(\s*\$build\s*=\s\).*/\1' $BUILD ';/ " " $CONSOLE_INSTALL_FILE "
2010-06-02 18:01:48 +02:00
echo "Setting develop_bypass to 0..."
2017-03-01 15:59:31 +01:00
sed -i -e " s/\s*if\s*(\s*[!]\s*isset\s*(\s* $develop_bypass \s*)\s*)\s* $develop_bypass \s*=.*/if ([!]isset( $develop_bypass )) $develop_bypass = 0;/ " " $CONSOLE_FILE "
2010-05-24 18:38:04 +02:00
# Pandora Agents
echo "Updating Pandora Unix Agent version..."
2017-03-01 15:59:31 +01:00
sed -i -e " s/\s*use\s*constant\s*AGENT_VERSION =>.*/use constant AGENT_VERSION => ' $VERSION ';/ " " $AGENT_UNIX_FILE "
sed -i -e " s/\s*use\s*constant\s*AGENT_BUILD =>.*/use constant AGENT_BUILD => ' $BUILD ';/ " " $AGENT_UNIX_FILE "
2010-05-24 18:38:04 +02:00
echo "Updating Pandora Windows Agent version..."
2021-05-10 17:58:17 +02:00
sed -i -e " s/\s*#define\s*PANDORA_VERSION\s*.*/#define PANDORA_VERSION (\" $VERSION Build $BUILD \")/ " " $AGENT_WIN_FILE "
2017-03-01 15:59:31 +01:00
sed -i -e " s/{Pandora FMS Windows Agent v.*}/{Pandora FMS Windows Agent v $VERSION }/ " " $AGENT_WIN_MPI_FILE "
2010-11-03 18:23:26 +01:00
NUMERIC_VERSION = $( echo $VERSION | sed -e "s/\([0-9]*\.[0-9]*\).*/\1/" )
2017-03-06 09:12:38 +01:00
sed -i -n " 1h;1!H;\${;g;s/[\r\n]InstallVersion[\r\n]{\S*}/\nInstallVersion\n{ $NUMERIC_VERSION .0.0}/g;p;} " " $AGENT_WIN_MPI_FILE "
sed -i -n " 1h;1!H;\${;g;s/[\r\n]Version[\r\n]{[^\n\r]*}/\nVersion\n{ $BUILD }/g;p;} " " $AGENT_WIN_MPI_FILE "
2011-10-27 20:11:02 +02:00
if [ $NB = = 1 ] ; then
2017-03-01 15:59:31 +01:00
sed --in-place -n "1h;1!H;\${;g;s/[\r\n]Windows\,Executable[\r\n]{[^\n\r]*}/\nWindows\,Executable\n{\<\%AppName\%\>\-\<\%Version\%\>\-Setup\<\%Ext\%\>}/g;p;}" " $AGENT_WIN_MPI_FILE "
2011-10-27 20:11:02 +02:00
else
2017-03-01 15:59:31 +01:00
sed --in-place -n "1h;1!H;\${;g;s/[\r\n]Windows\,Executable[\r\n]{[^\n\r]*}/\nWindows\,Executable\n{\<\%AppName\%\>\-Setup\<\%Ext\%\>}/g;p;}" " $AGENT_WIN_MPI_FILE "
2011-10-27 20:11:02 +02:00
fi
2017-03-01 15:59:31 +01:00
sed -i -e " s/\s*VALUE \"ProductVersion\".*/ VALUE \"ProductVersion\", \"( $VERSION (Build $BUILD ))\"/ " " $AGENT_WIN_RC_FILE "
2012-06-20 15:42:17 +02:00
echo "Updating Agent configuration files..."
for conf in ` find $AGENT_BASE_DIR -name pandora_agent.conf` ; do
2017-03-01 15:59:31 +01:00
sed -i -e " s/#\s*[Vv]ersion\s*[^\,]*/# Version $VERSION / " " $conf "
2012-06-20 15:42:17 +02:00
done
2010-05-24 18:38:04 +02:00