Class: RailsPwnerer::Scaffolds::Packages

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/rails_pwnerer/scaffolds/packages.rb

Overview

installs the required OS (read: Ubuntu / Debian) packages

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

_setup_unix, _setup_windows, all_packages, all_packages_without_caching, #atomic_erase, #atomic_read, #atomic_write, #best_package_matching, #check_rails_root, #control_boot_script, #cpu_cores, #current_user, #gem_exists?, #gid_for_username, #group_for_username, #hook_boot_script, #install_gem, #install_gems, #install_package, #install_package_impl, #install_package_matching, #install_packages, #kill_tree, #os_distro, #path_to_boot_script, #path_to_boot_script_defaults, #path_to_gem, #process_info, #prompt_user_for_password, #remove_package, #remove_packages, #search_packages, #uid_for_username, #unroll_collection, #update_all_packages, #update_all_packages_impl, #update_gems, #update_package_metadata, #upgrade_gem, #upgrade_gems, #upgrade_package, #upgrade_package_impl, #upgrade_packages, #with_package_source, #with_temp_dir

Class Method Details

.goObject

Standalone runner.



128
129
130
# File 'lib/rails_pwnerer/scaffolds/packages.rb', line 128

def self.go
  self.new.run
end

Instance Method Details

#install_databasesObject

Packages for all the database servers we could need.



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/rails_pwnerer/scaffolds/packages.rb', line 58

def install_databases
  package 'sqlite3'
  package 'libsqlite3-dev'
      
  package 'mysql-client'
  package 'mysql-server'
  package 'libmysql-dev', 'libmysqlclient-dev', /^libmysqlclient\d*-dev$/
  
  package 'postgresql-client'
  package 'libpq-dev'
  
  # TODO: NoSQL stores.
end

#install_frontendsObject

Package for front-end servers.



105
106
107
108
# File 'lib/rails_pwnerer/scaffolds/packages.rb', line 105

def install_frontends
  package 'nginx'
  package 'varnish'
end

#install_managementObject

Packages needed to manage the server remotely and install applications.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rails_pwnerer/scaffolds/packages.rb', line 7

def install_management
  # Needed to play with the configuration database.
  package 'debconf'
  package 'debconf-utils'
  
  # Keys for Debian packages.
  package 'debian-archive-keyring'
  
  # Fetch files via HTTP.
  package 'curl'
  package 'wget'
  
  package 'dpkg-dev'  # Builds packages from source.
  package 'openssh-server'  # SSH into the box.

  # For gems with native extensions.
  package 'build-essential'
  package 'g++'
  
  # Pull code from version control.
  package 'subversion'    
  package 'git-core'

  package 'avahi-daemon'  # mDNS, a.k.a. Bonjour
  package 'ddclient'  # dynamic DNS
end

#install_rubyObject

The ruby environment (ruby, irb, rubygems).



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/rails_pwnerer/scaffolds/packages.rb', line 73

def install_ruby
  package = best_package_matching(['ruby1.8', 'ruby'])
  if !package or package[:version] < '1.8.7'
    # This distribution has an old ruby. Work around it.
    deb_source = 'http://debian.mirrors.tds.net/debian/'
    deb_repos = %w(testing main non-free contrib)
    with_package_source deb_source, deb_repos do
      install_ruby
    end
  end

  package 'ruby', 'ruby1.8'
  
  # Libraries needed to compile custom rubies.
  package 'libssl-dev', /^libssl[0-9.]*-dev$/
  package 'libreadline-dev', /^libreadline\d*-dev$/
  package 'zlib-dev', /^zlib[0-9a-z]*-dev$/

  # Extensions that don't come in the ruby package, but should.
  package 'libdbm-ruby', 'libdbm-ruby1.8'
  package 'libgdm-ruby', 'libgdbm-ruby1.8'
  package 'libopenssl-ruby', 'libopenssl-ruby1.8'
  package 'libreadline-ruby', 'libreadline-ruby1.8'
  package 'libsetup-ruby', 'libsetup-ruby1.8'

  # Ecosystem command-line tools.
  package 'irb', 'irb1.8'
  package 'ruby-dev', 'ruby1.8-dev'
  package 'rubygems', 'rubygems1.8'
end

#install_toolsObject

Packages needed by popular gems.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rails_pwnerer/scaffolds/packages.rb', line 35

def install_tools
  # For rmagick (image processing).
  package 'libmagickwand-dev', /^libmagick\d*-dev$/
  
  # For HTML/XML parsers (nokogiri, hpricot).
  package 'libxml2-dev'
  package 'libxslt1-dev'
  
  # For HTTP fetchers (curb).
  package 'libcurl-dev', 'libcurl-openssl-dev', /^libcurl\d*-dev$/,
          /^libcurl\d*-openssl-dev$/
      
  # needed for solr and other java-based services
  package 'openjdk-6-jdk'
  
  # useful to be able to work with compressed data
  package 'bzip2'
  package 'gzip'
  package 'tar'
  package 'zip'
end

#package(*patterns) ⇒ Object

Implementation of the super-simple package DSL.



111
112
113
# File 'lib/rails_pwnerer/scaffolds/packages.rb', line 111

def package(*patterns)
  install_package_matching patterns
end

#runObject

Runner.



117
118
119
120
121
122
123
124
125
# File 'lib/rails_pwnerer/scaffolds/packages.rb', line 117

def run
  
  update_all_packages
  install_management
  install_tools
  install_databases
  install_frontends
  install_ruby
end