mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-10-30 23:10:16 +01:00 
			
		
		
		
	Added the Install feature.
This commit is contained in:
		
							parent
							
								
									622150b875
								
							
						
					
					
						commit
						1349f296c0
					
				| @ -6,6 +6,7 @@ class Mage_Console | |||||||
|     private $_actionOptions = null; |     private $_actionOptions = null; | ||||||
|     private $_environment = null; |     private $_environment = null; | ||||||
|     private static $_log = null; |     private static $_log = null; | ||||||
|  |     private static $_logEnabled = true; | ||||||
|      |      | ||||||
|     public function setArgs($args) |     public function setArgs($args) | ||||||
|     { |     { | ||||||
| @ -23,6 +24,9 @@ class Mage_Console | |||||||
| 
 | 
 | ||||||
|             } else if ($this->_args[0] == 'add') { |             } else if ($this->_args[0] == 'add') { | ||||||
|                 $this->_action = 'add'; |                 $this->_action = 'add'; | ||||||
|  |                  | ||||||
|  |             } else if ($this->_args[0] == 'install') { | ||||||
|  |                 $this->_action = 'install'; | ||||||
| 
 | 
 | ||||||
|             } else if ($this->_args[0] == 'init') { |             } else if ($this->_args[0] == 'init') { | ||||||
|                 $this->_action = 'init'; |                 $this->_action = 'init'; | ||||||
| @ -72,7 +76,14 @@ class Mage_Console | |||||||
|     } |     } | ||||||
|      |      | ||||||
|     public function run() |     public function run() | ||||||
|     {        |     { | ||||||
|  |         // Disable Loging
 | ||||||
|  |         if ($this->getAction() == 'install') { | ||||||
|  |             self::$_logEnabled = false; | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         Mage_Console::output('Starting <blue>Magallanes</blue>', 0, 2); | ||||||
|  |          | ||||||
|         $config = new Mage_Config; |         $config = new Mage_Config; | ||||||
|         $config->loadEnvironment($this->getEnvironment()); |         $config->loadEnvironment($this->getEnvironment()); | ||||||
|         $config->loadSCM(); |         $config->loadSCM(); | ||||||
| @ -87,6 +98,11 @@ class Mage_Console | |||||||
|                 $task = new Mage_Task_Update; |                 $task = new Mage_Task_Update; | ||||||
|                 $task->run($config); |                 $task->run($config); | ||||||
|                 break; |                 break; | ||||||
|  | 
 | ||||||
|  |             case 'install'; | ||||||
|  |                 $task = new Mage_Task_Install; | ||||||
|  |                 $task->run(); | ||||||
|  |                 break; | ||||||
|                  |                  | ||||||
|             case 'init'; |             case 'init'; | ||||||
|                 $task = new Mage_Task_Init; |                 $task = new Mage_Task_Init; | ||||||
| @ -102,15 +118,19 @@ class Mage_Console | |||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
|         } |         } | ||||||
|  |          | ||||||
|  |         Mage_Console::output('Finished <blue>Magallanes</blue>', 0, 2); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public static function log($message, $continuation = false) |     public static function log($message, $continuation = false) | ||||||
|     { |     { | ||||||
|         if (self::$_log == null) { |         if (self::$_logEnabled) { | ||||||
|             self::$_log = fopen('.mage/logs/log-' . date('Ymd-His') . '.log', 'w'); |             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); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
							
								
								
									
										50
									
								
								Mage/Task/Install.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								Mage/Task/Install.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,50 @@ | |||||||
|  | <?php | ||||||
|  | class Mage_Task_Install | ||||||
|  | { | ||||||
|  |     public function run () | ||||||
|  |     { | ||||||
|  |         Mage_Console::output('Installing <dark_gray>Magallanes</dark_gray>... ', 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('<light_green>Success!</light_green>', 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; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -24,12 +24,8 @@ $baseDir = dirname(dirname(__FILE__)); | |||||||
| require_once $baseDir . '/Mage/Autoload.php'; | require_once $baseDir . '/Mage/Autoload.php'; | ||||||
| spl_autoload_register(array('Mage_Autoload', 'autoload')); | spl_autoload_register(array('Mage_Autoload', 'autoload')); | ||||||
| 
 | 
 | ||||||
| Mage_Console::output('Starting <blue>Magallanes</blue>', 0, 2); |  | ||||||
| 
 |  | ||||||
| $console = new Mage_Console; | $console = new Mage_Console; | ||||||
| $console->setArgs($argv); | $console->setArgs($argv); | ||||||
| $console->parse(); | $console->parse(); | ||||||
| 
 | 
 | ||||||
| $console->run(); | $console->run(); | ||||||
| 
 |  | ||||||
| Mage_Console::output('Finished <blue>Magallanes</blue>', 0, 2); |  | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user