require 'rho_connect_install_constants' require 'rho_connect_install_checkers' include Checkers module Installers # configure_passenger # This method installs items that were retrieved via wget as well as passenger def configure_passenger(options) raise "Please stop the web server and then reinstall the package." if check_web_server_running @options=options print_header "Configuring passenger ..." if @options[:web_server] if @options[:web_server] == "apache2" print_header "Configuring apache2 to work with passenger ..." cmd "yes | #{@options[:prefix]}/bin/passenger-install-#{ @options[:web_server] }-module" elsif @options[:web_server] == "nginx" nginx_version = Constants::Nginx print_header "Downloading http://nginx.org/download/#{nginx_version}.tar.gz ..." cmd "cd #{@options[:prefix]}; wget http://nginx.org/download/#{nginx_version}.tar.gz -o /dev/null; tar -xzvf #{nginx_version}.tar.gz" print_header "Configuring and compiling Nginx to work with passenger ..." cmd "#{@options[:prefix]}/bin/passenger-install-nginx-module --auto --prefix=/opt/nginx \ --nginx-source-dir=#{@options[:prefix]}/#{nginx_version} \ --extra-configure-flags='--with-http_ssl_module --with-http_gzip_static_module --user=nginx --group=nginx'" else raise "Unsupported web server." end end raise "Nginx installation failed." if $? != 0 end # install_all_gems # This method installs all gems specified in the GEMS list defined in the # Constants file def install_all_gems @gem_path = "#{@options[:prefix]}/bin/gem" # Update the RubyGems system software cmd "#{@gem_path} update --system" Constants::GEMS.each do |gem| install_gem gem end end # install_gem # This method installs the given gem unless it is already installed def install_gem(gem) cmd "#{@gem_path} install #{gem} --no-ri --no-rdoc" unless check_gem(gem, @gem_path) raise "#{gem} installation failed." if $? != 0 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 print_header "Installing redis ..." Dir.chdir("#{@options[:prefix]}/#{Constants::REDIS}/src") cmd "make 2>&1; make PREFIX=#{@options[:prefix]} install" raise "Redis installation failed." if $? != 0 `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 #install_redis # install_sqlite # This method instaqll sqlite def install_sqlite print_header "Installing sqlite3 libs ..." Dir.chdir("#{@options[:prefix]}/#{Constants::SQLITE3}") cmd "./configure --prefix=#{@options[:prefix]}" cmd "make 2>&1; make install" raise "Installation if sqlite3 libraries failed." if $? != 0 end #install_sqlite # install_rhoconnect # This method installs rhoconnect def install_rhoconnect print_header "Installing rhoconnect ..." Dir.chdir(@options[:start_dir]) cmd "#{@options[:prefix]}/bin/bundle config build.sqlite3 " + "--with-sqlite3-include=#{@options[:prefix]}/include " + "--with-sqlite3-lib=#{@options[:prefix]}/lib" if @options[:pkg_mgr] =~ /yum/ # CentOS gem_name = (Dir.glob "rhoconnect-*.gem")[0] if gem_name && File.exists?(gem_name) install_gem gem_name else cmd "#{@options[:prefix]}/bin/bundle install --system --binstubs=/opt/rhoconnect/bin --without=test development" # PATH=/opt/rhoconnect/bin:$PATH rake build cmd "PATH=#{@options[:prefix]}/bin:$PATH rake build" cmd "#{@gem_path} install pkg/rhoconnect-*.gem --no-ri --no-rdoc" raise "Gem installation failed." if $? != 0 #`rm -f pkg/rhoconnect-*.gem` end end end