check some permission before starting install process

This commit is contained in:
Manuel Raynaud
2013-06-06 11:54:32 +02:00
parent b3c0397a55
commit c2a6fbecef
6 changed files with 55 additions and 13 deletions

0
cache/.gitkeep vendored Normal file → Executable file
View File

0
cache/.htaccess vendored Normal file → Executable file
View File

View File

@@ -53,6 +53,8 @@ class Install extends ContainerAwareCommand
'' ''
)); ));
$this->checkPermission($output);
do { do {
$connectionInfo = $this->getConnectionInfo($input, $output); $connectionInfo = $this->getConnectionInfo($input, $output);
} while(false === $connection = $this->tryConnection($connectionInfo, $output)); } while(false === $connection = $this->tryConnection($connectionInfo, $output));
@@ -82,6 +84,50 @@ class Install extends ContainerAwareCommand
)); ));
} }
protected function checkPermission(OutputInterface $output)
{
$output->writeln(array(
"Checking some permissions"
));
$confDir = THELIA_ROOT . "local/config";
$cacheDir = THELIA_ROOT . "cache";
$logDir = THELIA_ROOT . "log";
$conf = is_writable($confDir);
$cache = is_writable($cacheDir);
$log = is_writable($logDir);
$output->writeln(array(
sprintf(
"<info>config directory(%s)...</info> %s",
$confDir,
$conf ? "<info>Ok</info>" : "<error>Fail</error>"
),
sprintf(
"<info>cache directory(%s)...</info> %s"
,$cacheDir,
$cache ? "<info>Ok</info>" : "<error>Fail</error>"
),
sprintf(
"<info>log directory(%s)...</info> %s",
$logDir,
$log ? "<info>Ok</info>" : "<error>Fail</error>"
),
));
if ($conf === false || $cache === false || $log === false) {
$output->writeln(array(
"",
"<error>Please put correct permission and reload install process</error>"
));
exit;
}
}
protected function createConfigFile($connectionInfo) protected function createConfigFile($connectionInfo)
{ {
$fs = new Filesystem(); $fs = new Filesystem();

View File

@@ -118,18 +118,20 @@ class Thelia extends Kernel
$loader->load("config.xml"); $loader->load("config.xml");
$loader->load("routing.xml"); $loader->load("routing.xml");
$loader->load("action.xml"); $loader->load("action.xml");
if (defined("THELIA_INSTALL_MODE") === false) {
$modules = \Thelia\Model\ModuleQuery::getActivated();
$modules = \Thelia\Model\ModuleQuery::getActivated(); foreach ($modules as $module) {
foreach ($modules as $module) { try {
$loader = new XmlFileLoader($container, new FileLocator(THELIA_MODULE_DIR . "/" . ucfirst($module->getCode()) . "/Config"));
try { $loader->load("config.xml");
$loader = new XmlFileLoader($container, new FileLocator(THELIA_MODULE_DIR . "/" . ucfirst($module->getCode()) . "/Config")); } catch(\InvalidArgumentException $e) {
$loader->load("config.xml");
} catch(\InvalidArgumentException $e) {
}
} }
} }
} }
/** /**

View File

@@ -1,6 +0,0 @@
database:
connection:
driver: %DRIVER%
user: %USERNAME%
password: %PASSWORD%
dsn: %DSN%

0
log/.htaccess Normal file → Executable file
View File