#!/opt/rhoconnect/bin/ruby require 'rho_connect_install_constants' require 'readline' module Installers extend self # configure_passenger # This method installs items that were retrieved via wget as well as # passenger def configure_passenger(options) @options = options installs = 0 print_header "Configuring Passenger" print_header "Configuring Nginx to work with Passenger" cmd "#{@options[:prefix]}/bin/passenger-install-#{@options[:web_server]}-module " + "--auto --auto-download --prefix=/opt/rhoconnect/bin" if $? != 0 log_print "Passenger not configured." exit end #if end #configure_passenger # install_all_gems # This method installs all gems specified in the GEMS list defined in the # Constants file def install_all_gems(options) @options = options @gem_path = "#{@options[:prefix]}/bin/gem" Constants::GEMS.each do |gem| install_gem gem end #do end #install_all_gems # install_gem # This method installs the given gem def install_gem(gem) cmd "#{@gem_path} install #{ gem } --no-ri --no-rdoc" end #install_gem # install_rubygems # This method installs rubygems which was downloaded and untarred earlier def install_rubygems print_header "Installing Rubygems" Dir.chdir("#{@options[:prefix]}/#{Constants::RUBYGEMS}") cmd "#{@options[:prefix]}/bin/ruby setup.rb --prefix=#{@options[:prefix]}/#{Constants::RUBYGEMS}" @gem_path = "#{@options[:prefix]}/bin/gem" cmd "sed -n '1 c\#!/opt/rhoconnect/bin/ruby' #{@options[:prefix]}/bin/gem" end #install_rubygems # install_redis # This method installs redis def install_redis(options) @options = options puts "\nWould you like to install Redis (yes / no)?" answer = STDIN.readline.strip.downcase while answer != "yes" && answer != "no" puts "Please answer yes or no." end if answer == "yes" Dir.chdir("#{@options[:prefix]}/#{Constants::REDIS}/src") cmd "make; make PREFIX=#{@options[:prefix]} install" cmd "mkdir #{@options[:prefix]}/etc" unless File.exist? "#{@options[:prefix]}/etc" #cmd "cp ../redis.conf #{@options[:prefix]}etc" redis_conf_file = File.new("#{@options[:prefix]}/etc/redis.conf", 'w') File.foreach("../redis.conf") do |line| # daemonize no --> daemonize yes # logfile stdout --> logfile /var/log/redis.log if line =~ /^daemonize/ redis_conf_file << "daemonize yes" << "\n" elsif line =~ /^logfile/ redis_conf_file << "logfile /var/log/redis.log" << "\n" else redis_conf_file << line end end redis_conf_file.close end #if end #install_redis # install_sqlite # This method installs sqlite def install_sqlite(options) @options = options Dir.chdir("#{@options[:prefix]}/#{Constants::SQLITE3}") cmd "./configure --prefix=#{@options[:prefix]}" cmd "make; make install" end #install_sqlite # install_rhoconnect # This method installs rhoconnect def install_rhoconnect(options) @options = options print_header "Installing Rhoconnect" cmd "#{@gem_path} install rhoconnect-*.gem --no-ri --no-rdoc" cmd "rm -f rhoconnect-*.gem" end #install_rhoconnect end #Installers