Skip to content

Instantly share code, notes, and snippets.

@1stevengrant
Created August 27, 2011 22:02
Show Gist options
  • Save 1stevengrant/1175912 to your computer and use it in GitHub Desktop.
Save 1stevengrant/1175912 to your computer and use it in GitHub Desktop.
EE upgrade shell
##########################################################################################
#!/bin/bash
# File: set_exp_permissions.sh
# Description: Performs an upgrade on a ExpressionEngine install for EE 2.x
##########################################################################################
# First we need to get the current working directory
DIR=$(pwd)
# If we can't find the file/folder required, this is the message we're displaying
ERR_MSG="Sorry, File/Folder Not found :"
# Ok - First, Lets ask the user what their system folder is.
printf "Enter the name of your current system folder: "
read CURRENT_SYSTEM
# Ok - Lets ask the user what their new system folder is.
printf "Enter the name of your new system folder: "
read NEW_SYSTEM
# Ok - First, Lets ask the user what their themes folder is.
printf "Enter the name of your current themes folder: "
read CURRENT_THEMES
# Ok - Lets ask the user what their new themes folder is.
printf "Enter the name of your new themes folder: "
read NEW_THEMES
# Ok - First, Lets ask the user what their images folder is.
printf "Enter the name of your current images folder: "
read CURRENT_IMAGES
# Ok - Lets ask the user what their new images folder is.
printf "Enter the name of your new images folder: "
read NEW_IMAGES
# Now we're going to copy across everything that we need - we're going to make an assumption that it's a normal upgrade process.
printf "******************************\n"
printf " Starting Upgrade Process \n"
printf "******************************\n"
printf " Copying config.php..."
cp $DIR/$CURRENT_SYSTEM/expressionengine/config/config.php $DIR/$NEW_SYSTEM/expressionengine/config/config.php
printf " - DONE\n"
printf " Copying database.php..."
cp $DIR/$CURRENT_SYSTEM/expressionengine/config/database.php $DIR/$NEW_SYSTEM/expressionengine/config/database.php
printf " - DONE \n"
printf " Copying Templates Folder..."
cp -R $DIR/$CURRENT_SYSTEM/expressionengine/templates $DIR/$NEW_SYSTEM/expressionengine/
printf " - DONE \n"
printf " Copying Third Party Folder..."
cp -p -R $DIR/$CURRENT_SYSTEM/expressionengine/third_party $DIR/$NEW_SYSTEM/expressionengine/
printf " - DONE \n"
printf " Copying Third Party Themes..."
cp -p -R $DIR/$CURRENT_THEMES/third_party $DIR/$NEW_THEMES/
printf " - DONE \n"
printf " Copying Image Uploads Folder..."
cp -p -R $DIR/$CURRENT_IMAGES/uploads $DIR/$NEW_IMAGES/
printf " - DONE \n"
if [ -e $DIR/$CURRENT_IMAGES/sized ]
then
printf " Detected and Copying Image Resizer Cached/Sized Folder..."
cp -p -R $DIR/$CURRENT_IMAGES/sized $DIR/$NEW_IMAGES/
printf " - DONE \n"
fi
if [ -e $DIR/$CURRENT_THEMES/matrix ]
then
printf " Detected and Copying Matrix Themes Folder..."
cp -p -R $DIR/$CURRENT_THEMES/matrix $DIR/$NEW_THEMES/
printf " - DONE \n"
fi
if [ -e $DIR/$CURRENT_THEMES/wygwam ]
then
printf " Detected and Copying Wygwam Themes Folder..."
cp -p -R $DIR/$CURRENT_THEMES/wygwam $DIR/$NEW_THEMES/
printf " - DONE \n"
fi
printf "******************************\n"
printf " COMPLETE! \n"
printf "******************************\n"
printf "\n Assuming the copying didn't generate any errors,\n"
printf "we can now backup your existing folders, promote the new ones and \n"
printf "then set all permissions. Would you like us to do that? (Enter 'y' or 'n'): "
read BACKUP
if [ "$BACKUP" == "y" ]
then
mv $DIR/$CURRENT_SYSTEM $DIR/$CURRENT_SYSTEM-backup
mv $DIR/$NEW_SYSTEM $DIR/$CURRENT_SYSTEM
mv $DIR/$CURRENT_THEMES $DIR/$CURRENT_THEMES-backup
mv $DIR/$NEW_THEMES $DIR/$CURRENT_THEMES
mv $DIR/$CURRENT_IMAGES $DIR/$CURRENT_IMAGES-backup
mv $DIR/$NEW_IMAGES $DIR/$CURRENT_IMAGES
printf "\n\nBackup Completed - All original folders appended with '-backup'\n"
printf "Now setting file permissions\n"
V2_666[0]=$DIR/$CURRENT_SYSTEM/expressionengine/config/database.php
V2_666[1]=$DIR/$CURRENT_SYSTEM/expressionengine/config/config.php
V2_777[0]=$DIR/images/avatars/uploads/
V2_777[1]=$DIR/images/captchas/
V2_777[2]=$DIR/images/member_photos/
V2_777[3]=$DIR/images/pm_attachments/
V2_777[4]=$DIR/images/signature_attachments/
V2_777[5]=$DIR/images/uploads/
V2_777[6]=$DIR/$CURRENT_SYSTEM/expressionengine/cache/
V2_777[7]=$DIR/themes/
# Check files and change permissions
for FILE in ${V2_666[@]}
do
if [ -e $FILE ]
then
chmod 666 $FILE
else
printf "$ERR_MSG $FILE\n"
err="1"
fi
done
# Check directories and change permissions
for DIR in ${V2_777[@]}
do
if [ -d $DIR ]
then
chmod -R 777 $DIR
else
printf "$ERR_MSG $DIR\n"
err="1"
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment