From 051cc243ca14e88e2166334dec9b35876bfeb758 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Fri, 5 Nov 2010 13:03:16 -0400 Subject: [PATCH] call propel-gen to load sql in database. --- install/nondbinstall.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/install/nondbinstall.php b/install/nondbinstall.php index dfe1349b1..f286c8207 100644 --- a/install/nondbinstall.php +++ b/install/nondbinstall.php @@ -24,6 +24,32 @@ require_once(dirname(__FILE__).'/../backend/GreenBox.php'); require_once(dirname(__FILE__).'/../backend/cron/Cron.php'); require_once(dirname(__FILE__)."/installInit.php"); +// Need to check that we are superuser before running this. + +echo " *** Database Installation ***\n"; + +//sudo -u postgres createuser --no-superuser --no-createdb --no-createrole -A -P myuser + +// Create the database user +$command = "sudo -u postgres psql postgres --command \"CREATE USER {$CC_CONFIG['dsn']['username']} " + ." ENCRYPTED PASSWORD '{$CC_CONFIG['dsn']['password']}' LOGIN CREATEDB NOCREATEUSER;\" 2>/dev/null"; +//echo $command."\n"; +@exec($command, $output, $results); +if ($results == 0) { + echo " * User {$CC_CONFIG['dsn']['username']} created.\n"; +} else { + echo " * User {$CC_CONFIG['dsn']['username']} already exists.\n"; +} + +$command = "sudo -u postgres createdb {$CC_CONFIG['dsn']['database']} --owner {$CC_CONFIG['dsn']['username']} 2> /dev/null"; +//echo $command."\n"; +@exec($command, $output, $results); +if ($results == 0) { + echo " * Database '{$CC_CONFIG['dsn']['database']}' created.\n"; +} else { + echo " * Database '{$CC_CONFIG['dsn']['database']}' already exists.\n"; +} + // Connect to DB campcaster_db_connect(true); @@ -37,6 +63,12 @@ if ($langIsInstalled == '0') { echo " * Postgres scripting language already installed\n"; } +// Put Propel sql files in Database +$command = "../3rd_party/php/propel/generator/bin/propel-gen ../backend/propel-db/ insert-sql"; +echo $command."\n"; +@exec($command, $output, $results); + + //------------------------------------------------------------------------ // Install default data //------------------------------------------------------------------------