class RailsPwnerer::Scaffolds::Packages
installs the required OS (read: Ubuntu / Debian) packages
Public Class Methods
go()
click to toggle source
Standalone runner.
# File lib/rails_pwnerer/scaffolds/packages.rb 146 def self.go 147 self.new.run 148 end
Public Instance Methods
install_databases()
click to toggle source
Packages
for all the database servers we could need.
# File lib/rails_pwnerer/scaffolds/packages.rb 62 def install_databases 63 package 'sqlite3' 64 package 'libsqlite3-dev' 65 66 package 'mysql-client' 67 package 'mysql-server' 68 package 'libmysql-dev', 'libmysqlclient-dev', /^libmysqlclient\d*-dev$/ 69 70 package 'postgresql-client' 71 package 'libpq-dev' 72 73 # TODO: NoSQL stores. 74 end
install_frontends()
click to toggle source
Package for front-end servers.
# File lib/rails_pwnerer/scaffolds/packages.rb 125 def install_frontends 126 package 'nginx' 127 end
install_management()
click to toggle source
Packages
needed to manage the server remotely and install applications.
# File lib/rails_pwnerer/scaffolds/packages.rb 7 def install_management 8 # Needed to play with the configuration database. 9 package 'debconf' 10 package 'debconf-utils' 11 12 # Keys for Debian packages. 13 package 'debian-archive-keyring' 14 15 # Fetch files via HTTP. 16 package 'curl' 17 package 'wget' 18 19 package 'dpkg-dev' # Builds packages from source. 20 package 'openssh-server' # SSH into the box. 21 22 # For gems with native extensions. 23 package 'build-essential' 24 package 'g++' 25 26 # Pull code from version control. 27 package 'subversion' 28 package 'git-core' 29 30 package 'avahi-daemon' # mDNS, a.k.a. Bonjour 31 package 'ddclient' # dynamic DNS 32 end
install_ruby()
click to toggle source
The ruby environment (ruby, irb, rubygems).
# File lib/rails_pwnerer/scaffolds/packages.rb 77 def install_ruby 78 # remove the bootstrap version of ruby to install the best available one. 79 remove_packages %w(ruby ruby1.8 ruby1.9.1 ruby2.0) 80 install_ruby_20 || install_ruby_19 81 end
install_ruby_19(retry_with_repos = true)
click to toggle source
MRI19 (1.9.2 or above).
# File lib/rails_pwnerer/scaffolds/packages.rb 104 def install_ruby_19(retry_with_repos = true) 105 package = best_package_matching(['ruby1.9.1']) 106 if !package or package[:version] < '1.9.2' 107 return false unless retry_with_repos 108 109 # This distribution has an old ruby. Work around it. 110 deb_source = 'http://debian.mirrors.tds.net/debian/' 111 deb_repos = %w(testing main non-free contrib) 112 return_value = nil 113 with_package_source deb_source, deb_repos do 114 return_value = install_ruby_19 false 115 end 116 return return_value 117 end 118 119 package 'ruby1.9.1' 120 package 'ruby1.9.1-dev' 121 true 122 end
install_ruby_20(retry_with_repos = true)
click to toggle source
MRI 2.0.
# File lib/rails_pwnerer/scaffolds/packages.rb 84 def install_ruby_20(retry_with_repos = true) 85 package = best_package_matching(['ruby2.0']) 86 if !package 87 return false unless retry_with_repos 88 89 # This distribution has an old ruby. Work around it. 90 deb_source = 'http://debian.mirrors.tds.net/debian/' 91 deb_repos = %w(testing main non-free contrib) 92 return_value = nil 93 with_package_source deb_source, deb_repos do 94 return_value = install_ruby_20 false 95 end 96 return return_value 97 end 98 package 'ruby2.0' 99 package 'ruby2.0-dev' 100 true 101 end
install_tools()
click to toggle source
Packages
needed by popular gems.
# File lib/rails_pwnerer/scaffolds/packages.rb 35 def install_tools 36 # For eventmachine. 37 package 'libssl-dev' 38 39 # For rmagick (image processing). 40 package 'libmagickwand-dev', /^libmagick\d*-dev$/ 41 42 # For HTML/XML parsers (nokogiri, hpricot). 43 package 'libxml2-dev' 44 package 'libxslt1-dev' 45 46 # For HTTP fetchers (curb). 47 package 'libcurl-dev', 'libcurl-openssl-dev', /^libcurl\d*-dev$/, 48 /^libcurl\d*-openssl-dev$/ 49 50 # needed for solr and other java-based services 51 package /^openjdk-\d+-jdk/ 52 53 # useful to be able to work with compressed data 54 package 'zlib-dev', /^zlib[0-9a-z]*-dev$/ 55 package 'bzip2' 56 package 'gzip' 57 package 'tar' 58 package 'zip' 59 end
package(*patterns)
click to toggle source
Implementation of the super-simple package DSL.
# File lib/rails_pwnerer/scaffolds/packages.rb 130 def package(*patterns) 131 install_package_matching patterns 132 end
run()
click to toggle source
Runner.
# File lib/rails_pwnerer/scaffolds/packages.rb 135 def run 136 update_package_metadata 137 update_all_packages 138 install_management 139 install_tools 140 install_databases 141 install_frontends 142 install_ruby 143 end