Skip to content

Commit

Permalink
Update installer.php
Browse files Browse the repository at this point in the history
  • Loading branch information
eriktorsner committed Dec 11, 2012
1 parent 5ec6620 commit b93528c
Showing 1 changed file with 77 additions and 13 deletions.
90 changes: 77 additions & 13 deletions installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,80 @@
*/
function process($argv)
{
//$help = in_array('--help', $argv);
/**
* 1. Get the archive from Ellis
* 2. Unzip it
* 3. Go in and add the 'localsettings' hack
* 4. Download the CI
*
*/
$cmd = 'curl -sL http://ellislab.com/codeigniter/download > ci.zip';
exec $cmd;


}

// Settings
$repo = 'eriktorsner/codeigniterbootstrap';
$apiurl = 'https://api.github.com';
$gitfileurl = 'https://raw.github.com';

// Get the latest CI
echo "Fetching latest CodeIgniter from Ellislab....\n";
$cmd = "curl -sL http://ellislab.com/codeigniter/download > ci.zip";
exec($cmd);

// Unzip it
echo "Unzipping.\n";
$cmd = "unzip ci.zip";
exec($cmd);

// Remove archive
echo "Cleaning up download\n";
$cmd = "rm -rf ci.zip";
exec($cmd);

// get the CI path into a var:
$ci_folder = "";
$cur_folder = scandir(".");
foreach($cur_folder as $file)
{
if(substr($file, 0, 13) == "CodeIgniter_2")
{
$ci_folder = $file;
break;
}
}
echo "CodeIgniter downloaded into $ci_folder \n";

// Get list of mods to run into an array
$mods = array();
$github_cmd = "$apiurl/repos/$repo/contents";
$content = get_content_from_github($github_cmd);
foreach($content as $file)
{
if($file['type'] == "file"
&& substr($file['name'],-4) == ".mod")
{
$mod = array();
$mod["name"] = $file["name"];
$mod["path"] = $file["path"];
$mods[] = $mod;

$f = $mod["name"];
$cmd = "curl -sL $gitfileurl/$repo/master/$f > $f";
exec($cmd);

// Execute the code in the mod... careful about
// recreating function names etc....
echo "Applying mod: $f\n";
require_once($f);
unlink($f);

}
}
echo "All mod's have executed. Done!\n\n";
}


function get_content_from_github($url) {
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1);
$content = curl_exec($ch);
curl_close($ch);
return json_decode($content, true);
}




0 comments on commit b93528c

Please sign in to comment.