skippy-ec2onrails 0.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +159 -0
- data/COPYING +339 -0
- data/Manifest +162 -0
- data/README.textile +214 -0
- data/Rakefile +36 -0
- data/TODO +102 -0
- data/ec2onrails.gemspec +42 -0
- data/examples/Capfile +3 -0
- data/examples/deploy.rb +101 -0
- data/examples/s3.yml +9 -0
- data/lib/ec2onrails/capistrano_utils.rb +43 -0
- data/lib/ec2onrails/recipes.rb +844 -0
- data/lib/ec2onrails/version.rb +31 -0
- data/lib/ec2onrails.rb +20 -0
- data/server/build-ec2onrails.sh +44 -0
- data/server/files/etc/aliases +5 -0
- data/server/files/etc/aliases.db +0 -0
- data/server/files/etc/apache2/apache2.conf +295 -0
- data/server/files/etc/apache2/conf.d/app.proxy_cluster.conf +7 -0
- data/server/files/etc/apache2/conf.d/app.proxy_frontend.conf +10 -0
- data/server/files/etc/apache2/mods-available/proxy.conf +18 -0
- data/server/files/etc/apache2/sites-available/app.common +56 -0
- data/server/files/etc/apache2/sites-available/app.custom +0 -0
- data/server/files/etc/apache2/sites-available/default +14 -0
- data/server/files/etc/apache2/sites-available/default-ssl +19 -0
- data/server/files/etc/cron.d/backup_app_db_to_s3 +16 -0
- data/server/files/etc/cron.daily/app +9 -0
- data/server/files/etc/cron.daily/logrotate_post +19 -0
- data/server/files/etc/cron.hourly/app +10 -0
- data/server/files/etc/cron.monthly/app +10 -0
- data/server/files/etc/cron.weekly/app +10 -0
- data/server/files/etc/denyhosts.conf +628 -0
- data/server/files/etc/dpkg/dpkg.cfg +13 -0
- data/server/files/etc/ec2onrails/README +32 -0
- data/server/files/etc/ec2onrails/balancer_members +6 -0
- data/server/files/etc/ec2onrails/roles.yml +5 -0
- data/server/files/etc/environment +2 -0
- data/server/files/etc/god/app.god +35 -0
- data/server/files/etc/god/db.god +17 -0
- data/server/files/etc/god/examples/have_god_daemonize.god +18 -0
- data/server/files/etc/god/master.conf +35 -0
- data/server/files/etc/god/memcache.god +15 -0
- data/server/files/etc/god/notifications.god +14 -0
- data/server/files/etc/god/system.god +34 -0
- data/server/files/etc/god/web.god +36 -0
- data/server/files/etc/init.d/ec2-every-startup +29 -0
- data/server/files/etc/init.d/ec2-first-startup +36 -0
- data/server/files/etc/init.d/god +42 -0
- data/server/files/etc/init.d/nginx +78 -0
- data/server/files/etc/init.d/set_roles +3 -0
- data/server/files/etc/logrotate.d/apache2 +16 -0
- data/server/files/etc/logrotate.d/mongrel +11 -0
- data/server/files/etc/logrotate.d/nginx +11 -0
- data/server/files/etc/memcached.conf +47 -0
- data/server/files/etc/mongrel_cluster/app.yml +9 -0
- data/server/files/etc/motd.tail +13 -0
- data/server/files/etc/mysql/my.cnf +149 -0
- data/server/files/etc/nginx/nginx.conf +296 -0
- data/server/files/etc/postfix/main.cf +4 -0
- data/server/files/etc/rcS.d/S91ec2-first-startup +1 -0
- data/server/files/etc/rcS.d/S92ec2-every-startup +1 -0
- data/server/files/etc/rcS.d/S99set_roles +1 -0
- data/server/files/etc/ssh/sshd_config +94 -0
- data/server/files/etc/sudoers +1 -0
- data/server/files/etc/sudoers.full_access +26 -0
- data/server/files/etc/sudoers.restricted_access +28 -0
- data/server/files/etc/syslog.conf +69 -0
- data/server/files/usr/bin/god +26 -0
- data/server/files/usr/local/ec2onrails/COPYING +339 -0
- data/server/files/usr/local/ec2onrails/bin/archive_file.rb +44 -0
- data/server/files/usr/local/ec2onrails/bin/backup_app_db.rb +159 -0
- data/server/files/usr/local/ec2onrails/bin/ec2_meta_data.rb +80 -0
- data/server/files/usr/local/ec2onrails/bin/exec_runner +73 -0
- data/server/files/usr/local/ec2onrails/bin/init_services.rb +64 -0
- data/server/files/usr/local/ec2onrails/bin/optimize_mysql.rb +348 -0
- data/server/files/usr/local/ec2onrails/bin/rails_env +35 -0
- data/server/files/usr/local/ec2onrails/bin/rebundle.sh +70 -0
- data/server/files/usr/local/ec2onrails/bin/restore_app_db.rb +58 -0
- data/server/files/usr/local/ec2onrails/bin/set_rails_env +40 -0
- data/server/files/usr/local/ec2onrails/bin/set_roles.rb +87 -0
- data/server/files/usr/local/ec2onrails/bin/setup_web_proxy.rb +109 -0
- data/server/files/usr/local/ec2onrails/config +30 -0
- data/server/files/usr/local/ec2onrails/lib/aws_helper.rb +76 -0
- data/server/files/usr/local/ec2onrails/lib/god_helper.rb +129 -0
- data/server/files/usr/local/ec2onrails/lib/god_patch.rb +43 -0
- data/server/files/usr/local/ec2onrails/lib/mysql_helper.rb +101 -0
- data/server/files/usr/local/ec2onrails/lib/roles_helper.rb +151 -0
- data/server/files/usr/local/ec2onrails/lib/s3_helper.rb +99 -0
- data/server/files/usr/local/ec2onrails/lib/utils.rb +16 -0
- data/server/files/usr/local/ec2onrails/lib/vendor/ini.rb +268 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/every-startup/get-hostname.sh +25 -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.sh +39 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/generate-default-web-cert-and-key.sh +49 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/misc.sh +27 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/prepare-mysql-data-dir.sh +24 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-credentials.sh +29 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-file-permissions.sh +30 -0
- data/server/rakefile.rb +242 -0
- data/setup.rb +1585 -0
- data/test/autobench.conf +60 -0
- data/test/spec/lib/s3_helper_spec.rb +134 -0
- data/test/spec/lib/s3_old.yml +3 -0
- data/test/spec/test_files/test1 +0 -0
- data/test/spec/test_files/test2 +0 -0
- data/test/test_app/Capfile +3 -0
- data/test/test_app/README +182 -0
- data/test/test_app/Rakefile +10 -0
- data/test/test_app/app/controllers/application.rb +7 -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/app/helpers/db_fast_helper.rb +2 -0
- data/test/test_app/app/helpers/fast_helper.rb +2 -0
- data/test/test_app/app/helpers/slow_helper.rb +2 -0
- data/test/test_app/app/helpers/very_slow_helper.rb +2 -0
- data/test/test_app/config/boot.rb +109 -0
- data/test/test_app/config/database.yml +19 -0
- data/test/test_app/config/deploy.rb +21 -0
- data/test/test_app/config/environment.rb +60 -0
- data/test/test_app/config/environments/development.rb +21 -0
- data/test/test_app/config/environments/production.rb +18 -0
- data/test/test_app/config/environments/test.rb +19 -0
- data/test/test_app/config/routes.rb +27 -0
- data/test/test_app/db/schema.rb +7 -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/500.html +30 -0
- data/test/test_app/public/dispatch.cgi +10 -0
- data/test/test_app/public/dispatch.fcgi +24 -0
- data/test/test_app/public/dispatch.rb +10 -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/javascripts/application.js +2 -0
- data/test/test_app/public/javascripts/controls.js +963 -0
- data/test/test_app/public/javascripts/dragdrop.js +972 -0
- data/test/test_app/public/javascripts/effects.js +1120 -0
- data/test/test_app/public/javascripts/prototype.js +4225 -0
- data/test/test_app/public/robots.txt +1 -0
- data/test/test_app/script/about +3 -0
- data/test/test_app/script/breakpointer +3 -0
- data/test/test_app/script/console +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/performance/request +3 -0
- data/test/test_app/script/plugin +3 -0
- data/test/test_app/script/process/inspector +3 -0
- data/test/test_app/script/process/reaper +3 -0
- data/test/test_app/script/process/spawner +3 -0
- data/test/test_app/script/runner +3 -0
- data/test/test_app/script/server +3 -0
- data/test/test_app/test/functional/db_fast_controller_test.rb +18 -0
- data/test/test_app/test/functional/fast_controller_test.rb +18 -0
- data/test/test_app/test/functional/slow_controller_test.rb +18 -0
- data/test/test_app/test/functional/very_slow_controller_test.rb +18 -0
- data/test/test_app/test/test_helper.rb +28 -0
- data/test/test_ec2onrails.rb +11 -0
- data/test/test_helper.rb +2 -0
- metadata +274 -0
data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/prepare-mysql-data-dir.sh
ADDED
|
@@ -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,29 @@
|
|
|
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
|
+
#make sure we have the credentials
|
|
25
|
+
/etc/init.d/ec2-get-credentials
|
|
26
|
+
|
|
27
|
+
mkdir -p -m 700 /home/app/.ssh
|
|
28
|
+
cp /root/.ssh/authorized_keys /home/app/.ssh
|
|
29
|
+
chown -R app:app /home/app/.ssh
|
data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-file-permissions.sh
ADDED
|
@@ -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
|
data/server/rakefile.rb
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
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 build-ec2onrails.sh, which is run by
|
|
21
|
+
# Eric Hammond's Ubuntu build script: http://alestic.com/
|
|
22
|
+
# e.g.:
|
|
23
|
+
# bash /mnt/ec2ubuntu-build-ami --script /mnt/ec2onrails/server/build-ec2onrails.sh ...
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
require "rake/clean"
|
|
28
|
+
require 'yaml'
|
|
29
|
+
require 'erb'
|
|
30
|
+
require "#{File.dirname(__FILE__)}/../lib/ec2onrails/version"
|
|
31
|
+
|
|
32
|
+
if `whoami`.strip != 'root'
|
|
33
|
+
raise "Sorry, this buildfile must be run as root."
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# package notes:
|
|
37
|
+
# * aptitude: much better package installation system, especially around
|
|
38
|
+
# upgrades and package dependencies
|
|
39
|
+
# * gcc: libraries needed to compile c/c++ files from source
|
|
40
|
+
# * libmysqlclient-dev : provide mysqlclient-dev libs, needed for DataObject gems
|
|
41
|
+
# * nano/vim/less: simle file editors and viewer
|
|
42
|
+
# * git-core: because we are all using git now, aren't we?
|
|
43
|
+
# * xfsprogs: help with freezing and resizing of persistent volumes
|
|
44
|
+
#
|
|
45
|
+
|
|
46
|
+
@packages = %w(
|
|
47
|
+
adduser
|
|
48
|
+
apache2
|
|
49
|
+
aptitude
|
|
50
|
+
bison
|
|
51
|
+
ca-certificates
|
|
52
|
+
cron
|
|
53
|
+
curl
|
|
54
|
+
flex
|
|
55
|
+
gcc
|
|
56
|
+
git-core
|
|
57
|
+
irb
|
|
58
|
+
less
|
|
59
|
+
libdbm-ruby
|
|
60
|
+
libgdbm-ruby
|
|
61
|
+
libmysql-ruby
|
|
62
|
+
libopenssl-ruby
|
|
63
|
+
libreadline-ruby
|
|
64
|
+
libruby
|
|
65
|
+
libssl-dev
|
|
66
|
+
libyaml-ruby
|
|
67
|
+
libzlib-ruby
|
|
68
|
+
logrotate
|
|
69
|
+
make
|
|
70
|
+
mailx
|
|
71
|
+
memcached
|
|
72
|
+
mysql-client
|
|
73
|
+
mysql-server
|
|
74
|
+
nano
|
|
75
|
+
openssh-server
|
|
76
|
+
postfix
|
|
77
|
+
rdoc
|
|
78
|
+
ri
|
|
79
|
+
rsync
|
|
80
|
+
ruby
|
|
81
|
+
ruby1.8-dev
|
|
82
|
+
subversion
|
|
83
|
+
unzip
|
|
84
|
+
vim
|
|
85
|
+
wget
|
|
86
|
+
xfsprogs
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
# HACK: some packages just fail with apt-get but work fine
|
|
90
|
+
# with aptitude. These generally are virtual packages
|
|
91
|
+
@aptitude_packages = %w(
|
|
92
|
+
libmysqlclient-dev
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# NOTE: the amazon-ec2 gem is now at github, maintained by
|
|
96
|
+
# grempe-amazon-ec2. Will move back to regular amazon-ec2
|
|
97
|
+
# gem if/when he cuts a new release with volume and snapshot
|
|
98
|
+
# support included
|
|
99
|
+
@rubygems = [
|
|
100
|
+
"grempe-amazon-ec2",
|
|
101
|
+
"aws-s3",
|
|
102
|
+
"god",
|
|
103
|
+
"memcache-client",
|
|
104
|
+
"mongrel",
|
|
105
|
+
"mongrel_cluster",
|
|
106
|
+
"optiflag",
|
|
107
|
+
"rails",
|
|
108
|
+
"rails -v '~> 2.0.5'",
|
|
109
|
+
"rails -v '~> 1.2.6'",
|
|
110
|
+
"rake"
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
@build_root = "/mnt/build"
|
|
114
|
+
@fs_dir = "#{@build_root}/ubuntu"
|
|
115
|
+
|
|
116
|
+
@version = [Ec2onrails::VERSION::MAJOR, Ec2onrails::VERSION::MINOR, Ec2onrails::VERSION::TINY].join('.')
|
|
117
|
+
|
|
118
|
+
task :default => :configure
|
|
119
|
+
|
|
120
|
+
desc "Removes all build files"
|
|
121
|
+
task :clean_all do |t|
|
|
122
|
+
rm_rf @build_root
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
desc "Use apt-get to install required packages inside the image's filesystem"
|
|
126
|
+
task :install_packages do |t|
|
|
127
|
+
unless_completed(t) do
|
|
128
|
+
ENV['DEBIAN_FRONTEND'] = 'noninteractive'
|
|
129
|
+
ENV['LANG'] = ''
|
|
130
|
+
run_chroot "apt-get install -y #{@packages.join(' ')}"
|
|
131
|
+
run_chroot "apt-get clean"
|
|
132
|
+
|
|
133
|
+
#lets run the aptitude-only packages
|
|
134
|
+
run_chroot "aptitude install -y #{@aptitude_packages.join(' ')}"
|
|
135
|
+
run_chroot "aptitude clean"
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
desc "Install required ruby gems inside the image's filesystem"
|
|
140
|
+
task :install_gems => [:install_packages] do |t|
|
|
141
|
+
unless_completed(t) do
|
|
142
|
+
run_chroot "sh -c 'cd /tmp && wget -q http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz && tar zxf rubygems-1.3.1.tgz'"
|
|
143
|
+
run_chroot "sh -c 'cd /tmp/rubygems-1.3.1 && ruby setup.rb'"
|
|
144
|
+
run_chroot "ln -sf /usr/bin/gem1.8 /usr/bin/gem"
|
|
145
|
+
#NOTE: this will update to rubygems 1.3 and beyond...
|
|
146
|
+
# this was broken in rubygems 1.1 and 1.2, but it looks like they fixed it
|
|
147
|
+
run_chroot "gem update --system --no-rdoc --no-ri"
|
|
148
|
+
run_chroot "gem update --no-rdoc --no-ri"
|
|
149
|
+
run_chroot "gem sources -a http://gems.github.com"
|
|
150
|
+
@rubygems.each do |gem|
|
|
151
|
+
run_chroot "gem install #{gem} --no-rdoc --no-ri"
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
desc "Configure the image"
|
|
157
|
+
task :configure => [:install_gems] do |t|
|
|
158
|
+
unless_completed(t) do
|
|
159
|
+
sh("cp -r files/* #{@fs_dir}")
|
|
160
|
+
sh("find #{@fs_dir} -type d -name .svn -o -name .git | xargs rm -rf")
|
|
161
|
+
replace("#{@fs_dir}/etc/motd.tail", /!!VERSION!!/, "Version #{@version}")
|
|
162
|
+
|
|
163
|
+
run_chroot "/usr/sbin/adduser --gecos ',,,' --disabled-password app"
|
|
164
|
+
|
|
165
|
+
run "echo '. /usr/local/ec2onrails/config' >> #{@fs_dir}/root/.bashrc"
|
|
166
|
+
run "echo '. /usr/local/ec2onrails/config' >> #{@fs_dir}/home/app/.bashrc"
|
|
167
|
+
|
|
168
|
+
%w(mysql auth.log daemon.log kern.log mail.err mail.info mail.log mail.warn syslog user.log).each do |f|
|
|
169
|
+
rm_rf "#{@fs_dir}/var/log/#{f}"
|
|
170
|
+
run_chroot "ln -sf /mnt/log/#{f} /var/log/#{f}"
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
run "touch #{@fs_dir}/ec2onrails-first-boot"
|
|
174
|
+
|
|
175
|
+
# TODO find out the most correct solution here, there seems to be a bug in
|
|
176
|
+
# both feisty and gutsy where the dhcp daemon runs as dhcp but the dir
|
|
177
|
+
# that it tries to write to is owned by root and not writable by others.
|
|
178
|
+
run_chroot "chown -R dhcp /var/lib/dhcp3"
|
|
179
|
+
|
|
180
|
+
#make sure that god is setup to reboot at startup
|
|
181
|
+
run_chroot "update-rc.d god defaults 98"
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
desc "This task is for deploying the contents of /files to a running server image to test config file changes without rebuilding."
|
|
186
|
+
task :deploy_files do |t|
|
|
187
|
+
raise "need 'key' and 'host' env vars defined" unless ENV['key'] && ENV['host']
|
|
188
|
+
run "rsync -rlvzcC --rsh='ssh -l root -i #{ENV['key']}' files/ #{ENV['host']}:/"
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
##################
|
|
192
|
+
|
|
193
|
+
# Execute a given block and touch a stampfile. The block won't be run if the stampfile exists.
|
|
194
|
+
def unless_completed(task, &proc)
|
|
195
|
+
stampfile = "#{@build_root}/#{task.name}.completed"
|
|
196
|
+
unless File.exists?(stampfile)
|
|
197
|
+
yield
|
|
198
|
+
touch stampfile
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def run_chroot(command, ignore_error = false)
|
|
203
|
+
run "chroot '#{@fs_dir}' #{command}", ignore_error
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def run(command, ignore_error = false)
|
|
207
|
+
puts "*** #{command}"
|
|
208
|
+
result = system command
|
|
209
|
+
raise("error: #{$?}") unless result || ignore_error
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# def mount(type, mount_point)
|
|
213
|
+
# unless mounted?(mount_point)
|
|
214
|
+
# puts
|
|
215
|
+
# puts "********** Mounting #{type} on #{mount_point}..."
|
|
216
|
+
# puts
|
|
217
|
+
# run "mount -t #{type} none #{mount_point}"
|
|
218
|
+
# end
|
|
219
|
+
# end
|
|
220
|
+
#
|
|
221
|
+
# def mounted?(mount_point)
|
|
222
|
+
# mount_point_regex = mount_point.gsub(/\//, "\\/")
|
|
223
|
+
# `mount`.select {|line| line.match(/#{mount_point_regex}/) }.any?
|
|
224
|
+
# end
|
|
225
|
+
|
|
226
|
+
def replace_line(file, newline, linenum)
|
|
227
|
+
contents = File.open(file, 'r').readlines
|
|
228
|
+
contents[linenum - 1] = newline
|
|
229
|
+
File.open(file, 'w') do |f|
|
|
230
|
+
contents.each {|line| f << line}
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def replace(file, pattern, text)
|
|
235
|
+
contents = File.open(file, 'r').readlines
|
|
236
|
+
contents.each do |line|
|
|
237
|
+
line.gsub!(pattern, text)
|
|
238
|
+
end
|
|
239
|
+
File.open(file, 'w') do |f|
|
|
240
|
+
contents.each {|line| f << line}
|
|
241
|
+
end
|
|
242
|
+
end
|