Skip to content

Instantly share code, notes, and snippets.

@timknight
Created July 16, 2017 23:56
Show Gist options
  • Save timknight/41241d1c933c09b8b8b765c213b96789 to your computer and use it in GitHub Desktop.
Save timknight/41241d1c933c09b8b8b765c213b96789 to your computer and use it in GitHub Desktop.
Installation Script for Craft CMS 2.x Setups
if [[ $# -eq 0 ]]; then
project=${PWD##*/}
elif [[ $# -eq 1 ]]; then
project=$1
mkdir $project && cd $project
else
echo "Usage:"
echo -e '\tType "craft [project]" to create a project with a specific name'
echo -e '\tType "craft" within a blank project folder to take that folder as the project name'
exit 1
fi
# Download the latest version of Craft and unzip it
wget -O latest.zip https://craftcms.com/latest.zip?accept_license=yes
unzip -q latest.zip
rm latest.zip
echo " ✅ Craft CMS Download"
# Remove the readme file
rm readme.txt
# Rename the .htaccess file and cleanup unnecessary files
mv public/htaccess public/.htaccess
echo " ✅ Renamed .htaccess file"
rm public/web.config
rm craft/web.config
rm craft/.htaccess
rm craft/config/web.config
rm craft/config/.htaccess
rm craft/plugins/.htaccess
rm craft/plugins/web.config
rm craft/storage/.htaccess
rm craft/storage/web.config
rm -R craft/templates/
mkdir craft/templates/
echo " ✅ Removed unneeded files and emptied templates"
# Setup file permissions
chmod 774 craft/app/
chmod 774 craft/config/
chmod 774 craft/storage/
echo " ✅ Set Craft CMS folder permissions"
echo "-----------------------------------"
echo "Please provide your MySQL password."
echo "-----------------------------------"
/Applications/MAMP/Library/bin/mysql -u root -p -e "CREATE DATABASE \`$project\` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci;"
echo " ✅ Database for '${project}' created"
echo " ✅ Your project has been created"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment