mirror of
https://github.com/hauke68/Magallanes.git
synced 2025-09-13 12:40:18 +02:00
Address issue #3. Allow install in a custom directory. By default no root user is checked.
This commit is contained in:
parent
f8476197ac
commit
001fa82c51
@ -5,19 +5,54 @@ class Mage_Command_BuiltIn_Install
|
|||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
Mage_Console::output('Installing <dark_gray>Magallanes</dark_gray>... ', 1, 0);
|
Mage_Console::output('Installing <dark_gray>Magallanes</dark_gray>... ', 1, 0);
|
||||||
$this->_recursiveCopy('./', '/opt/magallanes-' . MAGALLANES_VERSION);
|
|
||||||
|
|
||||||
if (file_exists('/opt/magallanes') && is_link('/opt/magallanes')) {
|
// Vars
|
||||||
unlink('/opt/magallanes');
|
$installDir = $this->getConfig()->getParameter('installDir', '/opt/magallanes');
|
||||||
|
$systemWide = $this->getConfig()->getParameter('systemWide', false);
|
||||||
|
|
||||||
|
// Clean vars
|
||||||
|
$baseDir = realpath(dirname($installDir));
|
||||||
|
$installDir = basename($installDir);
|
||||||
|
|
||||||
|
// Check if install dir is available
|
||||||
|
if (!is_dir($baseDir) || !is_writable($baseDir)) {
|
||||||
|
Mage_Console::output('<red>Failure: install directory is invalid.</red>', 0, 2);
|
||||||
|
|
||||||
|
// Chck if it is a system wide install the user is root
|
||||||
|
} else if ($systemWide && (getenv('LOGNAME') != 'root')) {
|
||||||
|
Mage_Console::output('<red>Failure: you have to be root to perform a system wide install.</red>', 0, 2);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$destinationDir = $baseDir . '/' . $installDir;
|
||||||
|
if (!is_dir($destinationDir)) {
|
||||||
|
mkdir($destinationDir);
|
||||||
}
|
}
|
||||||
symlink('/opt/magallanes-' . MAGALLANES_VERSION, '/opt/magallanes');
|
|
||||||
chmod('/opt/magallanes/bin/mage', 0755);
|
// Copy
|
||||||
|
$this->_recursiveCopy('./', $destinationDir . '/' . MAGALLANES_VERSION);
|
||||||
|
|
||||||
|
// Check if there is already a symlink
|
||||||
|
if (file_exists($destinationDir . '/' . 'latest')
|
||||||
|
&& is_link($destinationDir . '/' . 'latest')) {
|
||||||
|
unlink($destinationDir . '/' . 'latest');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create "latest" symlink
|
||||||
|
symlink(
|
||||||
|
$destinationDir . '/' . MAGALLANES_VERSION,
|
||||||
|
$destinationDir . '/' . 'latest'
|
||||||
|
);
|
||||||
|
chmod($destinationDir . '/' . MAGALLANES_VERSION . '/bin/mage', 0755);
|
||||||
|
|
||||||
|
if ($systemWide) {
|
||||||
if (!file_exists('/usr/bin/mage')) {
|
if (!file_exists('/usr/bin/mage')) {
|
||||||
symlink('/opt/magallanes/bin/mage', '/usr/bin/mage');
|
symlink($destinationDir . '/latest/bin/mage', '/usr/bin/mage');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Mage_Console::output('<light_green>Success!</light_green>', 0, 2);
|
Mage_Console::output('<light_green>Success!</light_green>', 0, 2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function _recursiveCopy($from, $to)
|
private function _recursiveCopy($from, $to)
|
||||||
{
|
{
|
||||||
|
22
bin/mage
22
bin/mage
@ -1,9 +1,19 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/env php
|
||||||
#VERSION:0.9.14
|
<?php
|
||||||
|
date_default_timezone_set('UTC');
|
||||||
|
|
||||||
SCRIPT=$(readlink -f $0)
|
$baseDir = dirname(dirname(__FILE__));
|
||||||
DIR=$(dirname $SCRIPT)
|
|
||||||
PHP_BIN=$(which php)
|
|
||||||
|
|
||||||
$PHP_BIN -d safe_mode=Off -f $DIR/mage.php -- $@
|
define('MAGALLANES_VERSION', '0.9.14');
|
||||||
|
|
||||||
|
// Preload
|
||||||
|
require_once $baseDir . '/Mage/spyc.php';
|
||||||
|
require_once $baseDir . '/Mage/Autoload.php';
|
||||||
|
spl_autoload_register(array('Mage_Autoload', 'autoload'));
|
||||||
|
|
||||||
|
// Clean arguments
|
||||||
|
array_shift($argv);
|
||||||
|
|
||||||
|
// Run Magallanes
|
||||||
|
$console = new Mage_Console;
|
||||||
|
$console->run($argv);
|
||||||
|
Loading…
Reference in New Issue
Block a user