#####################################################################################
##  Recete pur migration du
##  DebianSqueeze avec Redmine1.2.3 installé dans /opt
##  vers DebianWheezy avec Redmine2.5.1-2 (package Debian)
#####################################################################################

#####################################################################################
## Migration du Redmine 1.2.3 vers 1.4.4 dans /opt
#####################################################################################

# /etc/init.d/redmine_mongrel stop
# cd /opt
# wget http://www.redmine.org/releases/1.x/redmine-1.4.4.tar.gz
# tar -zxf redmine-1.4.4.tar.gz
# cat <<EOT >> redmine/.gemrc
install: --no-rdoc --no-ri
update:  --no-rdoc --no-ri
EOT
# chown -hR redmine.redmine /opt/redmine*
# echo 'export PATH=/var/lib/gems/1.8/bin/:${PATH}' >> /opt/redmine/.bashrc
# mysqldump redmine09 | gzip > /opt/redmine-1.4.4/database_`date +%y_%m_%d`.gz
# gem install bundler
# su redmine
$ ln   redmine/.bashrc  redmine-1.4.4/.bashrc
$ cat <<EOT >> redmine-1.4.4/config/database.yml
production:
  adapter: mysql2
  database: redmine09
  host: localhost
  username: redmine
  password: jhqs44dQSD7
  encoding: utf8
EOT
$ cp -a redmine/config/configuration.yml redmine-1.4.4/config/
$ rm redmine-1.4.4/files/delete.me
$ cp -a redmine/files/* redmine-1.4.4/files/
$ cp -a redmine/vendor/plugins/redmine_http_auth/ redmine-1.4.4/vendor/plugins/
$ cd redmine-1.4.4

$ sed -i -e '/^gem "tzinfo"/agem "mysql2", "~> 0.2.7"' Gemfile
$ sed -i -e '/^platforms :mri_19, :mingw_19 do$/,/^end$/d' Gemfile

$ bundle install --path vendor/bundle --without test rmagick postgresql sqlite
$ bundle exec rake config/initializers/session_store.rb
$ bundle exec rake db:migrate RAILS_ENV=production
$ bundle exec rake db:migrate_plugins RAILS_ENV=production
$ bundle exec rake tmp:cache:clear
$ bundle exec rake tmp:sessions:clear

$ exit


#####################################################################################
## Upgrade du Debian Squeeze vers Wheezy en utilisant:
## http://wiki.auf.org/wikiteki/JeanChristopheAndr%C3%A9/Notes/Debian
#####################################################################################

aptitude update ; aptitude safe-upgrade ; aptitude clean
find /etc -name "*.dpkg*" -o -name "*.ucf*"
unset LANG ; mkdir ~/squeeze
cp -a /etc ~/squeeze/
cp -a /var/lib/dpkg ~/squeeze/_var_lib_dpkg
cp -a /var/lib/apt/extended_states ~/squeeze/_var_lib_apt_extended_states
cp -a /var/lib/aptitude/pkgstates ~/squeeze/_var_lib_aptitude_pkgstates
dpkg --audit ; dpkg --get-selections "*" > ~/squeeze/dpkg--get-selections.txt
aptitude search "~ahold" | grep "^.h" ; dpkg --get-selections | grep hold
f="/etc/apt/preferences" ; [ -f "$f" ] && sed -i -e 's|^|#|' "$f"
f="/etc/apt/preferences.d" ; [ -d "$f" ] && mv "$f" "$f".dpkg-disabled-before-upgrade && mkdir "$f"
sed -i -e '/proposed-updates/s/^/#/' /etc/apt/sources.list
sed -i -e 's/squeeze/wheezy/' /etc/apt/sources.list
sed -i -e 's| [a-z]+/volatile | wheezy-updates |' -e 's|/volatile|/archive|' /etc/apt/sources.list
sed -i -e '/wheezy-lts/s|^|#|' /etc/apt/sources.list
sed -i -e '/backports/s|backports.debian.org/debian-backports|http.debian.net/debian|' /etc/apt/sources.list
f="/etc/mysql/conf.d/local.cnf" ; [ -f "$f" ] && sed -i -e '/^default-character-set/s|^|#|' "$f"

## UPGRADING
script -t -a  2>~/squeeze/mise-a-niveau-wheezy.time ~/squeeze/mise-a-niveau-wheezy.typescript
apt-get update ; apt-get -o APT::Get::Trivial-Only=true dist-upgrade ; df --si
apt-get upgrade && apt-get clean
##Configuration file `/etc/crontab'
N
##Configuration file `/etc/sudoers'
N
## DIST UPGRADE
apt-get -o APT::Install-Recommends=false dist-upgrade


  ┌─────────────────────────────────┤ Configuring libc6 ├──────────────────────────────────┐
  │                                                                                        │
  │ There are services installed on your system which need to be restarted when certain    │
  │ libraries, such as libpam, libc, and libssl, are upgraded. Since these restarts may    │
  │ cause interruptions of service for the system, you will normally be prompted on each   │
  │ upgrade for the list of services you wish to restart.  You can choose this option to   │
  │ avoid being prompted; instead, all necessary restarts will be done for you             │
  │ automatically so you can avoid being asked questions on each library upgrade.          │
  │                                                                                        │
  │ Restart services during package upgrades without asking?                               │
  │                                                                                        │
  │                         <Yes>                            <No>                          │
  │                                                                                        │
  └────────────────────────────────────────────────────────────────────────────────────────┘
YES
 ┌─────────────────────────────────┤ Configuring apticron ├─────────────────────────────────┐
 │ A new version of configuration file /etc/cron.d/apticron is available, but the version   │
 │ installed currently has been locally modified.                                           │
 │                                                                                          │
 │ What do you want to do about modified configuration file apticron?                       │
 │                                                                                          │
 │                install the package maintainer's version                                  │
 │                keep the local version currently installed                                │
 │                show the differences between the versions                                 │
 │                show a side-by-side difference between the versions                       │
 │                show a 3-way difference between available versions                        │
 │                do a 3-way merge between available versions (experimental)                │
 │                start a new shell to examine the situation                                │
 │                                                                                          │
 │                                                                                          │
 │                                          <Ok>                                            │
 │                                                                                          │
 └──────────────────────────────────────────────────────────────────────────────────────────┘
install the package maintainer's version

  ┌────────────────────────────┤ Modified configuration file ├─────────────────────────────┐
  │ A new version of configuration file /etc/fusioninventory/agent.cfg is available, but   │
  │ the version installed currently has been locally modified.                             │
  │                                                                                        │
  │ What do you want to do about modified configuration file agent.cfg?                    │
  │                                                                                        │
  │                  install the package maintainer's version                              │
  │                  keep the local version currently installed                            │
  │                  show the differences between the versions                             │
  │                  show a side-by-side difference between the versions                   │
  │                  start a new shell to examine the situation                            │
  │                                                                                        │
  │                                                                                        │
  │                                         <Ok>                                           │
  │                                                                                        │
  └────────────────────────────────────────────────────────────────────────────────────────┘
install the package maintainer's version


apt-get clean ; aptitude search ~i\!~Odebian
find /etc -name "*.dpkg*" -o -name "*.ucf*"
auf-inventaire-config

#####################################################################################
## Du Redmine1.4.4(/opt) vers Redmine1.4.4(Debian)
#####################################################################################

# apt-get install redmine-mysql
# apt-get install redmine ruby-rmagick

  ┌─────────────────────────────┤ Configuring dbconfig-common ├─────────────────────────────┐
  │ A new version of configuration file /etc/dbconfig-common/config is available, but the   │
  │ version installed currently has been locally modified.                                  │
  │                                                                                         │
  │ What do you want to do about modified configuration file config?                        │
  │                                                                                         │
  │                   install the package maintainer's version                              │
  │                   keep the local version currently installed                            │
  │                   show the differences between the versions                             │
  │                   show a side-by-side difference between the versions                   │
  │                   start a new shell to examine the situation                            │
  │                                                                                         │
  │                                                                                         │
  │                                         <Ok>                                            │
  │                                                                                         │
  └─────────────────────────────────────────────────────────────────────────────────────────┘
install the package maintainer's version

 ┌─────────────────────────────────┤ Configuring redmine ├──────────────────────────────────┐
 │                                                                                          │
 │ The redmine/instances/default package must have a database installed and configured      │
 │ before it can be used.  This can be optionally handled with dbconfig-common.             │
 │                                                                                          │
 │ If you are an advanced database administrator and know that you want to perform this     │
 │ configuration manually, or if your database has already been installed and configured,   │
 │ you should refuse this option.  Details on what needs to be done should most likely be   │
 │ provided in /usr/share/doc/redmine/instances/default.                                    │
 │                                                                                          │
 │ Otherwise, you should probably choose this option.                                       │
 │                                                                                          │
 │ Configure database for redmine/instances/default with dbconfig-common?                   │
 │                                                                                          │
 │                         <Yes>                            <No>                            │
 │                                                                                          │
 └──────────────────────────────────────────────────────────────────────────────────────────┘
YES
    ┌─────────────────────────────────┤ Configuring redmine ├──────────────────────────────────┐
    │ The redmine/instances/default package can be configured to use one of several database   │
    │ types. Below, you will be presented with the available choices.                          │
    │                                                                                          │
    │ Database type to be used by redmine/instances/default:                                   │
    │                                                                                          │
    │                                         sqlite3                                          │
    │                                         pgsql                                            │
    │                                         mysql                                            │
    │                                                                                          │
    │                                                                                          │
    │                         <Ok>                             <Cancel>                        │
    │                                                                                          │
    └──────────────────────────────────────────────────────────────────────────────────────────┘
mysql
  ┌───────────────────────────────────┤ Configuring redmine ├───────────────────────────────────┐
  │ Please provide the password for the administrative account with which this package should   │
  │ create its MySQL database and user.                                                         │
  │                                                                                             │
  │ Password of the database's administrative user:                                             │
  │                                                                                             │
  │ ********___________________________________________________________________________________ │
  │                                                                                             │
  │                          <Ok>                              <Cancel>                         │
  │                                                                                             │
  └─────────────────────────────────────────────────────────────────────────────────────────────┘


##Purgando redmine_default y creandola vacia y cargando la de nosotros:
# mysqladmin drop redmine_default
# mysqladmin create redmine_default
# mysqldump redmine09 > /tmp/db09.sql
# mysql redmine_default < /tmp/db09.sql && rm /tmp/db09.sql

### copiando configuración
# cp /opt/redmine-1.4.4/config/configuration.yml /etc/redmine/default/
# chown root.www-data /etc/redmine/default/configuration.yml
# chmod 640 /etc/redmine/default/configuration.yml
## migrando archivos
# mv /opt/redmine-1.4.4/files/* /var/lib/redmine/default/files/
# chown -hR www-data:www-data /var/lib/redmine/default/files/
#####################################################################################
## Cofig de Apache2 avec passenger
#####################################################################################
# apt-get install libapache2-mod-passenger
# /etc/init.d/apache2 stop
# ln -s /usr/share/redmine /var/lib/redmine/default/passenger
# a2enmod passenger
# mv /etc/apache2/sites-available/redmine.auf.org /etc/apache2/sites-available/redmine.auf.org.2014-01-22
###############CONFIG /etc/apache2/sites-available/redmine.auf.org-fredy
# These modules must be enabled : rewrite, fcgid
# (mod_fastcgi is much harder to configure)

<VirtualHost *:80>
        ServerName redmine.auf.org
        ServerAdmin technique@ca.auf.org
        Redirect permanent / https://redmine.auf.org/
</VirtualHost>

<VirtualHost *:443>
        ServerName redmine.auf.org
        ServerAdmin technique@ca.auf.org

        SSLEngine on
        SSLCertificateFile    /etc/ssl/certs/_.auf.org-cert.pem
        SSLCertificateKeyFile /etc/ssl/private/_.auf.org-key.pem
        SSLCACertificateFile  /etc/ssl/certs/GandiStandardSSLCA.pem
        SSLVerifyClient None

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        LogLevel warn

        # this is the passenger config
        RailsEnv production
        # create a link in /var/lib/redmine/default/passenger to /usr/share/redmine
        PassengerAppRoot /var/lib/redmine/default/passenger
        PassengerUser "www-data"
        SetEnv X_DEBIAN_SITEID "default"
        Alias "/plugin_assets/" /var/cache/redmine/default/plugin_assets/

        DocumentRoot /usr/share/redmine/public
        <Directory "/usr/share/redmine/public">
                Order allow,deny
                Allow from all
        </Directory>
        <Location />
                AuthType "Mellon"
                MellonEnable "info"
                MellonUser "mail"
                MellonDefaultLoginPath "/"
                # préparation des méta-données
                MellonOrganizationName "redmine.auf.org"
                MellonOrganizationDisplayName "fr" "Redmine AuF"
                MellonOrganizationURL "http://www.auf.org/"
                MellonSPPrivateKeyFile /etc/ssl/private/saml-redmine.auf.org-key.pem
                MellonSPCertFile /etc/ssl/certs/saml-redmine.auf.org-cert.pem
                MellonIdPMetadataFile /etc/ssl/saml-id.auf.org-metadata.xml
        </Location>

        RewriteEngine On
        # allows redmine_http_auth plugin to work
        RequestHeader unset Remote-User
        RequestHeader set Remote-User "%{MELLON_mail}e" env=MELLON_mail
        RequestHeader unset Mellon-gn
        RequestHeader set Mellon-gn "%{MELLON_gn}e" env=MELLON_gn
        RequestHeader unset Mellon-sn
        RequestHeader set Mellon-sn "%{MELLON_sn}e" env=MELLON_sn
        RequestHeader unset Mellon-mail
        RequestHeader set Mellon-mail "%{MELLON_mail}e" env=MELLON_mail
</VirtualHost>
########################################END CONFIG FILE

# cd /etc/apache2/sites-available
# mv redmine.auf.org-fredy redmine.auf.org
# /etc/init.d/apache2 start
# cd

###############################################
## upgrade vers redmine 2.5 (backport du debian)
################################################
# apt-get -t wheezy-backports install redmine
#####################################################################################
## Configuration du plugin auth.
#####################################################################################
# mkdir /usr/share/redmine/plugins
## le plugin
# cd /usr/share/redmine/plugins
# unset GIT_DIR GIT_WORK_TREE
# git clone https://github.com/caleno/redmine_http_auth.git



cd /usr/share/redmine ; patch -p0 < /root/redmine-2.5-auf.diff
# cd /usr/share/redmine/plugins/redmine_http_auth/lib
# ln -s ../app/helpers/http_auth_helper.rb
# cp -a /opt/redmine-1.2/public/idauf*.png /usr/share/redmine/public/
# /etc/init.d/apache2 restart


###############################################################
## FIN DE LA MIGRATION
###############################################################


##################################################################
## Post Migration
##################################################################

# ln -s /var/cache/redmine/default/plugin_assets /usr/share/redmine/public/

# rm /etc/init.d/redmine_mongrel
# rm /etc/rc?.d/*redmine_mongrel


## loop http with ID: http://mark.diatonic.de/linux/redmine-http-auth-plugin-fix
# pwd
/usr/share/redmine/plugins/redmine_http_auth/lib
# diff http_auth_patch.rb*
100,101d99
<       session[:ctime] = Time.now.utc.to_i
<       session[:atime] = Time.now.utc.to_i

###############notes

############ probleme: http://www.redmine.org/boards/2/topics/35656
###You have a plugin installed that requires dispatcher (require 'dispatcher').
##But dispatcher is no longer available in Rails 3.
############ solution: https://github.com/yakaz/redmine_http_auth/commit/37fadb646f61739020c558e356cd6057df6235f0

redmine/De123Vers25 (dernière édition le 2015-01-28 16:53:59 par JeanChristopheAndré)