gigpark-ec2onrails 0.9.10.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +190 -0
- data/COPYING +339 -0
- data/Manifest +160 -0
- data/README.textile +233 -0
- data/Rakefile +31 -0
- data/TODO +104 -0
- data/ec2onrails.gemspec +46 -0
- data/echoe_config.rb +27 -0
- data/examples/Capfile +3 -0
- data/examples/deploy.rb +103 -0
- data/examples/s3.yml +9 -0
- data/lib/ec2onrails.rb +20 -0
- data/lib/ec2onrails/capistrano_utils.rb +47 -0
- data/lib/ec2onrails/recipes.rb +146 -0
- data/lib/ec2onrails/recipes/db.rb +366 -0
- data/lib/ec2onrails/recipes/deploy.rb +26 -0
- data/lib/ec2onrails/recipes/server.rb +517 -0
- data/lib/ec2onrails/version.rb +29 -0
- data/server/build +74 -0
- data/server/files/etc/README +7 -0
- data/server/files/etc/aliases +5 -0
- data/server/files/etc/cron.d/ec2onrails +16 -0
- data/server/files/etc/cron.daily/app +31 -0
- data/server/files/etc/cron.daily/logrotate_post +25 -0
- data/server/files/etc/cron.hourly/app +31 -0
- data/server/files/etc/cron.monthly/app +31 -0
- data/server/files/etc/cron.weekly/app +31 -0
- data/server/files/etc/default/varnish +33 -0
- data/server/files/etc/default/varnishncsa +11 -0
- data/server/files/etc/denyhosts.conf +628 -0
- data/server/files/etc/dpkg/dpkg.cfg +13 -0
- data/server/files/etc/ec2onrails/rails_env +1 -0
- data/server/files/etc/ec2onrails/roles.yml +5 -0
- data/server/files/etc/environment +2 -0
- data/server/files/etc/event.d/god +8 -0
- data/server/files/etc/god/db_primary.god +16 -0
- data/server/files/etc/god/dkim_filter.god +17 -0
- data/server/files/etc/god/master.conf +40 -0
- data/server/files/etc/god/memcache.god +15 -0
- data/server/files/etc/god/notifications.god +11 -0
- data/server/files/etc/god/proxy.god +40 -0
- data/server/files/etc/god/system.god +37 -0
- data/server/files/etc/god/web.god +23 -0
- data/server/files/etc/init.d/ec2-every-startup +29 -0
- data/server/files/etc/init.d/ec2-first-startup +37 -0
- data/server/files/etc/init.d/nginx +78 -0
- data/server/files/etc/logrotate.d/nginx +10 -0
- data/server/files/etc/logrotate.d/rails +8 -0
- data/server/files/etc/logrotate.d/varnish +14 -0
- data/server/files/etc/memcached.conf +47 -0
- data/server/files/etc/motd.tail +13 -0
- data/server/files/etc/mysql/my.cnf +152 -0
- data/server/files/etc/nginx/conf.d/custom.conf +1 -0
- data/server/files/etc/nginx/nginx.conf.erb +152 -0
- data/server/files/etc/postfix/main.cf +4 -0
- data/server/files/etc/ssh/sshd_config +96 -0
- data/server/files/etc/sudoers +31 -0
- data/server/files/etc/syslog.conf +63 -0
- data/server/files/etc/varnish/default.vcl.erb +140 -0
- data/server/files/usr/local/ec2onrails/COPYING +339 -0
- data/server/files/usr/local/ec2onrails/bin/archive_file +44 -0
- data/server/files/usr/local/ec2onrails/bin/backup_app_db +160 -0
- data/server/files/usr/local/ec2onrails/bin/backup_dir +89 -0
- data/server/files/usr/local/ec2onrails/bin/ec2_meta_data +80 -0
- data/server/files/usr/local/ec2onrails/bin/exec_runner +76 -0
- data/server/files/usr/local/ec2onrails/bin/in_role +33 -0
- data/server/files/usr/local/ec2onrails/bin/init_services +43 -0
- data/server/files/usr/local/ec2onrails/bin/install_system_files +56 -0
- data/server/files/usr/local/ec2onrails/bin/optimize_mysql +346 -0
- data/server/files/usr/local/ec2onrails/bin/public-hostname +24 -0
- data/server/files/usr/local/ec2onrails/bin/rails_env +33 -0
- data/server/files/usr/local/ec2onrails/bin/rebundle +62 -0
- data/server/files/usr/local/ec2onrails/bin/restore_app_db +58 -0
- data/server/files/usr/local/ec2onrails/bin/set_rails_env +36 -0
- data/server/files/usr/local/ec2onrails/bin/set_roles +36 -0
- data/server/files/usr/local/ec2onrails/bin/uninstall_system_files +34 -0
- data/server/files/usr/local/ec2onrails/config +30 -0
- data/server/files/usr/local/ec2onrails/lib/aws_helper.rb +75 -0
- data/server/files/usr/local/ec2onrails/lib/god_helper.rb +84 -0
- data/server/files/usr/local/ec2onrails/lib/mysql_helper.rb +100 -0
- data/server/files/usr/local/ec2onrails/lib/roles_helper.rb +156 -0
- data/server/files/usr/local/ec2onrails/lib/s3_helper.rb +116 -0
- data/server/files/usr/local/ec2onrails/lib/system_files_helper.rb +110 -0
- data/server/files/usr/local/ec2onrails/lib/system_files_manifest.rb +107 -0
- data/server/files/usr/local/ec2onrails/lib/utils.rb +26 -0
- data/server/files/usr/local/ec2onrails/lib/vendor/ini.rb +268 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/every-startup/README +5 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/every-startup/create-mysqld-pid-dir +26 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/README +5 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/create-dirs +45 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/generate-default-web-cert-and-key +49 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/get-hostname +27 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/misc +27 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/prepare-mysql-data-dir +24 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-credentials +32 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-file-permissions +30 -0
- data/server/rakefile-wrapper +26 -0
- data/server/rakefile.rb +267 -0
- data/test/autobench.conf +60 -0
- data/test/spec/lib/s3_helper_spec.rb +154 -0
- data/test/spec/lib/s3_old.yml +3 -0
- data/test/spec/lib/system_files_manifest_spec.rb +122 -0
- data/test/spec/test_files/system_files1/_manifest +13 -0
- data/test/spec/test_files/system_files1/test1 +0 -0
- data/test/spec/test_files/system_files1/test2 +0 -0
- data/test/spec/test_files/system_files1/testfolder/test3 +0 -0
- data/test/spec/test_files/system_files2/_manifest +2 -0
- data/test/spec/test_files/system_files2/test1 +0 -0
- data/test/spec/test_files/system_files2/test2 +0 -0
- data/test/spec/test_files/system_files2/testfolder/test3 +0 -0
- data/test/spec/test_files/test2 +0 -0
- data/test/test_app/Capfile +3 -0
- data/test/test_app/README +243 -0
- data/test/test_app/Rakefile +10 -0
- data/test/test_app/app/controllers/application_controller.rb +10 -0
- data/test/test_app/app/controllers/db_fast_controller.rb +6 -0
- data/test/test_app/app/controllers/fast_controller.rb +5 -0
- data/test/test_app/app/controllers/slow_controller.rb +6 -0
- data/test/test_app/app/controllers/very_slow_controller.rb +6 -0
- data/test/test_app/app/helpers/application_helper.rb +3 -0
- data/test/test_app/config/boot.rb +110 -0
- data/test/test_app/config/database.yml +24 -0
- data/test/test_app/config/deploy.rb +22 -0
- data/test/test_app/config/ec2onrails/config.rb +5 -0
- data/test/test_app/config/environment.rb +41 -0
- data/test/test_app/config/environments/development.rb +17 -0
- data/test/test_app/config/environments/production.rb +28 -0
- data/test/test_app/config/environments/test.rb +28 -0
- data/test/test_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/test_app/config/initializers/inflections.rb +10 -0
- data/test/test_app/config/initializers/mime_types.rb +5 -0
- data/test/test_app/config/initializers/new_rails_defaults.rb +19 -0
- data/test/test_app/config/initializers/session_store.rb +15 -0
- data/test/test_app/config/locales/en.yml +5 -0
- data/test/test_app/config/routes.rb +43 -0
- data/test/test_app/doc/README_FOR_APP +2 -0
- data/test/test_app/public/404.html +30 -0
- data/test/test_app/public/422.html +30 -0
- data/test/test_app/public/500.html +30 -0
- data/test/test_app/public/favicon.ico +0 -0
- data/test/test_app/public/images/rails.png +0 -0
- data/test/test_app/public/index.html +275 -0
- data/test/test_app/public/javascripts/application.js +2 -0
- data/test/test_app/public/javascripts/controls.js +963 -0
- data/test/test_app/public/javascripts/dragdrop.js +973 -0
- data/test/test_app/public/javascripts/effects.js +1128 -0
- data/test/test_app/public/javascripts/prototype.js +4320 -0
- data/test/test_app/public/robots.txt +5 -0
- data/test/test_app/script/about +4 -0
- data/test/test_app/script/console +3 -0
- data/test/test_app/script/dbconsole +3 -0
- data/test/test_app/script/destroy +3 -0
- data/test/test_app/script/generate +3 -0
- data/test/test_app/script/performance/benchmarker +3 -0
- data/test/test_app/script/performance/profiler +3 -0
- data/test/test_app/script/plugin +3 -0
- data/test/test_app/script/runner +3 -0
- data/test/test_app/script/server +3 -0
- data/test/test_app/test/performance/browsing_test.rb +9 -0
- data/test/test_app/test/test_helper.rb +38 -0
- metadata +266 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# This file is part of EC2 on Rails.
|
4
|
+
# http://rubyforge.org/projects/ec2onrails/
|
5
|
+
#
|
6
|
+
# Copyright 2007 Paul Dowman, http://pauldowman.com/
|
7
|
+
#
|
8
|
+
# EC2 on Rails is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# EC2 on Rails is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
|
22
|
+
# Generate a new self-signed cert and key for https
|
23
|
+
|
24
|
+
echo "Generating default self-signed SSL cert and key..."
|
25
|
+
|
26
|
+
export RANDFILE=/tmp/randfile
|
27
|
+
|
28
|
+
cd /tmp
|
29
|
+
openssl genrsa -out server.key 1024
|
30
|
+
openssl req -new -key server.key -out server.csr <<END
|
31
|
+
CA
|
32
|
+
.
|
33
|
+
.
|
34
|
+
.
|
35
|
+
.
|
36
|
+
.
|
37
|
+
.
|
38
|
+
.
|
39
|
+
.
|
40
|
+
|
41
|
+
END
|
42
|
+
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
|
43
|
+
|
44
|
+
mkdir -p /etc/ec2onrails/ssl/cert
|
45
|
+
mkdir -p -m 700 /etc/ec2onrails/ssl/private
|
46
|
+
mv server.key /etc/ec2onrails/ssl/private/ec2onrails-default.key
|
47
|
+
mv server.crt /etc/ec2onrails/ssl/cert/ec2onrails-default.crt
|
48
|
+
rm $RANDFILE
|
49
|
+
rm server.csr
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# This file is part of EC2 on Rails.
|
4
|
+
# http://rubyforge.org/projects/ec2onrails/
|
5
|
+
#
|
6
|
+
# Copyright 2007 Paul Dowman, http://pauldowman.com/
|
7
|
+
#
|
8
|
+
# EC2 on Rails is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# EC2 on Rails is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
# Set the hostname to this instance's public hostname
|
22
|
+
|
23
|
+
HOSTNAME=`curl -s http://169.254.169.254/latest/meta-data/local-hostname`
|
24
|
+
hostname $HOSTNAME
|
25
|
+
|
26
|
+
# Save it so it will be used after reboot
|
27
|
+
echo $HOSTNAME > /etc/hostname
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# This file is part of EC2 on Rails.
|
4
|
+
# http://rubyforge.org/projects/ec2onrails/
|
5
|
+
#
|
6
|
+
# Copyright 2007 Paul Dowman, http://pauldowman.com/
|
7
|
+
#
|
8
|
+
# EC2 on Rails is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# EC2 on Rails is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
|
22
|
+
cp /etc/hosts /etc/hosts.original
|
23
|
+
|
24
|
+
# make sure the db optimize is only run once...
|
25
|
+
# the setup script will look for this flag, and
|
26
|
+
# if it doesn't exist the db optimization won't occur
|
27
|
+
touch /tmp/optimize_db_flag
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# This file is part of EC2 on Rails.
|
4
|
+
# http://rubyforge.org/projects/ec2onrails/
|
5
|
+
#
|
6
|
+
# Copyright 2007 Paul Dowman, http://pauldowman.com/
|
7
|
+
#
|
8
|
+
# EC2 on Rails is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# EC2 on Rails is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
|
22
|
+
mkdir -p /mnt/mysql_data/tmp
|
23
|
+
chown -R mysql:mysql /mnt/mysql_data/
|
24
|
+
cp -rp /var/lib/mysql/mysql /mnt/mysql_data/
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# This file is part of EC2 on Rails.
|
4
|
+
# http://rubyforge.org/projects/ec2onrails/
|
5
|
+
#
|
6
|
+
# Copyright 2007 Paul Dowman, http://pauldowman.com/
|
7
|
+
#
|
8
|
+
# EC2 on Rails is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# EC2 on Rails is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
#
|
21
|
+
# This file helps spread the root key so we can log in/deploy using the
|
22
|
+
# app user instead of root, but with the same ec2 key
|
23
|
+
|
24
|
+
|
25
|
+
# /etc/init.d/ec2-get-credentials is run as /etc/rc2.d/S70ec2-get-credentials,
|
26
|
+
# but this script is run from /etc/rcS.d so the rc2.d scripts haven't
|
27
|
+
# been run yet
|
28
|
+
/etc/init.d/ec2-get-credentials
|
29
|
+
|
30
|
+
mkdir -p -m 700 /home/app/.ssh
|
31
|
+
cp /root/.ssh/authorized_keys /home/app/.ssh
|
32
|
+
chown -R app:app /home/app/.ssh
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# This file is part of EC2 on Rails.
|
4
|
+
# http://rubyforge.org/projects/ec2onrails/
|
5
|
+
#
|
6
|
+
# Copyright 2007 Paul Dowman, http://pauldowman.com/
|
7
|
+
#
|
8
|
+
# EC2 on Rails is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# EC2 on Rails is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
#
|
21
|
+
# Some of the files will need to have additional permissions than the
|
22
|
+
# default settings, especially as the main app and deploy do not run
|
23
|
+
# under the user 'root' but instead under the user 'app'
|
24
|
+
#
|
25
|
+
|
26
|
+
|
27
|
+
chmod 777 /tmp
|
28
|
+
|
29
|
+
#make sure the god files hav the correct permissions set
|
30
|
+
chmod 700 -R /etc/god
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# This file is part of EC2 on Rails.
|
4
|
+
# http://rubyforge.org/projects/ec2onrails/
|
5
|
+
#
|
6
|
+
# Copyright 2007 Paul Dowman, http://pauldowman.com/
|
7
|
+
#
|
8
|
+
# EC2 on Rails is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# EC2 on Rails is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
|
22
|
+
# This script runs the EC2 on Rails rakefile, it's meant to be called by
|
23
|
+
# Eric Hammond's Ubuntu build script: http://alestic.com/
|
24
|
+
|
25
|
+
cd `dirname $0`
|
26
|
+
rake --trace
|
data/server/rakefile.rb
ADDED
@@ -0,0 +1,267 @@
|
|
1
|
+
# This file is part of EC2 on Rails.
|
2
|
+
# http://rubyforge.org/projects/ec2onrails/
|
3
|
+
#
|
4
|
+
# Copyright 2007 Paul Dowman, http://pauldowman.com/
|
5
|
+
#
|
6
|
+
# EC2 on Rails is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# EC2 on Rails is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
|
20
|
+
# This script is meant to be run by rakefile-wrapper, which is run by
|
21
|
+
# Eric Hammond's Ubuntu build script: http://alestic.com/
|
22
|
+
# See the README file for details
|
23
|
+
|
24
|
+
require "rake/clean"
|
25
|
+
require 'yaml'
|
26
|
+
require 'erb'
|
27
|
+
require "#{File.dirname(__FILE__)}/../lib/ec2onrails/version"
|
28
|
+
|
29
|
+
# package notes:
|
30
|
+
# * gcc: libraries needed to compile c/c++ files from source
|
31
|
+
# * libmysqlclient-dev : provide mysqlclient-dev libs, needed for DataObject gems
|
32
|
+
# * nano/vim/less: simle file editors and viewer
|
33
|
+
# * git-core: because we are all using git now, aren't we?
|
34
|
+
# * xfsprogs: help with freezing and resizing of persistent volumes
|
35
|
+
#
|
36
|
+
|
37
|
+
@packages = %w(
|
38
|
+
adduser
|
39
|
+
bison
|
40
|
+
ca-certificates
|
41
|
+
cron
|
42
|
+
curl
|
43
|
+
flex
|
44
|
+
gcc
|
45
|
+
git-core
|
46
|
+
irb
|
47
|
+
less
|
48
|
+
libmysqlclient-dev
|
49
|
+
libmysql-ruby
|
50
|
+
libpcre3-dev
|
51
|
+
libssl-dev
|
52
|
+
libxml2-dev
|
53
|
+
libxslt1-dev
|
54
|
+
libyaml-ruby
|
55
|
+
libzlib-ruby
|
56
|
+
logrotate
|
57
|
+
make
|
58
|
+
mailx
|
59
|
+
memcached
|
60
|
+
mysql-client
|
61
|
+
mysql-server
|
62
|
+
nano
|
63
|
+
openssh-server
|
64
|
+
postfix
|
65
|
+
rdoc
|
66
|
+
ri
|
67
|
+
rsync
|
68
|
+
ruby-full
|
69
|
+
subversion
|
70
|
+
sysstat
|
71
|
+
unzip
|
72
|
+
varnish
|
73
|
+
vim
|
74
|
+
wget
|
75
|
+
xfsprogs
|
76
|
+
)
|
77
|
+
|
78
|
+
# NOTE: the amazon-ec2 gem is now at github, maintained by
|
79
|
+
# grempe-amazon-ec2. Will move back to regular amazon-ec2
|
80
|
+
# gem if/when he cuts a new release with volume and snapshot
|
81
|
+
# support included
|
82
|
+
@rubygems = [
|
83
|
+
"grempe-amazon-ec2",
|
84
|
+
"god",
|
85
|
+
"RubyInline",
|
86
|
+
"memcache-client",
|
87
|
+
"optiflag",
|
88
|
+
"passenger",
|
89
|
+
"rails",
|
90
|
+
"rails -v '~> 2.3.3'",
|
91
|
+
"rails -v '~> 2.2.2'",
|
92
|
+
"rails -v '~> 2.1.2'",
|
93
|
+
"rails -v '~> 2.0.5'",
|
94
|
+
"rails -v '~> 1.2.6'",
|
95
|
+
"rake",
|
96
|
+
"right_aws"
|
97
|
+
]
|
98
|
+
|
99
|
+
@build_root = "/mnt/build"
|
100
|
+
@fs_dir = "#{@build_root}/ubuntu"
|
101
|
+
|
102
|
+
@version = Ec2onrails::VERSION::STRING
|
103
|
+
|
104
|
+
task :default => :configure
|
105
|
+
|
106
|
+
desc "Removes all build files"
|
107
|
+
task :clean_all => :require_root do |t|
|
108
|
+
puts "Unmounting proc and dev from #{@build_root}..."
|
109
|
+
run "umount #{@build_root}/ubuntu/proc", true
|
110
|
+
run "umount #{@build_root}/ubuntu/dev", true
|
111
|
+
|
112
|
+
puts "Removing #{@build_root}..."
|
113
|
+
rm_rf @build_root
|
114
|
+
end
|
115
|
+
|
116
|
+
task :require_root do |t|
|
117
|
+
if `whoami`.strip != 'root'
|
118
|
+
raise "Sorry, this buildfile must be run as root."
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
desc "Use aptitude to install required packages inside the image's filesystem"
|
123
|
+
task :install_packages => :require_root do |t|
|
124
|
+
unless_completed(t) do
|
125
|
+
ENV['DEBIAN_FRONTEND'] = 'noninteractive'
|
126
|
+
ENV['LANG'] = ''
|
127
|
+
run_chroot "apt-get autoremove -y"
|
128
|
+
run_chroot "aptitude update"
|
129
|
+
run_chroot "aptitude install -y #{@packages.join(' ')}"
|
130
|
+
run_chroot "aptitude clean"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
desc "Install required ruby gems inside the image's filesystem"
|
135
|
+
task :install_gems => [:require_root, :install_packages] do |t|
|
136
|
+
unless_completed(t) do
|
137
|
+
version = "1.3.5"
|
138
|
+
dir = "60718"
|
139
|
+
|
140
|
+
filename = "rubygems-#{version}.tgz"
|
141
|
+
url = "http://rubyforge.org/frs/download.php/#{dir}/#{filename}"
|
142
|
+
run_chroot "sh -c 'cd /tmp && wget -q #{url} && tar zxf #{filename}'"
|
143
|
+
run_chroot "sh -c 'cd /tmp/rubygems-#{version} && ruby setup.rb'"
|
144
|
+
run_chroot "ln -sf /usr/bin/gem1.8 /usr/bin/gem"
|
145
|
+
#NOTE: this will update to the most recent rubygems version even if we haven't updated the url here
|
146
|
+
run_chroot "gem update --system --no-rdoc --no-ri"
|
147
|
+
run_chroot "gem update --no-rdoc --no-ri"
|
148
|
+
run_chroot "gem sources -a http://gems.github.com"
|
149
|
+
@rubygems.each do |g|
|
150
|
+
run_chroot "gem install #{g} --no-rdoc --no-ri"
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
desc "Install nginx from source"
|
156
|
+
task :install_nginx => [:require_root, :install_packages, :install_gems] do |t|
|
157
|
+
unless_completed(t) do
|
158
|
+
nginx_version = "nginx-0.7.60"
|
159
|
+
nginx_tar = "#{nginx_version}.tar.gz"
|
160
|
+
|
161
|
+
nginx_img = "http://sysoev.ru/nginx/#{nginx_tar}"
|
162
|
+
fair_bal_img = "http://github.com/gnosek/nginx-upstream-fair/tarball/master"
|
163
|
+
src_dir = "/tmp/src/nginx"
|
164
|
+
# Make sure the dir is created but empty...lets start afresh
|
165
|
+
run_chroot "mkdir -p -m 755 #{src_dir}/ && rm -rf #{src_dir}/*"
|
166
|
+
run_chroot "sh -c 'cd #{src_dir} && wget -q #{nginx_img} && tar -xzf #{nginx_tar}'"
|
167
|
+
run_chroot "sh -c 'cd #{src_dir}/#{nginx_version} && \
|
168
|
+
./configure \
|
169
|
+
--sbin-path=/usr/sbin \
|
170
|
+
--conf-path=/etc/nginx/nginx.conf \
|
171
|
+
--pid-path=/var/run/nginx.pid \
|
172
|
+
--with-http_ssl_module \
|
173
|
+
--with-http_stub_status_module \
|
174
|
+
--add-module=`/usr/bin/passenger-config --root`/ext/nginx && \
|
175
|
+
make && \
|
176
|
+
make install'"
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
desc "Install Ubuntu packages, download and compile other software, and install gems"
|
181
|
+
task :install_software => [:require_root, :install_gems, :install_packages, :install_nginx]
|
182
|
+
|
183
|
+
desc "Configure the image"
|
184
|
+
task :configure => [:require_root, :install_software] do |t|
|
185
|
+
unless_completed(t) do
|
186
|
+
sh("cp -r files/* #{@fs_dir}")
|
187
|
+
replace("#{@fs_dir}/etc/motd.tail", /!!VERSION!!/, "Version #{@version}")
|
188
|
+
|
189
|
+
run_chroot "/usr/sbin/adduser --system --group --disabled-login --no-create-home nginx"
|
190
|
+
run_chroot "/usr/sbin/adduser --gecos ',,,' --disabled-password app"
|
191
|
+
run_chroot "/usr/sbin/addgroup rootequiv"
|
192
|
+
|
193
|
+
run_chroot "cp /root/.gemrc /home/app" # so the app user also has access to gems.github.com
|
194
|
+
run_chroot "chown app:app /home/app/.gemrc"
|
195
|
+
|
196
|
+
run "echo '. /usr/local/ec2onrails/config' >> #{@fs_dir}/root/.bashrc"
|
197
|
+
run "echo '. /usr/local/ec2onrails/config' >> #{@fs_dir}/home/app/.bashrc"
|
198
|
+
|
199
|
+
%w(mysql auth.log daemon.log kern.log mail.err mail.info mail.log mail.warn syslog user.log).each do |f|
|
200
|
+
rm_rf "#{@fs_dir}/var/log/#{f}"
|
201
|
+
run_chroot "ln -sf /mnt/log/#{f} /var/log/#{f}"
|
202
|
+
end
|
203
|
+
|
204
|
+
# Create symlinks to run scripts on startup
|
205
|
+
run_chroot "update-rc.d ec2-first-startup start 91 S ."
|
206
|
+
run_chroot "update-rc.d ec2-every-startup start 92 S ."
|
207
|
+
|
208
|
+
# Disable the services that will be managed by god, depending on the roles
|
209
|
+
%w(nginx mysql memcached varnish varnishncsa).each do |service|
|
210
|
+
run_chroot "update-rc.d -f #{service} remove"
|
211
|
+
run_chroot "update-rc.d #{service} stop 20 2 3 4 5 ."
|
212
|
+
end
|
213
|
+
|
214
|
+
# God is started by upstart so that it will be restarted automatically if it dies,
|
215
|
+
# see /etc/event.d/god
|
216
|
+
|
217
|
+
# Create the mail aliases db
|
218
|
+
run_chroot "postalias /etc/aliases"
|
219
|
+
|
220
|
+
run_chroot "chmod 0440 /etc/sudoers"
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
desc "This task is for deploying the contents of /files to a running server image to test config file changes without rebuilding."
|
225
|
+
task :deploy_files do |t|
|
226
|
+
raise "need 'key' and 'host' env vars defined" unless ENV['key'] && ENV['host']
|
227
|
+
run "rsync -rlvzcCp --rsh='ssh -l root -i #{ENV['key']}' files/ #{ENV['host']}:/"
|
228
|
+
end
|
229
|
+
|
230
|
+
##################
|
231
|
+
|
232
|
+
# Execute a given block and touch a stampfile. The block won't be run if the stampfile exists.
|
233
|
+
def unless_completed(task, &proc)
|
234
|
+
stampfile = "#{@build_root}/#{task.name}.completed"
|
235
|
+
unless File.exists?(stampfile)
|
236
|
+
yield
|
237
|
+
touch stampfile
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
def run_chroot(command, ignore_error = false)
|
242
|
+
run "chroot '#{@fs_dir}' #{command}", ignore_error
|
243
|
+
end
|
244
|
+
|
245
|
+
def run(command, ignore_error = false)
|
246
|
+
puts "*** #{command}"
|
247
|
+
result = system command
|
248
|
+
raise("error: #{$?}") unless result || ignore_error
|
249
|
+
end
|
250
|
+
|
251
|
+
def replace_line(file, newline, linenum)
|
252
|
+
contents = File.open(file, 'r').readlines
|
253
|
+
contents[linenum - 1] = newline
|
254
|
+
File.open(file, 'w') do |f|
|
255
|
+
contents.each {|line| f << line}
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
def replace(file, pattern, text)
|
260
|
+
contents = File.open(file, 'r').readlines
|
261
|
+
contents.each do |line|
|
262
|
+
line.gsub!(pattern, text)
|
263
|
+
end
|
264
|
+
File.open(file, 'w') do |f|
|
265
|
+
contents.each {|line| f << line}
|
266
|
+
end
|
267
|
+
end
|