blob: 2816cc8c786aad526a86ec40dfd96bacf3817990 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
#!/bin/sh
# This script expects to run as root
# ONLY CHANGE THIS PART
export SERVER_NAME=gitorious.org
export GITORIOUS_REPO=git://gitorious.org/gitorious/akitaonrails-gitorious.git
# DO NOT CHANGE THIS PART
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -q -y build-essential apache2 mysql-server mysql-client git git-svn apg geoip-bin libgeoip1 libgeoip-dev sqlite3 libsqlite3-dev imagemagick libpcre3 libpcre3-dev zlib1g zlib1g-dev libyaml-dev libmysqlclient15-dev apache2-dev sendmail
# Checks for 64-bit flag
while [ "$#" -gt "0" ]
do
case $1 in
-64)
SIXTY_FOUR_FLAG=1
;;
esac
shift
done
/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
sleep 5
mysql mysql -e "update user set Password=password('root') where User='root';"
/etc/init.d/mysql stop
/etc/init.d/mysql start
if [ -d ~/tmp ]; then rm -Rf ~/tmp; fi
mkdir ~/tmp && cd ~/tmp
test -f onig-5.9.1.tar.gz || wget http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.1.tar.gz
test -d onig-5.9.1 || tar xvfz onig-5.9.1.tar.gz
cd onig-5.9.1
./configure && make && make install
cd ..
test -f sphinx-0.9.8.tar.gz || wget http://www.sphinxsearch.com/downloads/sphinx-0.9.8.tar.gz
test -d sphinx-0.9.8 || tar xvfz sphinx-0.9.8.tar.gz
cd sphinx-0.9.8
./configure && make && make install
cd ..
test -f ImageMagick-6.4.6-9.tar.gz || wget ftp://ftp.imagemagick.net/pub/ImageMagick/ImageMagick-6.4.6-9.tar.gz
test -d ImageMagick-6.4.6-9 || tar xvfz ImageMagick-6.4.6-9.tar.gz
cd ImageMagick-6.4.6-9
./configure && make && make install
cd ..
if [ "$SIXTY_FOUR_FLAG" = "1" ]; then
# unattended ruby enterprise install for all other OSes (only tested on Ubuntu 8.10 64-bit)
# there may be some performance penalty
# but Gitorious is not really a performance-hungry application
#
# More information about state of 64-bit support on Ruby Enterprise:
# http://blog.phusion.nl/2008/12/30/ruby-enterprise-edition-second-sponsorship-campaign/
# http://www.rubyenterpriseedition.com/faq.html#thirty_three_percent_mem_reduction
cd ~/tmp
test -f ruby-enterprise-1.8.6-20081215.tar.gz || wget http://rubyforge.org/frs/download.php/48623/ruby-enterprise-1.8.6-20081215.tar.gz
tar xzvf ruby-enterprise-1.8.6-20081215.tar.gz
echo "" > unattended-install-script
echo "/opt/ruby-enterprise" >> unattended-install-script
cd ruby-enterprise-1.8.6-20081215 && cat ../unattended-install-script | ./installer
cd ..
rm unattended-install-script
else
test -f ruby-enterprise_1.8.6-20081215-i386.deb || wget http://rubyforge.org/frs/download.php/48625/ruby-enterprise_1.8.6-20081215-i386.deb
dpkg -i ruby-enterprise_1.8.6-20081215-i386.deb
fi
if [ -f /etc/profile.git ]; then cp /etc/profile.git /etc/profile; fi
cp /etc/profile /etc/profile.git
echo "export PATH=/opt/ruby-enterprise/bin:\$PATH" >> /etc/profile
echo "export LD_LIBRARY_PATH=\"/usr/local/lib\"" >> /etc/profile
echo "export LDFLAGS=\"-L/usr/local/lib -Wl,-rpath,/usr/local/lib\"" >> /etc/profile
if [ -f /etc/ld.so.conf.git ]; then cp /etc/ld.so.conf.git /etc/ld.so.conf; fi
touch ld.so.conf
echo "/usr/local/lib" >> ld.so.conf
cat /etc/ld.so.conf >> ld.so.conf
cp /etc/ld.so.conf /etc/ld.so.conf.git
mv ld.so.conf /etc/ld.so.conf
. /etc/profile
ldconfig
test -f /usr/bin/ruby.old || mv /usr/bin/ruby /usr/bin/ruby.old
test -f /usr/bin/ruby || ln -s /opt/ruby-enterprise/bin/ruby /usr/bin/ruby
gem install passenger --no-rdoc --no-ri --version=2.0.6
yes '' | /opt/ruby-enterprise/bin/passenger-install-apache2-module
if [ -f /etc/apache2/mods-available/passenger.load ]; then rm /etc/apache2/mods-available/passenger.load; fi
if [ -f /etc/apache2/mods-available/passenger.conf ]; then rm /etc/apache2/mods-available/passenger.conf; fi
if [ -f /etc/apache2/sites-available/gitorious ]; then rm /etc/apache2/sites-available/gitorious; fi
touch /etc/apache2/mods-available/passenger.load
touch /etc/apache2/mods-available/passenger.conf
touch /etc/apache2/sites-available/gitorious
echo "LoadModule passenger_module /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so" >> /etc/apache2/mods-available/passenger.load
echo "PassengerRoot /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.0.6" >> /etc/apache2/mods-available/passenger.load
echo "PassengerRuby /opt/ruby-enterprise/bin/ruby" >> /etc/apache2/mods-available/passenger.conf
a2enmod passenger
echo "<VirtualHost *:80>" >> /etc/apache2/sites-available/gitorious
echo " ServerName $SERVER_NAME" >> /etc/apache2/sites-available/gitorious
echo " DocumentRoot /var/www/gitorious/public" >> /etc/apache2/sites-available/gitorious
echo "</VirtualHost>" >> /etc/apache2/sites-available/gitorious
rm /etc/apache2/sites-enabled/000*
ln -s /etc/apache2/sites-available/gitorious /etc/apache2/sites-enabled/000-gitorious
gem install mime-types oniguruma textpow chronic BlueCloth ruby-yadis ruby-openid rmagick geoip ultrasphinx rspec rspec-rails RedCloth echoe daemons geoip --no-rdoc --no-ri
cd /var/www
test -d gitorious || git clone $GITORIOUS_REPO gitorious
test -f /usr/local/bin/gitorious || ln -s /var/www/gitorious/script/gitorious /usr/local/bin/gitorious
cp /var/www/gitorious/doc/templates/ubuntu/git-daemon /etc/init.d
cp /var/www/gitorious/doc/templates/ubuntu/git-ultrasphinx /etc/init.d
chmod +x /etc/init.d/git-ultrasphinx
chmod +x /etc/init.d/git-daemon
update-rc.d -f git-daemon start 99 2 3 4 5 .
update-rc.d -f git-ultrasphinx start 99 2 3 4 5 .
yes '' | adduser git --disabled-password
chown -R git:git /var/www/gitorious
su - git -c "mkdir ~/.ssh"
su - git -c "chmod 700 ~/.ssh"
su - git -c "touch ~/.ssh/authorized_keys"
cp /var/www/gitorious/config/database.sample.yml /var/www/gitorious/config/database.yml
cp /var/www/gitorious/config/gitorious.sample.yml /var/www/gitorious/config/gitorious.yml
export SECRET=`apg -m 64 | tr -d '\n'`
cat /var/www/gitorious/config/gitorious.yml | sed \
-e "s/cookie_secret\:.*$/cookie_secret\: $SECRET/g" \
-e "s/repository_base_path\:.*$/repository_base_path\: \/home\/git/g" \
-e "s/public_mode\:.*$/public_mode\: false/g" \
-e "s/gitorious_client_port\:.*/gitorious_client_port\: 80/g" \
-e "s/gitorious_host\:.*$/gitorious_host\: $SERVER_NAME/g" \
> ~/tmp/foo
mv ~/tmp/foo /var/www/gitorious/config/gitorious.yml
cat /var/www/gitorious/config/database.yml | sed 's/password\:/password\: root/g' > ~/tmp/foo
mv ~/tmp/foo /var/www/gitorious/config/database.yml
chown git:git /var/www/gitorious/config/database.yml
chown git:git /var/www/gitorious/config/gitorious.yml
su - git -c "if [ -f ~/.bash_profile ]; rm ~/.bash_profile; fi"
su - git -c "touch ~/.bash_profile"
su - git -c "echo 'export RUBY_HOME=/opt/ruby-enterprise' >> ~/.bash_profile"
su - git -c "echo 'export GEM_HOME=\$RUBY_HOME/lib/ruby/gems/1.8/gems' >> ~/.bash_profile"
su - git -c "echo 'export PATH=\$RUBY_HOME/bin:\$PATH' >> ~/.bash_profile"
su - git -c "cd /var/www/gitorious && rake db:create RAILS_ENV=production"
su - git -c "cd /var/www/gitorious && rake db:migrate RAILS_ENV=production"
su - git -c "cd /var/www/gitorious && rake ultrasphinx:bootstrap RAILS_ENV=production"
rm ~/tmp/crontab && touch ~/tmp/crontab
echo "*/2 * * * * /opt/ruby-enterprise/bin/ruby /var/www/gitorious/script/task_performer" >> ~/tmp/crontab
echo "* */1 * * * cd /var/www/gitorious && /opt/ruby-enterprise/bin/rake ultrasphinx:index RAILS_ENV=production" >> ~/tmp/crontab
mv ~/tmp/crontab /home/git
chown git:git /home/git/crontab
su - git -c "crontab -u git /home/git/crontab"
/etc/init.d/git-daemon start
/etc/init.d/git-ultrasphinx start
cp /var/www/gitorious/doc/templates/gitorious-logrotate /etc/logrotate.d/gitorious
chmod 644 /etc/logrotate.d/gitorious
/etc/init.d/apache2 reload
|