Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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