FiXato-ubuntu-machine 0.5.3.2.11 → 0.5.3.2.20

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -10,4 +10,5 @@ http://suitmymind.github.com/ubuntu-machine/#changelog
10
10
  - Joseph Glenn
11
11
  - Ahume
12
12
  - Tarik Alkasab
13
- - Filip H.F. "FiXato" Slagter
13
+ - Filip H.F. "FiXato" Slagter
14
+ - Wes "Narnach" Oldenbeuving
@@ -1,7 +1,10 @@
1
1
  namespace :apache do
2
+ _cset(:sites_path) { "/home/#{user}/websites" }
3
+
2
4
  desc "Install Apache"
3
5
  task :install, :roles => :web do
4
6
  sudo "apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert -y"
7
+ _cset(:server_name) {Capistrano::CLI.ui.ask("Server name : ")}
5
8
 
6
9
  run "cat /etc/apache2/apache2.conf > ~/apache2.conf.tmp"
7
10
  put render("apache2", binding), "apache2.append.conf.tmp"
@@ -90,12 +93,15 @@ namespace :apache do
90
93
  server_admin = default_server_admin if server_admin.empty?
91
94
  server_name = Capistrano::CLI.ui.ask("Server name : ")
92
95
  server_alias = Capistrano::CLI.ui.ask("Server alias : ")
96
+ server_port = Capistrano::CLI.ui.ask("Server port (80) if blank : ")
97
+ server_port = 80 if server_port.empty?
93
98
  directory_index = Capistrano::CLI.ui.ask("Directory index (#{default_directory_index}) if blank : ")
94
99
  directory_index = default_directory_index if directory_index.empty?
100
+ document_root = "#{sites_path}/#{server_name}/public"
95
101
 
96
102
  # Website skeleton
97
103
  %w{backup cap cgi-bin logs private public tmp}.each { |d|
98
- run "mkdir -p /home/#{user}/websites/#{server_name}/#{d}"
104
+ run "mkdir -p #{sites_path}/#{server_name}/#{d}"
99
105
  }
100
106
 
101
107
  put render("vhost", binding), server_name
@@ -111,7 +117,7 @@ namespace :apache do
111
117
  if sure=="y"
112
118
  sudo "sudo a2dissite #{server_name}"
113
119
  sudo "rm /etc/apache2/sites-available/#{server_name}"
114
- sudo "rm -Rf /home/#{user}/websites/#{server_name}"
120
+ sudo "rm -Rf #{sites_path}/#{server_name}"
115
121
  reload
116
122
  end
117
123
  end
@@ -130,6 +136,11 @@ namespace :apache do
130
136
  run "tar -xzf mod_xsendfile-0.9.tar.gz"
131
137
  sudo "mkdir -p /usr/local/src"
132
138
  sudo "mv mod_xsendfile-0.9* /usr/local/src/"
133
- sudo "apxs2 -cia /usr/local/src/mod_xsendfile-0.9/mod_xsendfile.c"
139
+ sudo "apxs2 -ci /usr/local/src/mod_xsendfile-0.9/mod_xsendfile.c"
140
+ put render("xsendfile.conf", binding), "xsendfile.conf.tmp"
141
+ sudo "mv xsendfile.conf.tmp /etc/apache2/mods-available/xsendfile.conf"
142
+ put render("xsendfile.load", binding), "xsendfile.load.tmp"
143
+ sudo "mv xsendfile.load.tmp /etc/apache2/mods-available/xsendfile.load"
144
+ sudo "a2enmod xsendfile"
134
145
  end
135
146
  end
@@ -0,0 +1,33 @@
1
+ desc "Installs extra utils: curl, lynx, mailutils, munin, imagemagick"
2
+ task :install_all do
3
+ install_curl
4
+ install_lynx
5
+ install_mailutils
6
+ install_munin
7
+ install_imagemagick
8
+ end
9
+
10
+ desc "Installs extra util curl"
11
+ task :install_curl do
12
+ sudo "aptitude install -y curl"
13
+ end
14
+
15
+ desc "Installs extra util lynx"
16
+ task :install_lynx do
17
+ sudo "aptitude install -y lynx"
18
+ end
19
+
20
+ desc "Installs extra util mailutils"
21
+ task :install_mailutils do
22
+ sudo "aptitude install -y mailutils"
23
+ end
24
+
25
+ desc "Installs extra util munin"
26
+ task :install_munin do
27
+ sudo "aptitude install -y munin"
28
+ end
29
+
30
+ desc "Installs extra util imagemagick"
31
+ task :install_imagemagick do
32
+ sudo "aptitude install -y imagemagick"
33
+ end
@@ -11,7 +11,7 @@ namespace :ffmpeg do
11
11
  task :install_dependencies, :roles => :app do
12
12
  #TODO: Ensure that the multiverse repositories/sources are available and being used by aptitude \
13
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 libmp3lame-dev libogg-dev libpng12-dev libtheora-dev libtiff4-dev libvorbis-dev libxvidcore4-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
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
16
  sudo "ldconfig"
17
17
  run "if test -x x264; then cd x264 && git checkout master && git pull; else git clone git://git.videolan.org/x264.git; fi"
@@ -42,24 +42,28 @@ namespace :gems do
42
42
  run "echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc"
43
43
  end
44
44
 
45
- # TODO: Replace scp with Capistrano's way of uploading/deploying files.
46
45
  desc "Scp local gem to the remote server and install it"
47
46
  task :deploy_local_gem, :roles => :app do
48
47
  local_gem_path = Capistrano::CLI.ui.ask("Please supply the path to the local gem: ")
49
48
  run "mkdir -p gems"
50
- `scp -P #{ssh_options[:port]} #{File.expand_path(local_gem_path)} #{user}@#{server_name}:gems/`
51
- sudo "gem install -l gems/#{File.basename(local_gem_path)}"
49
+ upload(local_gem_path,'~/gems/',:via => :scp, :recursive => false)
50
+ sudo_keepalive
51
+ run "cd gems/ && sudo gem install -l #{File.basename(local_gem_path)}"
52
52
  end
53
53
 
54
- # TODO: Replace scp with Capistrano's way of uploading/deploying files.
55
54
  # TODO: Refactor with deploy_local_gem
56
55
  desc "Scp a set of local gems preconfigured in :local_gems_to_deploy to the remote server and install them"
57
56
  task :deploy_local_gems, :roles => :app do
58
57
  _cset(:local_gems_to_deploy) { abort "Please specify the local gems you want to deploy:\n set :local_gems_to_deploy, ['/path/to/your_local-1.2.gem']" }
59
58
  run "mkdir -p gems"
59
+ # First upload all gems
60
60
  local_gems_to_deploy.each do |local_gem_path|
61
- `scp -P #{ssh_options[:port]} #{File.expand_path(local_gem_path)} #{user}@#{server_name}:gems/`
62
- sudo "gem install -l gems/#{File.basename(local_gem_path)}"
61
+ upload(local_gem_path,'~/gems/',:via => :scp, :recursive => false)
62
+ end
63
+ # Then install them
64
+ local_gems_to_deploy.each do |local_gem_path|
65
+ sudo_keepalive
66
+ run "cd gems/ && sudo gem install -l #{File.basename(local_gem_path)}"
63
67
  end
64
68
  end
65
69
  end
@@ -61,9 +61,10 @@ end
61
61
  def add_to_crontab(commands,period,use_sudo=false)
62
62
  send_cmd = use_sudo ? :sudo : :run
63
63
  tmp_cron="/tmp/cron.tmp"
64
+ self.send(send_cmd, "rm -f #{tmp_cron} && touch #{tmp_cron}")
65
+ run "(#{use_sudo ? 'sudo ' : ''}crontab -l || true) > #{tmp_cron}"
64
66
  cron_lines = [*commands].map{|cmd| "#{period} #{cmd}"}
65
- self.send(send_cmd, "rm -f #{tmp_cron} && crontab -l || true > #{tmp_cron}")
66
- add_to_file(cron_lines, tmp_cron)
67
+ add_to_file(tmp_cron, cron_lines)
67
68
  self.send(send_cmd, "crontab #{tmp_cron}")
68
69
  sudo "rm -f #{tmp_cron}"
69
70
  end
@@ -40,6 +40,7 @@ namespace :machine do
40
40
  ruby.install_passenger
41
41
  git.install
42
42
  php.install
43
+ extras.install_all
43
44
  end
44
45
 
45
46
  desc = "Ask for a user and change his password"
@@ -48,4 +49,35 @@ namespace :machine do
48
49
 
49
50
  run_and_watch_prompt("passwd #{user_to_update}", [/Enter new UNIX password/, /Retype new UNIX password:/])
50
51
  end
52
+
53
+ desc "Change the hostname of the machine"
54
+ task :change_hostname do
55
+ _cset(:hostname) {Capistrano::CLI.ui.ask("What do you want to change the hostname of this machine to? : ")}
56
+ tmp_host = 'hostname.tmp'
57
+ run "echo '#{hostname}' > #{tmp_host}"
58
+ sudo "cp #{tmp_host} /etc/hostname"
59
+ sudo "rm #{tmp_host}"
60
+ sudo_add_to_file('/etc/hosts', "127.0.0.1 #{hostname}")
61
+ sudo "/etc/init.d/hostname.sh start"
62
+ end
63
+
64
+ desc "Add current path to crontab"
65
+ task :add_path_to_crontab do
66
+ tmp_cron="/tmp/cron.tmp"
67
+ run "rm -f #{tmp_cron} && touch #{tmp_cron}"
68
+ run "echo PATH=$PATH > #{tmp_cron}"
69
+ run "(crontab -l || true) >> #{tmp_cron}"
70
+ run "crontab #{tmp_cron}"
71
+ run "rm -f #{tmp_cron}"
72
+ end
73
+
74
+ desc "Add current path to sudo crontab"
75
+ task :sudo_add_path_to_crontab do
76
+ tmp_cron="/tmp/cron.tmp"
77
+ sudo "rm -f #{tmp_cron} && touch #{tmp_cron}"
78
+ run "echo PATH=$PATH > #{tmp_cron}"
79
+ run "(sudo crontab -l || true) >> #{tmp_cron}"
80
+ sudo "crontab #{tmp_cron}"
81
+ sudo "rm -f #{tmp_cron}"
82
+ end
51
83
  end
@@ -50,7 +50,7 @@ namespace :ruby do
50
50
  sudo "ln -s #{ruby_enterprise_path_prefix}/#{ruby_enterprise_version} #{ruby_enterprise_path_prefix}/ruby-enterprise"
51
51
 
52
52
  # add REE bin to the path
53
- sudo_add_to_file('/etc/environment','echo PATH="%s/ruby-enterprise/bin:$PATH"' % ruby_enterprise_path_prefix)
53
+ sudo_add_to_file('/etc/environment','PATH="%s/ruby-enterprise/bin:$PATH"' % ruby_enterprise_path_prefix)
54
54
  end
55
55
 
56
56
  desc "Install Phusion Passenger"
@@ -1,5 +1,5 @@
1
1
  namespace :ssh do
2
- _cset :ssh_secundary_keys, []
2
+ _cset :ssh_secondary_keys, []
3
3
  _cset(:ssh_config_port) {ssh_options[:port] || 22}
4
4
 
5
5
  desc <<-DESC
@@ -13,17 +13,24 @@ namespace :ssh do
13
13
  reload
14
14
  end
15
15
 
16
- desc "Uploads secundary ssh pubkeys defined in ssh_secundary_keys which don't necessarily belong to you."
17
- task :add_secundary_keys do
16
+ desc "Uploads secondary ssh pubkeys defined in ssh_secondary_keys which don't necessarily belong to you."
17
+ task :add_secondary_keys do
18
18
  run "mkdir -p ~/.ssh"
19
19
  run "chown -R #{user}:#{user} ~/.ssh"
20
20
  run "chmod 700 ~/.ssh"
21
21
 
22
- [*ssh_secundary_keys].each do |key|
23
- key = File.read("#{key}.pub")
22
+ [*ssh_secondary_keys].each do |key|
23
+ key = File.read("#{key}.pub").strip
24
24
  run "echo '#{key}' >> ./.ssh/authorized_keys2"
25
25
  end
26
26
  end
27
+
28
+ after 'ssh:add_secondary_keys', 'ssh:cleanup_keys'
29
+
30
+ desc 'Sort and remove duplicate keys. Useful if you run ssh:add_secondary_keys multiple times by accident.'
31
+ task :cleanup_keys do
32
+ run 'sort -u ~/.ssh/authorized_keys2 > /home/yoadmin/.ssh/authorized_keys2-sorted && mv /home/yoadmin/.ssh/authorized_keys2-sorted /home/yoadmin/.ssh/authorized_keys2'
33
+ end
27
34
 
28
35
  desc <<-DESC
29
36
  Uploads your local public SSH keys to the server. A .ssh folder is created if \
@@ -1,4 +1,5 @@
1
- <VirtualHost *:80>
1
+ NameVirtualHost *:<%= server_port %>
2
+ <VirtualHost *:<%= server_port %>>
2
3
 
3
4
  # Admin email, Server Name (domain name) and any aliases
4
5
  ServerAdmin <%= server_admin %>
@@ -7,11 +8,11 @@
7
8
 
8
9
  # Index file and Document Root (where the public files are located)
9
10
  DirectoryIndex <%= directory_index %>
10
- DocumentRoot /home/<%= user %>/websites/<%= server_name %>/public
11
+ DocumentRoot <%= document_root %>
11
12
 
12
13
  # Custom log file locations
13
14
  LogLevel warn
14
- ErrorLog /home/<%= user %>/websites/<%= server_name %>/logs/error.log
15
- CustomLog /home/<%= user %>/websites/<%= server_name %>/logs/access.log combined
15
+ ErrorLog <%= sites_path %>/<%= server_name %>/logs/error.log
16
+ CustomLog <%= sites_path %>/<%= server_name %>/logs/access.log combined
16
17
 
17
18
  </VirtualHost>
@@ -0,0 +1,3 @@
1
+ <IfModule mod_xsendfile.c>
2
+ XSendFile on
3
+ </IfModule>
@@ -0,0 +1 @@
1
+ LoadModule xsendfile_module /usr/lib/apache2/modules/mod_xsendfile.so
@@ -42,5 +42,6 @@ namespace :utils do
42
42
  run "df"
43
43
  partition = Capistrano::CLI.ui.ask("Which partition do you want to run a filesystem check on, on every boot? ")
44
44
  sudo "tune2fs -c 1 #{partition}"
45
+ sudo 'sed -i -e s/FSCKFIX=no/FSCKFIX=yes/ /etc/default/rcS'
45
46
  end
46
47
  end
@@ -24,8 +24,6 @@ namespace :vsftpd do
24
24
 
25
25
  desc "Add the :vsftpd_user_shell to /etc/shells"
26
26
  task :add_nologin_shell do
27
- puts "If this fails, then the '#{vsftpd_user_shell}'-shell is already in /etc/shells"
28
- run "test -z `grep #{vsftpd_user_shell} /etc/shells`"
29
27
  sudo_add_to_file('/etc/shells',vsftpd_user_shell)
30
28
  end
31
29
 
@@ -8,6 +8,7 @@ end
8
8
 
9
9
  Capistrano::Configuration.instance.load {load("#{File.dirname(__FILE__)}/ubuntu-machine/apache.rb")}
10
10
  Capistrano::Configuration.instance.load {load("#{File.dirname(__FILE__)}/ubuntu-machine/aptitude.rb")}
11
+ Capistrano::Configuration.instance.load {load("#{File.dirname(__FILE__)}/ubuntu-machine/extras.rb")}
11
12
  Capistrano::Configuration.instance.load {load("#{File.dirname(__FILE__)}/ubuntu-machine/ffmpeg.rb")}
12
13
  Capistrano::Configuration.instance.load {load("#{File.dirname(__FILE__)}/ubuntu-machine/gems.rb")}
13
14
  Capistrano::Configuration.instance.load {load("#{File.dirname(__FILE__)}/ubuntu-machine/git.rb")}
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: FiXato-ubuntu-machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3.2.11
4
+ version: 0.5.3.2.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Balthazar
8
8
  - Tarik Alkasab
9
9
  - Filip H.F. 'FiXato' Slagter
10
+ - Wes Oldenbeuving
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
14
 
14
- date: 2009-06-26 00:00:00 -07:00
15
+ date: 2009-09-18 00:00:00 -07:00
15
16
  default_executable:
16
17
  dependencies:
17
18
  - !ruby/object:Gem::Dependency
@@ -38,6 +39,7 @@ files:
38
39
  - lib/capistrano/ext/ubuntu-machine.rb
39
40
  - lib/capistrano/ext/ubuntu-machine/apache.rb
40
41
  - lib/capistrano/ext/ubuntu-machine/aptitude.rb
42
+ - lib/capistrano/ext/ubuntu-machine/extras.rb
41
43
  - lib/capistrano/ext/ubuntu-machine/ffmpeg.rb
42
44
  - lib/capistrano/ext/ubuntu-machine/gems.rb
43
45
  - lib/capistrano/ext/ubuntu-machine/git.rb
@@ -71,8 +73,11 @@ files:
71
73
  - lib/capistrano/ext/ubuntu-machine/templates/sshd_config.erb
72
74
  - lib/capistrano/ext/ubuntu-machine/templates/vhost.erb
73
75
  - lib/capistrano/ext/ubuntu-machine/templates/vsftpd.conf.erb
76
+ - lib/capistrano/ext/ubuntu-machine/templates/xsendfile.load.erb
77
+ - lib/capistrano/ext/ubuntu-machine/templates/xsendfile.conf.erb
74
78
  has_rdoc: false
75
79
  homepage: http://github.com/FiXato/ubuntu-machine
80
+ licenses:
76
81
  post_install_message:
77
82
  rdoc_options: []
78
83
 
@@ -93,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
98
  requirements: []
94
99
 
95
100
  rubyforge_project:
96
- rubygems_version: 1.2.0
101
+ rubygems_version: 1.3.5
97
102
  signing_key:
98
103
  specification_version: 2
99
104
  summary: Capistrano recipes for setting up and deploying to a Ubuntu Machine. Fork of SuitMyMind's ubuntu-machine