ubuntu-machine-rachid 0.5.3.2.23
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README +15 -0
- data/lib/capistrano/ext/ubuntu-machine/apache.rb +118 -0
- data/lib/capistrano/ext/ubuntu-machine/aptitude.rb +99 -0
- data/lib/capistrano/ext/ubuntu-machine/extras.rb +39 -0
- data/lib/capistrano/ext/ubuntu-machine/ffmpeg.rb +43 -0
- data/lib/capistrano/ext/ubuntu-machine/gems.rb +41 -0
- data/lib/capistrano/ext/ubuntu-machine/git.rb +15 -0
- data/lib/capistrano/ext/ubuntu-machine/helpers.rb +36 -0
- data/lib/capistrano/ext/ubuntu-machine/iptables.rb +20 -0
- data/lib/capistrano/ext/ubuntu-machine/lmsensors.rb +26 -0
- data/lib/capistrano/ext/ubuntu-machine/machine.rb +50 -0
- data/lib/capistrano/ext/ubuntu-machine/mysql.rb +64 -0
- data/lib/capistrano/ext/ubuntu-machine/network.rb +42 -0
- data/lib/capistrano/ext/ubuntu-machine/ntp.rb +37 -0
- data/lib/capistrano/ext/ubuntu-machine/odbc.rb +44 -0
- data/lib/capistrano/ext/ubuntu-machine/php.rb +8 -0
- data/lib/capistrano/ext/ubuntu-machine/postfix.rb +7 -0
- data/lib/capistrano/ext/ubuntu-machine/rails3.rb +7 -0
- data/lib/capistrano/ext/ubuntu-machine/ruby.rb +82 -0
- data/lib/capistrano/ext/ubuntu-machine/ssh.rb +64 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/apache2.erb +7 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/deflate.conf.erb +3 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/freetds.conf.erb +8 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/iptables.erb +46 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/my.cnf.erb +3 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/new_db.erb +5 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/ntp.conf.erb +16 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/ntpdate.erb +13 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/odbc.ini.erb +8 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/odbcinst.ini.erb +7 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/passenger.conf.erb +2 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/passenger.load.erb +1 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/sources.jaunty.erb +55 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/sources.lucid.erb +22 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/sshd_config.erb +80 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/vhost.erb +17 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/vsftpd.conf.erb +158 -0
- data/lib/capistrano/ext/ubuntu-machine/templates/xsendfile.load.erb +1 -0
- data/lib/capistrano/ext/ubuntu-machine/tmpfs.rb +17 -0
- data/lib/capistrano/ext/ubuntu-machine/utils.rb +49 -0
- data/lib/capistrano/ext/ubuntu-machine/vsftpd.rb +63 -0
- data/lib/capistrano/ext/ubuntu-machine.rb +30 -0
- metadata +130 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Thomas Balthazar
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
= View doc here :
|
2
|
+
http://suitmymind.github.com/ubuntu-machine
|
3
|
+
|
4
|
+
= Changelog here :
|
5
|
+
http://suitmymind.github.com/ubuntu-machine/#changelog
|
6
|
+
|
7
|
+
(Note: the above links belong to the official ubuntu-machine; not my fork.)
|
8
|
+
|
9
|
+
= Contributors :
|
10
|
+
- Joseph Glenn
|
11
|
+
- Ahume
|
12
|
+
- Tarik Alkasab
|
13
|
+
- Filip H.F. "FiXato" Slagter
|
14
|
+
- Wes "Narnach" Oldenbeuving
|
15
|
+
- Rachid Al Maach
|
@@ -0,0 +1,118 @@
|
|
1
|
+
namespace :apache do
|
2
|
+
desc "Install Apache"
|
3
|
+
task :install, :roles => :web do
|
4
|
+
sudo "apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert -y"
|
5
|
+
|
6
|
+
run "cat /etc/apache2/apache2.conf > ~/apache2.conf.tmp"
|
7
|
+
put render("apache2", binding), "apache2.append.conf.tmp"
|
8
|
+
run "cat apache2.append.conf.tmp >> ~/apache2.conf.tmp"
|
9
|
+
sudo "mv ~/apache2.conf.tmp /etc/apache2/apache2.conf"
|
10
|
+
run "rm apache2.append.conf.tmp"
|
11
|
+
restart
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Restarts Apache webserver"
|
15
|
+
task :restart, :roles => :web do
|
16
|
+
sudo "/etc/init.d/apache2 restart"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Starts Apache webserver"
|
20
|
+
task :start, :roles => :web do
|
21
|
+
sudo "/etc/init.d/apache2 start"
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Stops Apache webserver"
|
25
|
+
task :stop, :roles => :web do
|
26
|
+
sudo "/etc/init.d/apache2 stop"
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Reload Apache webserver"
|
30
|
+
task :reload, :roles => :web do
|
31
|
+
sudo "/etc/init.d/apache2 reload"
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Force reload Apache webserver"
|
35
|
+
task :force_reload, :roles => :web do
|
36
|
+
sudo "/etc/init.d/apache2 force-reload"
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "List enabled Apache sites"
|
40
|
+
task :enabled_sites, :roles => :web do
|
41
|
+
run "ls /etc/apache2/sites-enabled"
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "List available Apache sites"
|
45
|
+
task :available_sites, :roles => :web do
|
46
|
+
run "ls /etc/apache2/sites-available"
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "List enabled Apache modules"
|
50
|
+
task :enabled_modules, :roles => :web do
|
51
|
+
run "ls /etc/apache2/mods-enabled"
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "List available Apache modules"
|
55
|
+
task :available_modules, :roles => :web do
|
56
|
+
run "ls /etc/apache2/mods-available"
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "Disable Apache site"
|
60
|
+
task :disable_site, :roles => :web do
|
61
|
+
site = Capistrano::CLI.ui.ask("Which site should we disable: ")
|
62
|
+
sudo "sudo a2dissite #{site}"
|
63
|
+
reload
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "Enable Apache site"
|
67
|
+
task :enable_site, :roles => :web do
|
68
|
+
site = Capistrano::CLI.ui.ask("Which site should we enable: ")
|
69
|
+
sudo "sudo a2ensite #{site}"
|
70
|
+
reload
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "Disable Apache module"
|
74
|
+
task :disable_module, :roles => :web do
|
75
|
+
mod = Capistrano::CLI.ui.ask("Which module should we disable: ")
|
76
|
+
sudo "sudo a2dismod #{mod}"
|
77
|
+
force_reload
|
78
|
+
end
|
79
|
+
|
80
|
+
desc "Enable Apache module"
|
81
|
+
task :enable_module, :roles => :web do
|
82
|
+
mod = Capistrano::CLI.ui.ask("Which module should we enable: ")
|
83
|
+
sudo "sudo a2enmod #{mod}"
|
84
|
+
force_reload
|
85
|
+
end
|
86
|
+
|
87
|
+
desc "Create a new website"
|
88
|
+
task :create_website, :roles => :web do
|
89
|
+
server_admin = Capistrano::CLI.ui.ask("Server admin (#{default_server_admin}) if blank : ")
|
90
|
+
server_admin = default_server_admin if server_admin.empty?
|
91
|
+
server_name = Capistrano::CLI.ui.ask("Server name : ")
|
92
|
+
server_alias = Capistrano::CLI.ui.ask("Server alias : ")
|
93
|
+
directory_index = Capistrano::CLI.ui.ask("Directory index (#{default_directory_index}) if blank : ")
|
94
|
+
directory_index = default_directory_index if directory_index.empty?
|
95
|
+
|
96
|
+
# Website skeleton
|
97
|
+
%w{backup cap cgi-bin logs private public tmp}.each { |d|
|
98
|
+
run "mkdir -p /home/#{user}/websites/#{server_name}/#{d}"
|
99
|
+
}
|
100
|
+
|
101
|
+
put render("vhost", binding), server_name
|
102
|
+
sudo "mv #{server_name} /etc/apache2/sites-available/#{server_name}"
|
103
|
+
sudo "sudo a2ensite #{server_name}"
|
104
|
+
reload
|
105
|
+
end
|
106
|
+
|
107
|
+
desc "Delete a website (! delete all file and folders)"
|
108
|
+
task :delete_website, :roles => :web do
|
109
|
+
server_name = Capistrano::CLI.ui.ask("Server name you want to delete : ")
|
110
|
+
sure = Capistrano::CLI.ui.ask("Are you sure you want to delete #{server_name} and all its files? (y/n) : ")
|
111
|
+
if sure=="y"
|
112
|
+
sudo "sudo a2dissite #{server_name}"
|
113
|
+
sudo "rm /etc/apache2/sites-available/#{server_name}"
|
114
|
+
sudo "rm -Rf /home/#{user}/websites/#{server_name}"
|
115
|
+
reload
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
namespace :aptitude do
|
2
|
+
desc <<-DESC
|
3
|
+
Updates your software package list. This will not "upgrade" any of your \
|
4
|
+
installed software.
|
5
|
+
|
6
|
+
See "Update" section on \
|
7
|
+
http://articles.slicehost.com/2007/11/6/ubuntu-gutsy-setup-page-2
|
8
|
+
DESC
|
9
|
+
task :update, :roles => :app do
|
10
|
+
sudo "apt-get update"
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Alias for 'aptitude:safe_upgrade'"
|
14
|
+
task :upgrade, :roles => :app do
|
15
|
+
safe_upgrade
|
16
|
+
end
|
17
|
+
|
18
|
+
desc <<-DESC
|
19
|
+
Upgrades your installed software packages.
|
20
|
+
|
21
|
+
From the aptitude man pages:
|
22
|
+
|
23
|
+
This command will upgrade as many packages as it can upgrade without \
|
24
|
+
removing existing packages or installing new ones.
|
25
|
+
|
26
|
+
It is sometimes necessary to remove or install one package in order to \
|
27
|
+
upgrade another; this command is not able to upgrade packages in such \
|
28
|
+
situations. Use the full-upgrade to upgrade those packages as well.
|
29
|
+
|
30
|
+
See "Upgrade" section on \
|
31
|
+
http://articles.slicehost.com/2007/11/6/ubuntu-gutsy-setup-page-2
|
32
|
+
DESC
|
33
|
+
task :safe_upgrade, :roles => :app do
|
34
|
+
|
35
|
+
# to prevent interactive mode to block the install script
|
36
|
+
sudo 'aptitude hold console-setup -y'
|
37
|
+
|
38
|
+
# By default, OVH replace the original /etc/issue. The safe_upgrade will then ask \
|
39
|
+
# if it must overwrite this file, since it has been modified by OVH. \
|
40
|
+
# data =~ /^\*\*\*\sissue/ looks for the interactive prompt to enable you to answer
|
41
|
+
sudo_and_watch_prompt("aptitude safe-upgrade -y", /^\*\*\*\sissue/)
|
42
|
+
end
|
43
|
+
|
44
|
+
desc <<-DESC
|
45
|
+
Upgrades your installed software packages.
|
46
|
+
|
47
|
+
From the aptitude man pages:
|
48
|
+
|
49
|
+
Like safe-upgrade, this command will attempt to upgrade packages, but it is \
|
50
|
+
more aggressive about solving dependency problems: it will install and \
|
51
|
+
remove packages until all dependencies are satisfied. Because of the nature \
|
52
|
+
of this command, it is possible that it will do undesirable things, and so \
|
53
|
+
you should be careful when using it.
|
54
|
+
|
55
|
+
See "Upgrade" section on \
|
56
|
+
http://articles.slicehost.com/2007/11/6/ubuntu-gutsy-setup-page-2
|
57
|
+
DESC
|
58
|
+
task :full_upgrade, :roles => :app do
|
59
|
+
sudo "aptitude full-upgrade -y"
|
60
|
+
end
|
61
|
+
|
62
|
+
desc <<-DESC
|
63
|
+
Installs a software package via aptitude. You will be prompted for the \
|
64
|
+
package name after running this commmand.
|
65
|
+
DESC
|
66
|
+
task :install, :roles => :app do
|
67
|
+
package = Capistrano::CLI.ui.ask("Which package should we install: ")
|
68
|
+
sudo "apt-get install #{package}"
|
69
|
+
end
|
70
|
+
|
71
|
+
desc <<-DESC
|
72
|
+
Uninstalls a software package via aptitude. You will be prompted for the \
|
73
|
+
package name after running this commmand.
|
74
|
+
DESC
|
75
|
+
task :uninstall, :roles => :app do
|
76
|
+
package = Capistrano::CLI.ui.ask("Which package should we uninstall: ")
|
77
|
+
sudo "apt-get remove #{package}"
|
78
|
+
end
|
79
|
+
|
80
|
+
desc <<-DESC
|
81
|
+
Updates software packages and creates "a solid base for the 'meat' of the \
|
82
|
+
server". This task should be run only once when you are first setting up your \
|
83
|
+
new slice.
|
84
|
+
|
85
|
+
See "Update", "locales", "Upgrade" and "build essentials" sections on \
|
86
|
+
http://articles.slicehost.com/2007/11/6/ubuntu-gutsy-setup-page-2
|
87
|
+
DESC
|
88
|
+
task :setup, :roles => :app do
|
89
|
+
put render("sources.lucid", binding), "sources.list"
|
90
|
+
sudo "mv sources.list /etc/apt/sources.list"
|
91
|
+
sudo "apt-get update"
|
92
|
+
update
|
93
|
+
sudo "locale-gen en_GB.UTF-8"
|
94
|
+
sudo "/usr/sbin/update-locale LANG=en_GB.UTF-8"
|
95
|
+
safe_upgrade
|
96
|
+
full_upgrade
|
97
|
+
sudo "apt-get install -y build-essential"
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
namespace :extras do
|
2
|
+
desc "Installs extra utils: curl, lynx, mailutils, munin, imagemagick"
|
3
|
+
task :install_all do
|
4
|
+
install_curl
|
5
|
+
install_lynx
|
6
|
+
install_mailutils
|
7
|
+
install_munin
|
8
|
+
install_imagemagick
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Installs extra util curl"
|
12
|
+
task :install_curl do
|
13
|
+
sudo "aptitude install -y curl"
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Installs extra util lynx"
|
17
|
+
task :install_lynx do
|
18
|
+
sudo "aptitude install -y lynx"
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Installs extra util mailutils"
|
22
|
+
task :install_mailutils do
|
23
|
+
sudo "aptitude install -y mailutils"
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "Installs extra util munin"
|
27
|
+
task :install_munin do
|
28
|
+
sudo "aptitude install -y munin"
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Installs extra util imagemagick"
|
32
|
+
task :install_imagemagick do
|
33
|
+
sudo "apt-get install libmagick9-dev librmagick-ruby1.8 librmagick-ruby libmagickcore-dev msttcorefonts imagemagick libmagickwand-dev"
|
34
|
+
sudo "ldconfig"
|
35
|
+
sudo "gem install rmagick"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
@@ -0,0 +1,43 @@
|
|
1
|
+
namespace :ffmpeg do
|
2
|
+
# FFmpeg install has been tested in June 2009 as working with these settings:
|
3
|
+
# set :x264_commit_hash, '2c597171d5126c3ccae7546f6699d6c4d8ec5e3a'
|
4
|
+
# set :ffmpeg_commit_hash, 'cc32213534573a127e01a0e2ed4962eb4b1939fd'
|
5
|
+
# set :libswscale_commit_hash, '0fa4ae3fc08f75277e2c1f225561053243f18576'
|
6
|
+
_cset :x264_commit_hash, ''
|
7
|
+
_cset :ffmpeg_commit_hash, ''
|
8
|
+
_cset :libswscale_commit_hash, ''
|
9
|
+
|
10
|
+
desc 'Install FFmpeg dependencies'
|
11
|
+
task :install_dependencies, :roles => :app do
|
12
|
+
#TODO: Ensure that the multiverse repositories/sources are available and being used by aptitude \
|
13
|
+
# otherwise add them to /etc/apt/sources.list since they are needed for libraries such as libmp3lame-dev
|
14
|
+
sudo "aptitude install -y ccache checkinstall fakeroot liba52-0.7.4-dev liba52-dev libfaac-dev libfaad-dev libfreetype6-dev libgpac-dev libjpeg62-dev liblame-dev liblame0 libmp3lame-dev libogg-dev libpng12-dev libtheora-dev libtiff4-dev libvorbis-dev libxvidcore4-dev"
|
15
|
+
run "wget http://www.tortall.net/projects/yasm/releases/yasm-0.7.1.tar.gz -O yasm-0.7.1.tar.gz && tar -xzf yasm-0.7.1.tar.gz && cd yasm-0.7.1 && ./configure && make && sudo checkinstall -y"
|
16
|
+
sudo "ldconfig"
|
17
|
+
run "if test -x x264; then cd x264 && git checkout master && git pull; else git clone git://git.videolan.org/x264.git; fi"
|
18
|
+
if x264_commit_hash.size > 0
|
19
|
+
run "cd x264 && git checkout #{x264_commit_hash}"
|
20
|
+
end
|
21
|
+
run "cd x264 && ./configure --enable-pthread --enable-mp4-output --enable-shared --enable-pic --extra-asflags='-fPIC' --extra-cflags='-march=k8 -mtune=k8 -pipe -fomit-frame-pointer' && make && sudo checkinstall -y"
|
22
|
+
sudo "ldconfig"
|
23
|
+
run "wget http://ftp.penguin.cz/pub/users/utx/amr/amrnb-7.0.0.2.tar.bz2 -O amrnb-7.0.0.2.tar.bz2 && tar -xjf amrnb-7.0.0.2.tar.bz2 && cd amrnb-7.0.0.2 && ./configure && make && sudo make install"
|
24
|
+
run "wget http://ftp.penguin.cz/pub/users/utx/amr/amrwb-7.0.0.3.tar.bz2 -O amrwb-7.0.0.3.tar.bz2 && tar -xjf amrwb-7.0.0.3.tar.bz2 && cd amrwb-7.0.0.3 && ./configure && make && sudo make install"
|
25
|
+
sudo "ldconfig"
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'Install FFmpeg'
|
29
|
+
task :install, :roles => :app do
|
30
|
+
install_dependencies
|
31
|
+
run "if test -x ffmpeg; then cd ffmpeg && git checkout master && git pull; else git clone git://git.ffmpeg.org/ffmpeg; fi"
|
32
|
+
run "if test -x ffmpeg/libswscale; then cd ffmpeg/libswscale && git checkout master && git pull; else cd ffmpeg && git clone git://git.ffmpeg.org/libswscale; fi"
|
33
|
+
if ffmpeg_commit_hash.size > 0
|
34
|
+
run "cd ffmpeg && git checkout #{ffmpeg_commit_hash}"
|
35
|
+
end
|
36
|
+
if libswscale_commit_hash.size > 0
|
37
|
+
run "cd ffmpeg/libswscale && git checkout #{libswscale_commit_hash}"
|
38
|
+
end
|
39
|
+
sudo "ldconfig"
|
40
|
+
run "cd ffmpeg && ./configure --enable-gpl --enable-shared --enable-nonfree --enable-libfaadbin --enable-libamr-nb --enable-libamr-wb --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libx264 --enable-pthreads --enable-libxvid --disable-liba52 --disable-libvorbis --disable-libtheora --disable-libgsm --disable-postproc --disable-swscale --disable-debug --cc='ccache gcc' && make && sudo checkinstall -y"
|
41
|
+
sudo "ldconfig"
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
namespace :gems do
|
2
|
+
desc "Install RubyGems"
|
3
|
+
task :install_rubygems, :roles => :app do
|
4
|
+
sudo "apt-get install wget"
|
5
|
+
|
6
|
+
run "wget http://production.cf.rubygems.org/rubygems/rubygems-#{rubygem_version}.tgz"
|
7
|
+
run "tar xvzf rubygems-#{rubygem_version}.tgz"
|
8
|
+
run "cd rubygems-#{rubygem_version} && sudo ruby setup.rb"
|
9
|
+
sudo "ln -s /usr/bin/gem1.8 /usr/bin/gem"
|
10
|
+
sudo "gem update"
|
11
|
+
sudo "gem update --system"
|
12
|
+
run "rm -Rf rubygems-#{rubygem_version}*"
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "List gems on remote server"
|
16
|
+
task :list, :roles => :app do
|
17
|
+
stream "gem list"
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Update gems on remote server"
|
21
|
+
task :update, :roles => :app do
|
22
|
+
sudo "gem update"
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Update gem system on remote server"
|
26
|
+
task :update_system, :roles => :app do
|
27
|
+
sudo "gem update --system"
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Install a gem on the remote server"
|
31
|
+
task :install, :roles => :app do
|
32
|
+
name = Capistrano::CLI.ui.ask("Which gem should we install: ")
|
33
|
+
sudo "gem install #{name}"
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Uninstall a gem on the remote server"
|
37
|
+
task :uninstall, :roles => :app do
|
38
|
+
name = Capistrano::CLI.ui.ask("Which gem should we uninstall: ")
|
39
|
+
sudo "gem uninstall #{name}"
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
namespace :git do
|
2
|
+
desc "Install git"
|
3
|
+
task :install, :roles => :app do
|
4
|
+
sudo "sudo apt-get build-dep git-core -y"
|
5
|
+
run "wget http://kernel.org/pub/software/scm/git/#{git_version}.tar.gz"
|
6
|
+
run "tar xvzf #{git_version}.tar.gz"
|
7
|
+
run "cd #{git_version}"
|
8
|
+
run "cd #{git_version} && ./configure"
|
9
|
+
run "cd #{git_version} && make"
|
10
|
+
run "cd #{git_version} && sudo make install"
|
11
|
+
run "rm #{git_version}.tar.gz"
|
12
|
+
run "rm -Rf #{git_version}"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
# render a template
|
4
|
+
def render(file, binding)
|
5
|
+
template = File.read("#{File.dirname(__FILE__)}/templates/#{file}.erb")
|
6
|
+
result = ERB.new(template).result(binding)
|
7
|
+
end
|
8
|
+
|
9
|
+
# allows to sudo a command which require the user input via the prompt
|
10
|
+
def sudo_and_watch_prompt(cmd, regex_to_watch)
|
11
|
+
sudo cmd, :pty => true do |ch, stream, data|
|
12
|
+
watch_prompt(ch, stream, data, regex_to_watch)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# allows to run a command which require the user input via the prompt
|
17
|
+
def run_and_watch_prompt(cmd, regex_to_watch)
|
18
|
+
run cmd, :pty => true do |ch, stream, data|
|
19
|
+
watch_prompt(ch, stream, data, regex_to_watch)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# utility method called by sudo_and_watch_prompt and run_and_watch_prompt
|
24
|
+
def watch_prompt(ch, stream, data, regex_to_watch)
|
25
|
+
|
26
|
+
# the regex can be an array or a single regex -> we force it to always be an array with [*xx]
|
27
|
+
if [*regex_to_watch].find { |regex| data =~ regex}
|
28
|
+
# prompt, and then send the response to the remote process
|
29
|
+
ch.send_data(Capistrano::CLI.password_prompt(data) + "\n")
|
30
|
+
else
|
31
|
+
# use the default handler for all other text
|
32
|
+
Capistrano::Configuration.default_io_proc.call(ch, stream, data)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
namespace :iptables do
|
2
|
+
desc <<-DESC
|
3
|
+
Harden iptables configuration. Only allows ssh, http, and https connections and packets from SAN.
|
4
|
+
|
5
|
+
See "iptables" section on \
|
6
|
+
http://articles.slicehost.com/2008/4/25/ubuntu-hardy-setup-page-1
|
7
|
+
DESC
|
8
|
+
task :configure, :roles => :gateway do
|
9
|
+
sudo "apt-get install iptables -y"
|
10
|
+
put render("iptables", binding), "iptables.up.rules"
|
11
|
+
sudo "mv iptables.up.rules /etc/iptables.up.rules"
|
12
|
+
|
13
|
+
sudo "iptables-restore < /etc/iptables.up.rules"
|
14
|
+
|
15
|
+
# ensure that the iptables rules are applied when we reboot the server
|
16
|
+
run "cat /etc/network/interfaces > ~/tmp_interfaces"
|
17
|
+
run "echo 'pre-up iptables-restore < /etc/iptables.up.rules' >> ~/tmp_interfaces"
|
18
|
+
sudo "mv ~/tmp_interfaces /etc/network/interfaces"
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
namespace :lmsensors do
|
3
|
+
desc "Install lmsensors. Not relevant for virtual servers as they usually do not have sensors available."
|
4
|
+
task :install do
|
5
|
+
sudo "aptitude install -y lm-sensors"
|
6
|
+
to_probe = []
|
7
|
+
sudo "sensors-detect", :pty => true do |ch, stream, data|
|
8
|
+
if [/YES\/no/,/yes\/NO/,/to continue/].find { |regex| data =~ regex}
|
9
|
+
# prompt, and then send the response to the remote process
|
10
|
+
ch.send_data(Capistrano::CLI.ui.ask(data) + "\n")
|
11
|
+
elsif offset = data =~ /#----cut here----\s+# Chip drivers/
|
12
|
+
text = data[offset,data.size - offset]
|
13
|
+
text.gsub!('# Chip drivers','').gsub!('#----cut here----','')
|
14
|
+
to_probe = text.strip.split("\n").map{|str| str.strip}
|
15
|
+
Capistrano::Configuration.default_io_proc.call(ch, stream, data)
|
16
|
+
else
|
17
|
+
# use the default handler for all other text
|
18
|
+
Capistrano::Configuration.default_io_proc.call(ch, stream, data)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
puts "Will modprobe the following modules: %s" % to_probe.join(',')
|
22
|
+
to_probe.each do |mod|
|
23
|
+
sudo "modprobe #{mod}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
namespace :machine do
|
2
|
+
|
3
|
+
desc "Change the root password, create a new user and allow him to sudo and to SSH"
|
4
|
+
task :initial_setup do
|
5
|
+
set :user_to_create , user
|
6
|
+
set :user, 'root'
|
7
|
+
|
8
|
+
run_and_watch_prompt("passwd", [/Enter new UNIX password/, /Retype new UNIX password:/])
|
9
|
+
|
10
|
+
run_and_watch_prompt("adduser #{user_to_create}", [/Enter new UNIX password/, /Retype new UNIX password:/, /\[\]\:/, /\[y\/N\]/i])
|
11
|
+
|
12
|
+
# force the non-interactive mode
|
13
|
+
run "cat /etc/environment > ~/environment.tmp"
|
14
|
+
run 'echo DEBIAN_FRONTEND=noninteractive >> ~/environment.tmp'
|
15
|
+
sudo 'mv ~/environment.tmp /etc/environment'
|
16
|
+
# prevent this env variable to be skipped by sudo
|
17
|
+
run "echo 'Defaults env_keep = \"DEBIAN_FRONTEND\"' >> /etc/sudoers"
|
18
|
+
|
19
|
+
run "echo '#{user_to_create} ALL=(ALL)ALL' >> /etc/sudoers"
|
20
|
+
run "echo 'AllowUsers #{user_to_create}' >> /etc/ssh/sshd_config"
|
21
|
+
run "/etc/init.d/ssh reload"
|
22
|
+
end
|
23
|
+
|
24
|
+
task :configure do
|
25
|
+
ssh.setup
|
26
|
+
iptables.configure
|
27
|
+
aptitude.setup
|
28
|
+
end
|
29
|
+
|
30
|
+
task :install_dev_tools do
|
31
|
+
mysql.install
|
32
|
+
apache.install
|
33
|
+
ruby.install
|
34
|
+
postfix.install
|
35
|
+
gems.install_rubygems
|
36
|
+
ruby.install_enterprise
|
37
|
+
ruby.install_passenger
|
38
|
+
git.install
|
39
|
+
php.install
|
40
|
+
rails3.install
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
desc = "Ask for a user and change his password"
|
45
|
+
task :change_password do
|
46
|
+
user_to_update = Capistrano::CLI.ui.ask("Name of the user whose you want to update the password : ")
|
47
|
+
|
48
|
+
run_and_watch_prompt("passwd #{user_to_update}", [/Enter new UNIX password/, /Retype new UNIX password:/])
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#TODO : change root password
|
2
|
+
|
3
|
+
namespace :mysql do
|
4
|
+
desc "Restarts MySQL database server"
|
5
|
+
task :restart, :roles => :db do
|
6
|
+
sudo "/etc/init.d/mysql restart"
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Starts MySQL database server"
|
10
|
+
task :start, :roles => :db do
|
11
|
+
sudo "/etc/init.d/mysql start"
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Stops MySQL database server"
|
15
|
+
task :stop, :roles => :db do
|
16
|
+
sudo "/etc/init.d/mysql stop"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Export MySQL database"
|
20
|
+
task :export, :roles => :db do
|
21
|
+
database = Capistrano::CLI.ui.ask("Which database should we export: ")
|
22
|
+
sudo_and_watch_prompt("mysqldump -u root -p #{database} > #{database}.sql", /Enter\spassword/)
|
23
|
+
download "#{database}.sql", "#{default_local_files_path}/database.sql"
|
24
|
+
run "rm #{database}.sql"
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Create a new MySQL database, a new MySQL user, and load a local MySQL dump file"
|
28
|
+
task :create_database, :roles => :db do
|
29
|
+
db_root_password = Capistrano::CLI.ui.ask("MySQL root password : ")
|
30
|
+
db_name = Capistrano::CLI.ui.ask("Which database should we create: ")
|
31
|
+
db_username = Capistrano::CLI.ui.ask("Which database username should we create: ")
|
32
|
+
db_user_password = Capistrano::CLI.ui.ask("Choose a password for the new database username: ")
|
33
|
+
file_to_upload = Capistrano::CLI.ui.ask("Do you want to import a database file? (y/n) : ")
|
34
|
+
if file_to_upload == "y"
|
35
|
+
file = Capistrano::CLI.ui.ask("Which database file should we import (it must be located in #{default_local_files_path}): ")
|
36
|
+
upload "#{default_local_files_path}/#{file}", "#{file}"
|
37
|
+
end
|
38
|
+
create_db_tmp_file = "create_#{db_name}.sql"
|
39
|
+
put render("new_db", binding), create_db_tmp_file
|
40
|
+
run "mysql -u root -p#{db_root_password} < #{create_db_tmp_file}"
|
41
|
+
if file_to_upload == "y"
|
42
|
+
run "mysql -u root -p#{db_root_password} #{db_name} < #{file}"
|
43
|
+
run "rm #{file}"
|
44
|
+
end
|
45
|
+
run "rm #{create_db_tmp_file}"
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "Install MySQL"
|
49
|
+
task :install, :roles => :db do
|
50
|
+
db_root_password = Capistrano::CLI.ui.ask("Choose a MySQL root password : ")
|
51
|
+
|
52
|
+
sudo "aptitude install -y mysql-server mysql-client libmysqlclient15-dev"
|
53
|
+
run "mysqladmin -u root password #{db_root_password}"
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "Ask for a MySQL user and change his password"
|
57
|
+
task :change_password, :roles => :db do
|
58
|
+
user_to_update = Capistrano::CLI.ui.ask("Name of the MySQL user whose you want to update the password : ")
|
59
|
+
old_password = Capistrano::CLI.ui.ask("Old password for #{user_to_update} : ")
|
60
|
+
new_password = Capistrano::CLI.ui.ask("New password for #{user_to_update} : ")
|
61
|
+
|
62
|
+
run "mysqladmin -u #{user_to_update} -p#{old_password} password \"#{new_password}\""
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
namespace :network do
|
2
|
+
_cset :network_interfaces_config do
|
3
|
+
abort "Please specify the location of the /etc/network/interfaces config you want to upload.\n For example:\n set :network_interfaces_config, File.expand_path(File.join(File.dirname(__FILE__),'interfaces'))"
|
4
|
+
end
|
5
|
+
_cset :resolv_config do
|
6
|
+
abort "Please specify the location of the /etc/resolv.conf config you want to upload.\n For example:\n set :resolv_config, File.expand_path(File.join(File.dirname(__FILE__),'resolv.conf'))"
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Configure /etc/resolv.conf and /etc/network/interfaces"
|
10
|
+
task :configure do
|
11
|
+
configure_resolv_conf
|
12
|
+
configure_network_interfaces
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Configure network interfaces"
|
16
|
+
task :configure_network_interfaces do
|
17
|
+
put File.read(network_interfaces_config), "interfaces.tmp"
|
18
|
+
sudo "mv interfaces.tmp /etc/network/interfaces"
|
19
|
+
restart
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Configure /etc/resolv.conf"
|
23
|
+
task :configure_resolv_conf do
|
24
|
+
put File.read(resolv_config), "resolv.conf.tmp"
|
25
|
+
sudo "mv resolv.conf.tmp /etc/resolv.conf"
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Start the network"
|
29
|
+
task :start do
|
30
|
+
sudo "/etc/init.d/networking start"
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Restart the network"
|
34
|
+
task :restart do
|
35
|
+
sudo "/etc/init.d/networking restart"
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Stop the network"
|
39
|
+
task :stop do
|
40
|
+
sudo "/etc/init.d/networking stop"
|
41
|
+
end
|
42
|
+
end
|