Changeset 19

Show
Ignore:
Timestamp:
09/20/07 18:58:22 (1 year ago)
Author:
bermi
Message:

Updating command line installer

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/install.php

    r15 r19  
    22 
    33/** 
    4 * This command line script will setup an Editam site given the configuration parameters 
    5 
    6 *   Application name:  
     4* This installer allows you to create editam site from the command line programatically. 
     5*  
     6* php install.php --database_host localhost --database_name editam  --database_password pass --database_user root --database_type mysql --email bermi@example.com --locales en es --login bermi --password bermipass --path  /Users/bermi/Sites/editam --site_name "Editam Demo"  --url_suffix /editam 
     7*  
     8* Configuration files might be either a php file with an $options array like: 
     9*  
     10* <?php 
     11*  
     12* $options = array ( 
     13*   'database_host' => 'localhost', 
     14*   'database_name' => 'editam', 
     15*   'database_password' => 'pass', 
     16*   'database_user' => 'root', 
     17*   'database_type' => 'mysql', 
     18*   'email' => 'bermi@example.com', 
     19*   'locales' =>  
     20*   array ( 
     21*     0 => 'en', 
     22*     1 => 'es', 
     23*   ), 
     24*   'login' => 'bermi', 
     25*   'password' => 'bermipass', 
     26*   'path' => '/Users/bermi/Sites/editam', 
     27*   'site_name' => 'Editam Demo', 
     28*   'url_suffix' => '/editam', 
     29* ); 
     30*  
     31* ?> 
     32*  
     33* Using a PHP configuration file might allow you to add post install actions like fixing path permissions using register_shutdown_function() or implementing a function named after_editam_install() 
     34*  
     35* If your configuration file extension is YAML or txt it will need to be YAML compliant like: 
     36*  
     37* database_host: localhost 
     38* database_name: editam 
     39* database_password: pass 
     40* database_user: root 
     41* database_type: mysql 
     42* email: bermi@example.com 
     43* locales:  
     44*   - en 
     45*   - es 
     46* login: bermi 
     47* password: bermipass 
     48* path: /Users/bermi/Sites/editam 
     49* site_name: Editam Demo 
     50* url_suffix: /editam 
    751*/ 
     52 
     53 
    854require_once('utils/akelos_framework.php'); 
    955set_time_limit(0); 
     
    1662'path' => array( 
    1763'short'   => 'p', 
    18 'max'     => 0, 
    19 'min'     => 0, 
    20 'default' => false, 
     64'max'     => 1, 
     65'min'     => 1, 
    2166'desc'    => 'Location where the application will be accesed by the webserver.'), 
    2267 
     
    2469'site_name' => array( 
    2570'short'   => 's', 
    26 'max'     => 0, 
    27 'min'     => 0, 
     71'max'     => 1, 
     72'min'     => 1, 
     73'default' => 'My new Editam Site', 
    2874'desc'    => 'Site name.'), 
    2975 
     
    3379'login' => array( 
    3480'short'   => 'l', 
    35 'max'     => 0, 
    36 'min'     => 0, 
     81'max'     => 1, 
     82'min'     => 1, 
     83'default' => 'admin', 
    3784'desc'    => 'Administrator login.'), 
    3885 
    3986'password' => array( 
    4087'short'   => 'pass', 
    41 'max'     => 0, 
    42 'min'     => 0, 
     88'max'     => 1, 
     89'min'     => 1, 
     90'default' => Ak::randomString(6), 
    4391'desc'    => 'Administrator password.'), 
    4492 
    4593'email' => array( 
    4694'short'   => 'e', 
    47 'max'     => 0
    48 'min'     => 0
     95'max'     => 1
     96'min'     => 1
    4997'desc'    => 'Administrator email.'), 
    5098 
     
    52100// Database 
    53101 
    54 'host' => array( 
     102'database_host' => array( 
     103'short'   => 'dbh', 
     104'max'     => 1, 
     105'min'     => 1, 
     106'default' => 'localhost', 
     107'desc'    => 'Database host.'), 
     108 
     109'database_user' => array( 
     110'short'   => 'dbu', 
     111'max'     => 1, 
     112'min'     => 1, 
     113'desc'    => 'Database user.'), 
     114 
     115'database_name' => array( 
     116'short'   => 'dbn', 
     117'max'     => 1, 
     118'min'     => 1, 
     119'default' => 'editam', 
     120'desc'    => 'Database password.'), 
     121 
     122'database_password' => array( 
     123'short'   => 'dbp', 
     124'max'     => 1, 
     125'min'     => 1, 
     126'desc'    => 'Database password.'), 
     127 
     128 
     129'database_type' => array( 
     130'short'   => 'dbt', 
     131'max'     => 1, 
     132'min'     => 1, 
     133'default' => 'mysql', 
     134'desc'    => 'Database type.'), 
     135 
     136 
     137'url_suffix' => array( 
     138'short'   => 'url', 
     139'max'     => 1, 
     140'min'     => 1, 
     141'desc'    => 'Url suffix.'), 
     142 
     143'locales' => array( 
     144'short'   => 'lc', 
     145'max'     => 8, 
     146'min'     => 1, 
     147'default' => 'en', 
     148'desc'    => 'Locales.'), 
     149 
     150'config' => array( 
     151'short'   => 'c', 
     152'max'     => 1, 
     153'min'     => 1, 
     154'desc'    => 'Use a configuration file for getting the installer values.'), 
     155 
     156'ftp_user' => array( 
     157'short'   => 'fu', 
     158'max'     => 1, 
     159'min'     => 0, 
     160'desc'    => 'FTP user name.'), 
     161 
     162'ftp_password' => array( 
     163'short'   => 'fp', 
     164'max'     => 1, 
     165'min'     => 1, 
     166'desc'    => 'FTP password.'), 
     167 
     168'ftp_host' => array( 
     169'short'   => 'fh', 
     170'max'     => 1, 
     171'min'     => 1, 
     172'desc'    => 'FTP host.'), 
     173 
     174 
     175'ftp_path' => array( 
     176'short'   => 'fd', 
     177'max'     => 1, 
     178'min'     => 1, 
     179'desc'    => 'FTP path.'), 
     180 
     181'help' => array( 
    55182'short'   => 'h', 
    56183'max'     => 0, 
    57184'min'     => 0, 
    58 'desc'    => 'Database host.'), 
    59  
    60 'db_user' => array( 
    61 'short'   => 'dbu', 
    62 'max'     => 0, 
    63 'min'     => 0, 
    64 'desc'    => 'Database user.'), 
    65  
    66 'db_password' => array( 
    67 'short'   => 'dbp', 
    68 'max'     => 0, 
    69 'min'     => 0, 
    70 'desc'    => 'Database password.'), 
    71  
     185'desc'    => 'Show this help message.'), 
    72186 
    73187 
     
    94208'default' => 'false', 
    95209'desc'    => 'Suppress normal output.'), 
    96  
    97 'config' => array( 
    98 'short'   => 'c', 
    99 'max'     => 0, 
    100 'min'     => 0, 
    101 'desc'    => 'Use a configuration file for getting the installer values.'), 
    102  
    103 'help' => array( 
    104 'short'   => 'h', 
    105 'max'     => 0, 
    106 'min'     => 0, 
    107 'desc'    => 'Show this help message.'), 
    108210 
    109211); 
     
    123225$options = $args->getValues(); 
    124226 
    125 if(empty($options)){ 
     227if(!empty($options['config'])){ 
     228    if(file_exists($options['config'])){ 
     229        $extension = array_pop(pathinfo($options['config'])); 
     230        $config_file = $options['config']; 
     231        $cmd_options = $options; 
     232        $options = array(); 
     233        if($extension == 'php'){ 
     234            include_once($config_file); 
     235        }elseif($extension == 'txt' || $extension == 'yaml'){ 
     236            $options = Ak::convert('yaml','array', file_get_contents($config_file)); 
     237        }else{ 
     238            echo "Unrecognized configuration format {$config_file}. Please use the extension php or txt.\n"; 
     239        } 
     240    }else{ 
     241        echo "Could not find configuration file {$config_file}\n"; 
     242    } 
     243
     244 
     245if(empty($options) || (empty($options['path']) && empty($config_file))){ 
    126246    echo Console_Getargs::getHelp($config)."\n"; 
    127247    exit; 
    128248} 
    129249 
    130 print_r($options); 
    131  
     250if(!empty($cmd_options)){ 
     251    $options = array_merge($cmd_options, $options); 
     252
     253 
     254if(!empty($options['quiet'])){ 
     255    ob_start(); 
     256
     257 
     258// Check if destination path exists 
     259if(count(Ak::dir($options['path'])) > 0 && empty($options['force'])){ 
     260    echo "Destination directory ({$options['path']}) is not empty. Please add --force if you want to override existing contents.\n"; 
     261    return; 
     262
     263 
     264// Build a release 
     265echo "Building latest release.\n"; 
     266$build_serults = (`./makelos.php`); 
     267if(preg_match('/builds\/(.+)\.zip/', $build_serults, $match)){ 
     268    echo "Will use {$match[1]}\n"; 
     269
     270 
     271// Unpack release and move to the setup path 
     272echo "Unpacking builds/{$match[1]}.tar.gz and moving it to {$options['path']}\n"; 
     273if(!is_dir(AK_BASE_DIR."/build/builds/{$match[1]}")){ 
     274    (`tar -zxvf builds/{$match[1]}.tar.gz -C ./builds`); 
     275
     276(`cp -Rf builds/{$match[1]}/ {$options['path']}`); 
     277 
     278// Create temporary settings file 
     279file_put_contents("{$options['path']}/config/setup_options.txt", Ak::convert('array','yaml',$options)); 
     280 
     281// Run the editam setup against temp settings 
     282 
     283/* 
     284Ak::import('editam_setup'); 
     285$EditamSetup =& new EditamSetup(); 
     286$configuration_file = $EditamSetup->getConfigurationFile(); 
     287$EditamSetup->writeConfigurationFile($configuration_file); 
     288$EditamSetup->writeRoutesFile(); 
     289$EditamSetup->runEditamInstaller(); 
     290if($EditamSetup->hasUrlSuffix()){ 
     291    $EditamSetup->modifyHtaccessFiles(); 
     292
     293$EditamSetup->relativizeStylesheetPaths(); 
     294*/ 
     295// Remove tmp settings 
     296 
     297 
     298if(function_exists('after_editam_install')){ 
     299    after_editam_install($options); 
     300
     301 
     302if(!empty($options['quiet'])){ 
     303    ob_end_clean(); 
     304
    132305 
    133306?> 
  • trunk/build/makelos.php

    r14 r19  
     1#!/usr/bin/env php 
    12<?php 
    23 
     
    1819} 
    1920 
     21$new_version = $major_version.'.'.$minor_version.($release_type == 'stable'?'':".$revision"); 
     22$version_tag = $release_type.'-'.$new_version; 
     23 
    2024$prefix = ''; 
    2125$working_copy_status = trim(exec("svn status $repository")); 
     
    2428    echo "Generated release will be prefixed with 'my-'\n"; 
    2529    $prefix = 'my-'; 
     30}elseif(file_exists(AK_BASE_DIR."/build/builds/editam-$new_version".($release_type == 'stable'?'':'-'.$release_type).'.zip')){ 
     31    echo "Existing build found at /builds/editam-$new_version".($release_type == 'stable'?'':'-'.$release_type).".tar.gz\n"; 
     32    echo "Existing build found at /builds/editam-$new_version".($release_type == 'stable'?'':'-'.$release_type).".zip\n"; 
     33    echo "Done! look into ".AK_BASE_DIR."/build/builds/ to find your releases\n"; 
     34    return; 
    2635} 
    27  
    28 $new_version = $major_version.'.'.$minor_version.($release_type == 'stable'?'':".$revision"); 
    29 $version_tag = $release_type.'-'.$new_version; 
    3036 
    3137echo "Exporting Editam.\n";