Skip to content

Instantly share code, notes, and snippets.

@mtimkovich
Created June 6, 2012 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtimkovich/2879629 to your computer and use it in GitHub Desktop.
Save mtimkovich/2879629 to your computer and use it in GitHub Desktop.
CodeIgniter New Project Generator
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 [app]"
exit
fi
cache_dir="$XDG_CONFIG_HOME/codeigniter"
if [ ! -d $cache_dir ]; then
mkdir -p $cache_dir || exit 1
fi
original_dir=$PWD
download='http://www.codeigniter.com/download.php'
cd $cache_dir
file=$(curl -LI --max-redirs 1 $download 2>/dev/null | grep Location | tail -1 | sed 's#.*/##;s#\r##') || exit 1
folder=$(echo $file | sed 's/\.zip$//')
if [ -z $(echo "$file" | grep 'CodeIgniter') ]; then
echo 'Error downloading CodeIgniter' 1>&2
exit
fi
if [ ! -f $file ]; then
wget --trust-server-names $download || exit 1
unzip $file || exit 1
fi
cd $original_dir
cp -rn "$cache_dir/$folder" "$1" || exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment