diff --git a/Mage/Console.php b/Mage/Console.php
index 9d92b39..8c2c7c3 100644
--- a/Mage/Console.php
+++ b/Mage/Console.php
@@ -6,6 +6,7 @@ class Mage_Console
private $_actionOptions = null;
private $_environment = null;
private static $_log = null;
+ private static $_logEnabled = true;
public function setArgs($args)
{
@@ -23,6 +24,9 @@ class Mage_Console
} else if ($this->_args[0] == 'add') {
$this->_action = 'add';
+
+ } else if ($this->_args[0] == 'install') {
+ $this->_action = 'install';
} else if ($this->_args[0] == 'init') {
$this->_action = 'init';
@@ -72,7 +76,14 @@ class Mage_Console
}
public function run()
- {
+ {
+ // Disable Loging
+ if ($this->getAction() == 'install') {
+ self::$_logEnabled = false;
+ }
+
+ Mage_Console::output('Starting Magallanes', 0, 2);
+
$config = new Mage_Config;
$config->loadEnvironment($this->getEnvironment());
$config->loadSCM();
@@ -87,6 +98,11 @@ class Mage_Console
$task = new Mage_Task_Update;
$task->run($config);
break;
+
+ case 'install';
+ $task = new Mage_Task_Install;
+ $task->run();
+ break;
case 'init';
$task = new Mage_Task_Init;
@@ -102,15 +118,19 @@ class Mage_Console
}
break;
}
+
+ Mage_Console::output('Finished Magallanes', 0, 2);
}
public static function log($message, $continuation = false)
{
- if (self::$_log == null) {
- self::$_log = fopen('.mage/logs/log-' . date('Ymd-His') . '.log', 'w');
+ if (self::$_logEnabled) {
+ if (self::$_log == null) {
+ self::$_log = fopen('.mage/logs/log-' . date('Ymd-His') . '.log', 'w');
+ }
+
+ $message = date('Y-m-d H:i:s -- ') . $message;
+ fwrite(self::$_log, $message . PHP_EOL);
}
-
- $message = date('Y-m-d H:i:s -- ') . $message;
- fwrite(self::$_log, $message . PHP_EOL);
}
}
\ No newline at end of file
diff --git a/Mage/Task/Install.php b/Mage/Task/Install.php
new file mode 100644
index 0000000..fd0ea60
--- /dev/null
+++ b/Mage/Task/Install.php
@@ -0,0 +1,50 @@
+Magallanes... ', 1, 0);
+ $this->_recursiveCopy('./', '/opt/magallanes');
+ chmod('/opt/magallanes/bin/mage', 0755);
+ if (!file_exists('/usr/bin/mage')) {
+ symlink('/opt/magallanes/bin/mage', '/usr/bin/mage');
+ }
+ Mage_Console::output('Success!', 0, 2);
+ }
+
+ private function _recursiveCopy ($from, $to)
+ {
+ if (is_dir($from)) {
+ mkdir($to);
+ $files = scandir($from);
+
+ if (count($files) > 0) {
+ foreach ($files as $file) {
+ if (strpos($file, '.') === 0) {
+ continue;
+ }
+
+ if (is_dir($from . DIRECTORY_SEPARATOR . $file)) {
+ $this->_recursiveCopy(
+ $from . DIRECTORY_SEPARATOR . $file,
+ $to . DIRECTORY_SEPARATOR . $file
+ );
+
+ } else {
+ copy(
+ $from . DIRECTORY_SEPARATOR . $file,
+ $to . DIRECTORY_SEPARATOR . $file
+ );
+ }
+ }
+ }
+ return true;
+
+ } elseif (is_file($from)) {
+ return copy($from, $to);
+
+ } else {
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/bin/mage.php b/bin/mage.php
index 13b6b5a..67b3a51 100644
--- a/bin/mage.php
+++ b/bin/mage.php
@@ -24,12 +24,8 @@ $baseDir = dirname(dirname(__FILE__));
require_once $baseDir . '/Mage/Autoload.php';
spl_autoload_register(array('Mage_Autoload', 'autoload'));
-Mage_Console::output('Starting Magallanes', 0, 2);
-
$console = new Mage_Console;
$console->setArgs($argv);
$console->parse();
$console->run();
-
-Mage_Console::output('Finished Magallanes', 0, 2);