CC-2138: update_db_info.py to read from /etc/airtime/airtime.conf

-done
This commit is contained in:
martin 2011-04-01 15:22:49 -04:00
parent 86f2129f8d
commit d3ec3ef1e8
5 changed files with 26 additions and 20 deletions

View File

@ -20,9 +20,9 @@ $CC_CONFIG = array(
'rabbitmq' => $values['rabbitmq'],
'baseFilesDir' => $values['general']['baseFilesDir'],
'baseFilesDir' => $values['general']['base_files_dir'],
// main directory for storing binary media files
'storageDir' => $values['general']['baseFilesDir']."/stor",
'storageDir' => $values['general']['base_files_dir']."/stor",
// Database config
'dsn' => array(

View File

@ -13,8 +13,9 @@ vhost = /
[general]
api_key = AAA
webServerUser = www-data
baseFilesDir = x
web_server_user = www-data
airtime_dir = x
base_files_dir = x
[soundcloud]
connection_retries = 3

View File

@ -161,7 +161,8 @@ class AirtimeIni{
{
$api_key = AirtimeIni::GenerateRandomString();
AirtimeIni::UpdateIniValue('/etc/airtime/airtime.conf', 'api_key', $api_key);
AirtimeIni::UpdateIniValue('/etc/airtime/airtime.conf', 'baseFilesDir', realpath(__DIR__.'/../../').'/files');
AirtimeIni::UpdateIniValue('/etc/airtime/airtime.conf', 'base_files_dir', realpath(__DIR__.'/../../').'/files');
AirtimeIni::UpdateIniValue('/etc/airtime/airtime.conf', 'airtime_dir', realpath(__DIR__.'/../../'));
AirtimeIni::UpdateIniValue('/etc/airtime/pypo.cfg', 'api_key', "'$api_key'");
AirtimeIni::UpdateIniValue('/etc/airtime/recorder.cfg', 'api_key', "'$api_key'");
AirtimeIni::UpdateIniValue(__DIR__.'/../../build/build.properties', 'project.home', realpath(__dir__.'/../../'));

View File

@ -167,10 +167,14 @@ class AirtimeInstall {
$dir = realpath(__DIR__."/../../utils/airtime-clean-storage");
exec("ln -s $dir /usr/bin/airtime-clean-storage");
$dir = realpath(__DIR__."/../../utils/airtime-update-db-settings");
exec("ln -s $dir /usr/bin/airtime-update-db-settings");
}
public static function RemoveSymlinks(){
exec("rm -f /usr/bin/airtime-import");
exec("rm -f /usr/bin/airtime-clean-storage");
exec("rm -f /usr/bin/airtime-update-db-settings");
}
}

View File

@ -2,7 +2,7 @@
The purpose of this script is to consolidate into one location where
we need to update database host, dbname, username and password.
This script reads from database.conf.
This script reads from airtime.conf.
"""
import os
import ConfigParser
@ -11,18 +11,18 @@ from xml.dom.minidom import Node
#Read the universal values
parser = ConfigParser.SafeConfigParser()
parser.read('airtime.conf')
section_names = parser.sections();
items_in_section = parser.items(section_names[0])
parser.read('/etc/airtime/airtime.conf')
print "Updating ../application/configs/application.ini"
host = 'resources.db.params.host'
dbname = 'resources.db.params.dbname'
username = 'resources.db.params.username'
password = 'resources.db.params.password'
f = file('../application/configs/application.ini','r')
airtime_dir = parser.get('general', 'airtime_dir')
print 'Airtime root folder found at %s' % airtime_dir
print ("Updating %s/application/configs/application.ini" % airtime_dir)
f = file('%s/application/configs/application.ini' % airtime_dir,'r')
file_lines = []
for line in f:
@ -37,14 +37,14 @@ for line in f:
file_lines.append(line)
f.close()
f = file('../application/configs/application.ini', 'w')
f = file('%s/application/configs/application.ini' % airtime_dir, 'w')
f.writelines(file_lines)
f.close()
print "Updating ./build.properties"
print ("Updating %s/build.properties" % airtime_dir)
f = file('build.properties', 'r')
f = file('%s/build/build.properties' % airtime_dir, 'r')
file_lines = []
db_url = 'propel.database.url'
@ -57,22 +57,22 @@ for line in f:
file_lines.append(line)
f.close()
f = file('build.properties', 'w')
f = file('%s/build/build.properties' % airtime_dir, 'w')
f.writelines(file_lines)
f.close()
print "Updating ./runtime-conf.xml"
print ("Updating %s/runtime-conf.xml" % airtime_dir)
doc = xml.dom.minidom.parse('./runtime-conf.xml')
doc = xml.dom.minidom.parse('%s/build/runtime-conf.xml' % airtime_dir)
node = doc.getElementsByTagName("dsn")[0]
node.firstChild.nodeValue = 'pgsql:host=%s;port=5432;dbname=%s;user=%s;password=%s' % (parser.get('database', 'host'), \
parser.get('database', 'dbname'), parser.get('database', 'dbuser'), parser.get('database', 'dbpass'))
xml_file = open('runtime-conf.xml', "w")
xml_file = open('%s/build/runtime-conf.xml' % airtime_dir, "w")
xml_file.writelines(doc.toxml('utf-8'))
xml_file.close()
print 'Regenerating propel-config.php'
os.system('../library/propel/generator/bin/propel-gen')
os.system('cd %s/build && %s/library/propel/generator/bin/propel-gen' % (airtime_dir, airtime_dir))