Skip to content

Instantly share code, notes, and snippets.

@jackmcpickle
Last active July 11, 2017 16:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackmcpickle/0da0aa769e77ce490ab9 to your computer and use it in GitHub Desktop.
Save jackmcpickle/0da0aa769e77ce490ab9 to your computer and use it in GitHub Desktop.
manually update craft cms
#!/bin/bash
################################################################
# craft-update
# Searches and cleans latest craftcms url from craftcms.com
# Downloads and replaces existing craft app folder
# Also checks you agree to craftcms terms
################################################################
set -e
# Check that path to craft folder is there
if [ "$#" -ne 1 ]
then
echo "USAGE: craft-update [path/to/craft_folder]"
echo "Please use by passing the path to the craft folder without trailing slash"
exit 1
fi
# Check terms
read -p "Do you agree to craft's terms? - https://craftcms.com/license (y/n)" agreeTerms
if [ "$agreeTerms" != "y" ]
then
echo "Sorry, please agree to the terms before downloading."
exit 1
fi
# Download the latest Craft, save as craft.zip in current folder
wget https://craftcms.com/latest.zip?accept_license=yes -O "$1/craft.zip"
# Extract just the craft directory out of the archive, quietly
unzip -d $1 -qq "$1/craft.zip" 'craft/app/*'
# Swap in new app folder
mv "$1/app" "$1/app_old"
mv "$1/craft/app" "$1/app"
# Cleanup
rmdir "$1/craft"
rm -rf "$1/app_old"
rm "$1/craft.zip"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment