#! /usr/bin/env bash

#
# zenoss_upgrade_pre
#
# This script is intended to be run before the zenoss processes have
# been started for the first time after an upgrade.
#
# Note: it is run by root
#

#############################################################################
# This program is part of Zenoss Core, an open source monitoring platform.
# Copyright (C) 2007, Zenoss Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
# For complete information please visit: http://www.zenoss.com/oss/
#############################################################################
# environment variables
export OS_USERNAME="**OS_USERNAME**"
export OS_UID="**OS_UID**"
export ZENHOME="**ZENHOME**"
export MYSQLHOST="**MYSQL_HOST**"
export MYSQLROOTUSER="**MYSQL_ROOT_USERNAME**"
export MYSQLROOTPASSWD="**MYSQL_ROOT_PASSWD**"
export MYSQLUSER="**MYSQL_USERNAME**"
export MYSQLPASS="**MYSQL_PASSWD**"
export MYSQLEVENTDB="**MYSQL_DATABASE**"
export ZOPEPASSWORD="**ZOPE_PASSWD**"
export ZOPEHOME="**ZOPEHOME**"

# load the installation functions
. ${ZENHOME}/bin/shared-functions.sh
. ${ZENHOME}/bin/install-functions.sh

# copy the etc/*.conf.example files to etc/*.conf if etc/*.conf don't
# already exist (we don't want to clobber people's configs)
update_conf_files

# migrate the zeo database
start_zeodb
run_zenmigrate
stop_zeodb

