Commit f5815890ecba49aba2913373ca37cb4c89781f54

Authored by Antonio Terceiro
1 parent aa137131

Adding upgrade script

Showing 2 changed files with 96 additions and 0 deletions   Show diff stats
config/bashrc 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +export PS1="[Noosfero upgrade] (\w) $ "
  2 +eval `dircolors -b`
... ...
script/git-upgrade 0 → 100755
... ... @@ -0,0 +1,94 @@
  1 +#!/bin/sh
  2 +
  3 +set -e
  4 +
  5 +export RAILS_ENV=production
  6 +
  7 +get_value(){
  8 + ruby -ryaml -e "puts YAML.load_file('config/database.yml')['$RAILS_ENV']['$1']"
  9 +}
  10 +
  11 +usage(){
  12 + echo "usage: $0 [OPTIONS]"
  13 + echo
  14 + echo "Options:"
  15 + echo
  16 + echo " -s, --shell Opens a shell just after upgrading code and"
  17 + echo " database to make manual steps if needed"
  18 + echo
  19 + echo " -h, --help Displays the help (this screen)"
  20 + echo
  21 + echo " -v, --version Displays Noosfero current version"
  22 + echo
  23 + exit $1
  24 +}
  25 +
  26 +version(){
  27 + version=$(ruby -Ilib -rnoosfero -e 'puts Noosfero::VERSION')
  28 + echo "Noosfero version $version"
  29 + exit 0
  30 +}
  31 +
  32 +shell=no
  33 +while test $# -gt 0; do
  34 + case "$1" in
  35 + --shell)
  36 + shell=yes
  37 + ;;
  38 + --help)
  39 + usage 0
  40 + ;;
  41 + --version)
  42 + version
  43 + ;;
  44 + *)
  45 + usage 1
  46 + ;;
  47 + esac
  48 + shift
  49 +done
  50 +
  51 +
  52 +./script/production stop || echo "Stop failed, trying to continue anyway"
  53 +
  54 +sudo /etc/init.d/memcached stop
  55 +
  56 +rake backup
  57 +
  58 +database=$(get_value database)
  59 +adapter=$(get_value adapter)
  60 +
  61 +if [ "$adapter" = "postgresql" ]; then
  62 + mkdir -p backups/
  63 + backup=backups/dump-$(date +%Y-%m-%d-%H-%M).sql
  64 + pg_dump "$database" > "$backup"
  65 +fi
  66 +
  67 +git pull
  68 +
  69 +for dir in public/designs/themes/*; do
  70 + (cd $dir && test -e .git/config && git pull)
  71 +done
  72 +
  73 +rake db:migrate
  74 +
  75 +if test "$shell" = "yes"; then
  76 + echo "################################################"
  77 + echo "# Noosfero upgrade shell #"
  78 + echo "################################################"
  79 + echo "# #"
  80 + echo "# If you need to do any manual steps during #"
  81 + echo "# this upgrade, now is the time. #"
  82 + echo "# #"
  83 + echo "# After you finish, just exit this shell and #"
  84 + echo "# the upgrade will proceed #"
  85 + echo "################################################"
  86 + export PS1="[Noosfero upgrade] $PS1"
  87 + bash --rcfile config/bashrc
  88 +fi
  89 +
  90 +rake makemo
  91 +
  92 +sudo /etc/init.d/memcached start
  93 +
  94 +./script/production start
... ...