Project

General

Profile

Defect #6105 » redmine-migrator.sh

Jesse Norell, 2011-06-01 17:10

 
1
#!/bin/sh
2

    
3
X_DEBIAN_SITEID=default
4

    
5
# pass a siteid on cli if you want (todo: loop through all args)
6
if [ -n "$1" ]
7
then
8
	X_DEBIAN_SITEID=${1}
9
fi
10

    
11
# these are the debian redmine package locations
12
export X_DEBIAN_SITEID
13
export RAILS_ETC=/etc/redmine/${X_DEBIAN_SITEID}
14
export RAILS_LOG=/var/log/redmine/${X_DEBIAN_SITEID}
15
export RAILS_VAR=/var/lib/redmine/${X_DEBIAN_SITEID}
16
export RAILS_CACHE=/var/cache/redmine/${X_DEBIAN_SITEID}
17
export RAILS_ENV=production
18
RAKEFILE=/usr/share/redmine/Rakefile
19

    
20
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
21

    
22
if [ ! -d $RAILS_ETC ]
23
then
24
	mkdir $RAILS_ETC
25
	chown www-data:www-data $RAILS_ETC
26
  chmod 755 $RAILS_ETC
27
fi
28
if [ ! -d $RAILS_LOG ]
29
then
30
	mkdir $RAILS_LOG
31
	chown www-data:www-data $RAILS_LOG
32
  chmod 750 $RAILS_LOG
33
fi
34
if [ ! -d $RAILS_VAR ]
35
then
36
	mkdir -p $RAILS_VAR/files
37
	chown -R www-data:www-data $RAILS_VAR
38
  chmod 750 $RAILS_VAR
39
  chmod 755 $RAILS_VAR/files
40
fi
41
if [ ! -d $RAILS_VAR ]
42
then
43
	mkdir $RAILS_CACHE
44
	chown www-data:www-data $RAILS_CACHE
45
  chmod 750 $RAILS_CACHE
46
fi
47
  
48
if [ ! -f $RAILS_ETC/database.yml ]
49
then
50
	cp /usr/share/redmine/templates/database.yml.template $RAILS_ETC/database.yml
51
	chown root:www-data $RAILS_ETC/database.yml
52
	chmod 640 $RAILS_ETC/database.yml
53

    
54
	echo "Error: Database config for X_DEBIAN_SITEID ${X_DEBIAN_SITEID} not found, creating from template." 1>&2
55
	echo "Error: You need to edit $RAILS_ETC/database.yml then continue" 1>&2
56
	exit 1
57
fi
58

    
59
if [ -f $RAILS_ETC/email.yml ]
60
then
61
	chown root:www-data $RAILS_ETC/email.yml
62
	chmod 640 $RAILS_ETC/email.yml
63
fi
64

    
65
if [ ! -f ${RAKEFILE} ]
66
then
67
	echo "Error: rakefile [${RAKEFILE}] does not exist, can't continue." 1>&2
68
	exit 1
69
fi
70

    
71
rake -f ${RAKEFILE} generate_session_store
72

    
73
if [ -f $RAILS_ETC/email.yml ]
74
then
75
	chown root:www-data $RAILS_ETC/session.yml
76
	chmod 640 $RAILS_ETC/session.yml
77
fi
78

    
79
ruby /usr/share/redmine/script/about
80
exit
81

    
82
rake -f ${RAKEFILE} db:migrate --trace
83
rake -f ${RAKEFILE} redmine:load_default_data
84
rake -f ${RAKEFILE} db:migrate:upgrade_plugin_migrations
85
rake -f ${RAKEFILE} db:migrate_plugins
86

    
87
rake -f ${RAKEFILE} tmp:cache:clear
88
rake -f ${RAKEFILE} tmp:sessions:clear
89

    
(3-3/3)