Created
January 4, 2012 17:16
-
-
Save joshuamorse/1561042 to your computer and use it in GitHub Desktop.
Project Install Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
/** | |
* A simple script to get newly-cloned project up and running quickly. | |
* | |
* The general idea: we spend lots of time copying files/creating dirs | |
* when setting up new projects. This script will do most all of that for us. | |
* | |
* @author Joshua Morse <[email protected]> | |
*/ | |
$dirs = array( | |
'../_site', | |
); | |
$files = array( | |
'../_config.yml.dist', | |
); | |
$permissions = array( | |
777 => array( | |
$dirs[0], | |
), | |
); | |
$commands = array( | |
'git submodule update --init --recursive', | |
); | |
define('EXAMPLE_EXTENSION', '.dist'); | |
if (isset($dirs)) { | |
echo "> Creating dirs...\n"; | |
foreach ($dirs as $dir) { | |
$dir = __DIR__.'/'.$dir; | |
if (!file_exists($dir) && !is_dir($dir)) { | |
mkdir($dir); | |
} | |
} | |
} | |
if (isset($files)) { | |
echo "> Setting up .dist files...\n"; | |
foreach ($files as $file) { | |
$file = __DIR__.'/'.$file; | |
if (file_exists($file)) { | |
copy($file, str_replace(EXAMPLE_EXTENSION, '', $file)); | |
} | |
} | |
} | |
if (isset($permissions)) { | |
echo "> Setting up permissions...\n"; | |
foreach ($permissions as $permission => $files) { | |
foreach ($files as $file) { | |
$file = __DIR__.'/'.$file; | |
if (file_exists($file)) { | |
system(sprintf('chmod %s %s', $permission, $file)); | |
} | |
} | |
} | |
} | |
if (isset($commands)) { | |
echo "> Running commands...\n"; | |
foreach ($commands as $command) { | |
system($command); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment