2009-01-26 17:51:14 +01:00
|
|
|
# Pandora FMS 2.0 Console Upgrade (c) 2009 Artica ST
|
|
|
|
# Please see http://www.pandorafms.com
|
|
|
|
# This code is licensed under GPL 2.0 license.
|
|
|
|
# **********************************************************************
|
|
|
|
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
USER=`whoami`
|
|
|
|
|
|
|
|
if [ $USER != "root" ]
|
|
|
|
then
|
|
|
|
echo "Upgrade process need to be executed by root"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
|
|
|
MODE=$1
|
|
|
|
|
|
|
|
pandora_upgrade () {
|
|
|
|
|
|
|
|
if [ ! -e "$PANDORAPATH/index.php" ]
|
|
|
|
then
|
|
|
|
echo "ERROR: Provided path for current Pandora FMS console, do not exist ($PANDORAPATH)"
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
echo "Installing new console code in $PANDORAPATH"
|
|
|
|
cp -R * $PANDORAPATH
|
2009-04-03 12:44:26 +02:00
|
|
|
|
|
|
|
# This makes the old-style config.php file usable with 3.0
|
|
|
|
|
|
|
|
line=$(grep "?>" -n $PANDORAPATH/include/config.php | head -1 | cut -f1 -d:)
|
|
|
|
line=$(($line - 1))
|
|
|
|
head -$line $PANDORAPATH/include/config.php > /tmp/asdf
|
|
|
|
echo "require_once ('config_process.php');" >> /tmp/asdf
|
|
|
|
echo "?>" >> /tmp/asdf
|
|
|
|
mv /tmp/asdf $PANDORAPATH/include/config.php
|
|
|
|
|
|
|
|
# Upgrade Database ?
|
2009-01-26 17:51:14 +01:00
|
|
|
|
|
|
|
if [ "$UPGRADEDB" == "1" ]
|
|
|
|
then
|
|
|
|
echo "Setting database schema changes"
|
|
|
|
DBUSER=`cat $PANDORAPATH/include/config.php | grep dbuser | grep -v "^\/" | grep -o "\=\"[a-zA-Z0-9]*\"" | grep -o "[A-Za-z0-9]*"`
|
|
|
|
DBPASS=`cat $PANDORAPATH/include/config.php | grep dbpass | grep -v "^\/" | grep -o "\=\"[a-zA-Z0-9]*\"" | grep -o "[A-Za-z0-9]*"`
|
|
|
|
DBHOST=`cat $PANDORAPATH/include/config.php | grep dbhost | grep -v "^\/" | grep -o "\=\"[a-zA-Z0-9]*\"" | grep -o "[A-Za-z0-9]*"`
|
|
|
|
DBNAME=`cat $PANDORAPATH/include/config.php | grep dbname | grep -v "^\/" | grep -o "\=\"[a-zA-Z0-9]*\"" | grep -o "[A-Za-z0-9]*"`
|
2009-03-04 Sancho Lerena <slerena@artica.es>
* extras/: New directory with extra contents (scripts, tools, samples)
* index.php: Add new permission check for /attachment directory. Probably
could be extended and wrapped into a function. This should be only called
once, this is the reason why is placed here and not in config_process.
* pandora_console_upgrade: Force MYSQL run, even if SQL return error (useful
for applying over a older 3.0 version for example).
* pandoradb_data.sql: Was missing some tconfig variables.
* extras/*.sql: Missing somre tconfig variables and other minor issues fixed
* extensions/update_manager/main.php: Description of update manager patch
wider. Probably needs more formatting in the future.
* extras/sample_login.php: Sample on how to implement autologin feature.
* footer.php: I hope solve the frakkin image problem.
* godmode/agents/agent_manager.php: proper ACL check notice.
* godmode/alerts/alert_list.php: Fixed notice.
* godmode/reporting/map_builder.php: Added link to wizard and item count.
* godmode/reporting/map_builder_wizard.php: Added new feature, a wizard
to populate the visual map, using agents from a combo, depending on the
map selected. Could have a lot of improvements, it's a basic start. Allow
to choose agents and image maps and space between images. Puts in a reticle
automatically adjusting at 600px width.
* godmode/setup.php: Checkbox for trap_forward was bad, fixed.
* config_process.php: Fixed version to 3.0-dev
* functions_html.php: Default of 0 in text boxes makes them unusable on
default values, funny :-)
* include/functions_reporting.php: Fixed a notice on unknown variable
on function get_group_stat().
* operation/agentes/alerts_status.php: Filter on module status is made now
with combos, like the rest of the filters in the GUI.
* operation/events/events.php: a missing div makes graph float outside the
filter box. TODO: Hidder filter makes free-width style buggy here.
* operation/reporting/reporting_viewer.php: Fixed layout issue.
* operation/visual_console/render_view.php: Added ACL check.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1510 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-03-04 18:57:00 +01:00
|
|
|
cat extras/pandoradb_migrate_v2.x_to_v3.0.sql | mysql -f -u $DBUSER -p$DBPASS -h $DBHOST -D $DBNAME
|
2009-01-26 17:51:14 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
WWWUSER=`ls -la $PANDORAPATH/index.php | awk '{ print $3 }'`
|
|
|
|
echo "Setting permissions for $WWWUSER in $PANDORAPATH"
|
|
|
|
chown -R $WWWUSER $PANDORAPATH
|
|
|
|
|
|
|
|
echo "Setting permissions for $WWWUSER in /var/spool/pandora/data_in"
|
|
|
|
chgrp -R $WWWUSER /var/spool/pandora/data_in
|
|
|
|
|
|
|
|
echo " "
|
|
|
|
echo "DONE!"
|
|
|
|
echo " "
|
|
|
|
}
|
|
|
|
|
|
|
|
help () {
|
|
|
|
echo " -p <path> Upgrade Pandora FMS Console in path (pe: /var/www/pandora_console)"
|
|
|
|
echo " -d Upgrade also Database (by default not upgrade Database) "
|
|
|
|
echo " "
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
# Script banner at start
|
|
|
|
echo " "
|
|
|
|
echo "Pandora FMS 2.1 Console Upgrade (c) 2009 Artica ST"
|
|
|
|
echo "This program is licensed under GPL2 Terms. http://pandorafms.com"
|
|
|
|
echo " "
|
|
|
|
|
|
|
|
UPGRADEDB=0
|
|
|
|
UPGRADE=0
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]
|
|
|
|
then
|
|
|
|
help
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Main parsing code
|
|
|
|
|
|
|
|
while getopts ":hdp:" optname
|
|
|
|
do
|
|
|
|
case "$optname" in
|
|
|
|
"h")
|
|
|
|
help
|
|
|
|
;;
|
|
|
|
"d")
|
|
|
|
UPGRADEDB=1
|
|
|
|
;;
|
|
|
|
"p")
|
|
|
|
PANDORAPATH=$OPTARG
|
|
|
|
UPGRADE=1
|
|
|
|
;;
|
|
|
|
?)
|
|
|
|
help
|
|
|
|
;;
|
|
|
|
default)
|
|
|
|
help
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "$UPGRADE" == "1" ]
|
|
|
|
then
|
|
|
|
pandora_upgrade
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit
|