Skip to content

Instantly share code, notes, and snippets.

@iteman
Created August 24, 2009 17:36
Show Gist options
  • Save iteman/173991 to your computer and use it in GitHub Desktop.
Save iteman/173991 to your computer and use it in GitHub Desktop.
ITEMAN Redmine Upgrade - A command to upgrade an existing Redmine installation
#!/bin/bash
# ITEMAN Redmine Upgrade - A command to upgrade an existing Redmine installation
# Copyright (c) 2009-2012 ITEMAN, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
OLD_DIRECTORY=/data/redmine/redmine-1.1.2
NEW_DIRECTORY=/data/redmine/redmine-1.2.1
PLUGINS=(
google_analytics_plugin
redmine_mylyn_connector
redmine_resources
redmine_vote
redmine_youtube
acts_as_taggable_on
redmine_tagging
rails_sql_views
redmine_todos_plugin
)
REDMINE_USER=nobody
REDMINE_GROUP=www-data
REDMINE_FILE_MODE=660
REDMINE_GROUP_MODE=2770
if [ "x$OLD_DIRECTORY" = "x" ]; then
echo "$0: OLD_DIRECTORY must be specified, exit"
exit 1
fi
if [ "x$NEW_DIRECTORY" = "x" ]; then
echo "$0: NEW_DIRECTORY must be specified, exit"
exit 1
fi
if [ -f $OLD_DIRECTORY/config/configuration.yml ]; then
cp $OLD_DIRECTORY/config/configuration.yml $NEW_DIRECTORY/config/
fi
if [ -f $OLD_DIRECTORY/config/database.yml ]; then
cp $OLD_DIRECTORY/config/database.yml $NEW_DIRECTORY/config/
fi
if [ -f $OLD_DIRECTORY/config/email.yml ]; then
cp $OLD_DIRECTORY/config/email.yml $NEW_DIRECTORY/config/
fi
cp -R $OLD_DIRECTORY/files $NEW_DIRECTORY
for PLUGIN in ${PLUGINS[@]}; do
cp -R $OLD_DIRECTORY/vendor/plugins/$PLUGIN $NEW_DIRECTORY/vendor/plugins
done
pushd $NEW_DIRECTORY
RAILS_ENV="production" rake generate_session_store
RAILS_ENV="production" rake db:migrate
RAILS_ENV="production" rake db:migrate:upgrade_plugin_migrations
RAILS_ENV="production" rake db:migrate_plugins
RAILS_ENV="production" rake rails:update
RAILS_ENV="production" rake tmp:cache:clear
RAILS_ENV="production" rake tmp:sessions:clear
popd
find $NEW_DIRECTORY ! -user $REDMINE_USER -exec chown $REDMINE_USER '{}' \;
find $NEW_DIRECTORY ! -group $REDMINE_GROUP -exec chgrp $REDMINE_GROUP '{}' \;
find $NEW_DIRECTORY -type d ! -perm $REDMINE_GROUP_MODE -exec chmod $REDMINE_GROUP_MODE '{}' \;
find $NEW_DIRECTORY -type f ! -perm $REDMINE_FILE_MODE -exec chmod $REDMINE_FILE_MODE '{}' \;
exit 0
# Local Variables:
# mode: shell-script
# coding: utf-8
# tab-width: 4
# indent-tabs-mode: nil
# End:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment