Skip to content

Instantly share code, notes, and snippets.

@jesusOmar
Created June 26, 2013 22:56
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 jesusOmar/5872501 to your computer and use it in GitHub Desktop.
Save jesusOmar/5872501 to your computer and use it in GitHub Desktop.
My development server automatic update script.
#!/bin/bash
DOCUMENT_ROOT=/var/www/html/vhosts/dev.domain.com;
ENV=dev;
SVN_SERVER=https://subversion.assembla.com/svn/repo/trunk;
SVN_USERNAME=username;
SVN_PASSWORD=password;
echo "Changing directories to $DOCUMENT_ROOT...";
cd $DOCUMENT_ROOT;
# Check the servers revision number:
echo "Checking the server revision...";
SERVER_REVISION=`svn info --username $SVN_USERNAME --password $SVN_PASSWORD $SVN_SERVER | grep Revision: | sed 's .\{10\} '`;
echo "Server at revision $SERVER_REVISION";
echo "Checking the working copy revision...";
LOCAL_REVISION=`svn info | grep Revision: | sed 's .\{10\} '`;
echo "Working copy at revision $LOCAL_REVISION";
if [[ "$SERVER_REVISION" == "$LOCAL_REVISION" ]]; then
echo "Server is up to date. Nothing to do.";
else
echo "Running SVN update. Please wait...";
svn update --username $SVN_USERNAME --password $SVN_PASSWORD;
COMPOSER_CHANGED=`svn diff -r $LOCAL_REVISION:$SERVER_REVISION composer.lock`;
if [[ "$COMPOSER_CHANGED" == "" ]]; then
echo "Vendors update not needed...";
else
echo "Vendors needs updating...";
echo "Running composer.phar install. This might take a minute or two...";
./composer.phar install;
fi
echo "Running assetic dump...";
./app/console assetic:dump --env=$ENV --no-debug;
echo "Installing assets...";
./app/console assets:install --symlink;
echo "Clearing the cache...";
./app/console cache:clear --env=$ENV --no-debug;
echo "Warming up the cache...";
./app/console cache:warmup --env=$ENV --no-debug;
echo "Fixing permissions...";
chown -R apache:apache ./app/cache ./app/logs/;
chmod -R 777 app/cache ./app/logs;
echo "Checking for new migrations....";
NEW_MIGRATIONS=`svn diff -r $LOCAL_REVISION:$SERVER_REVISION app/DoctrineMigrations`;
if [[ "$NEW_MIGRATIONS" == "" ]]; then
echo "Migration not needed...";
else
echo "Running migrations..."
echo Y | ./app/console doctrine:migration:migrate
fi
fi
echo "Finished";
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment