Modified: trunk/installers/ubuntu/README.txt (2938 => 2939)
--- trunk/installers/ubuntu/README.txt 2012-02-22 03:10:42 UTC (rev 2938)
+++ trunk/installers/ubuntu/README.txt 2012-02-22 04:09:43 UTC (rev 2939)
@@ -6,10 +6,9 @@
18/10/2011). The installer is designed to work on a freshly installed version
of Ubuntu, you may have problems if you are installing on an existing system.
-install.bash is the main install script and can be downloaded and run from
-the current working directory as follows:
+install.bash is the main install script and can be downloaded and run as follows:
- /bin/bash install.bash
+ RAILS_ROOT/installers/ubuntu/install.bash
This install script requires the settings file, settings.bash, which needs to be
kept in the same directory. This can be created by copying the
@@ -18,11 +17,9 @@
myexp_root_password - Choose a password for the root account of MySQL. If for
whatever reason MySQL is already installed set this to the current MySQL root
-password. MySQL mosty have a root password for the installer to suceed
+password. MySQL must have a root password for the installer to suceed. See
+http://forums.mysql.com/read.php?10,355736 for how to unset a MySQL password.
-myexp_user_password - Choose a password for the account that myExperiment uses
-to access databases it creates for storing myExperiment data.
-
fq_server_name - The fully-qualified server name and domain for your server,
i.e. the A record. E.g. myexperiment.example.org
@@ -44,9 +41,9 @@
you will need to edit settings.yml in the config directory of the SVN checkout
of myExperiment by default this /var/rails/myexperiment/config/.
-Some configuration may require restarting Apache using the following command:
+Some configuration may require restarting myExperiment using the following command:
-sudo apache2ctl restart
+sudo service myexperiment restart
== Further Information ==
Modified: trunk/installers/ubuntu/default_settings.bash (2938 => 2939)
--- trunk/installers/ubuntu/default_settings.bash 2012-02-22 03:10:42 UTC (rev 2938)
+++ trunk/installers/ubuntu/default_settings.bash 2012-02-22 04:09:43 UTC (rev 2939)
@@ -1,43 +1,22 @@
#!/bin/bash
install_dir="/var/rails/myexperiment" # Where to checkout the myExperiment SVN
branch="trunk"
+ruby_version="1.8.7"
mysql_root_password="changeme"
-mysql_user_name="myexp"
-mysql_user_password="changeme"
-rdoc=1 # Set to 0 if you want no RDoc Ruby Gem documentaion
-ri=1 # Set yo 0 if you want no RI Ruby Gem documentatiom
-rake_version="0.8.7"
-rails_version="2.3.14"
-passenger_version="2.2.15"
fq_server_name="server.domain"
+myexp_cname="myexp.domain" # Where your myExperiment will be hosted can be the same as $fq_server_name
exim_smarthost_server="smtp"
exim_smarthost_domain="domain"
-myexp_cname="myexp.domain" # Where your myExperiment will be hosted can be the same as $fq_server_name
+exim_smarthost="${exim_smarthost_server}.${exim_smarthost_domain}"
-
-# Patch Files
-net_http_patch='Index: lib/net/http.rb
-===================================================================
---- lib/net/http.rb (revision 26550)
-+++ lib/net/http.rb (working copy)
-@@ -1057,7 +1057,7 @@
- res
- rescue => exception
- D "Conn close because of error #{exception}"
-- @socket.close unless @socket.closed?
-+ @socket.close if @socket and not @socket.closed?
- raise exception
- end'
-
-exim_smarthost="${exim_smarthost_server}.${exim_smarthost_domain}"
-settings_patch='--- default_settings.yml 2011-11-28 18:40:40.337937711 +0000
-+++ settings.yml 2011-11-28 19:00:56.231831591 +0000
+settings_patch='--- default_settings.yml 2011-11-28 18:40:40.337937711 +0000
++++ settings.yml 2011-11-28 19:00:56.231831591 +0000
@@ -75,7 +75,7 @@
#
# NOTE: No trailing slash.
-base_uri: http://www.example.com
-+base_uri: http://'${myexp_cname}'
++base_uri: http://'${myexp_cname}:3000'
# admins - Set "admins" to the list of usernames of people that are
# administrators of this installation. This is "Username" that is set
@@ -65,6 +44,7 @@
# show_debug - Shows query statistics in the footer: "Queries in Controller",
# "Queries in View" and "Query Time".
'
+
exim_config="dc_eximconfig_configtype='satellite'
dc_other_hostnames='${fq_server_name}'
dc_local_interfaces='127.0.0.1 ; ::1'
@@ -79,31 +59,53 @@
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'"
-apache_config="LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-${passenger_version}/ext/apache2/mod_passenger.so
-PassengerRoot /var/lib/gems/1.8/gems/passenger-${passenger_version}
-PassengerRuby /usr/bin/ruby1.8
-RailsEnv development
+initd_script='#!/bin/bash -e
-<VirtualHost *:80>
- ServerAdmin address@hidden
- ServerName ${myexp_cname}
- DocumentRoot ${install_dir}/public
- <Directory ${install_dir}/public/>
- AllowOverride all
- Options -MultiViews
- </Directory>
-</VirtualHost>"
+# Starts, stops, and restarts myExperiment
+MYEXP_DIR="'${install_dir}'"
+SOLR_LOG_FILE="'${install_dir}'/log/solr.log"
+SOLR_ERR_FILE="'${install_dir}'/log/solr.err"
+MYEXP_LOG_FILE="'${install_dir}'/log/myexperiment.log"
+MYEXP_ERR_FILE="'${install_dir}'/log/myexperiment.err"
+MYEXP_PID_FILE="'${install_dir}'/log/myexperiment.pid"
-# Configure options for (Ruby) gem install
-if [ ${rdoc} == 0 ]; then
- nordoc="--no-rdoc"
-else
- nordoc=""
-fi
-if [ ${ri} == 0 ]; then
- nori="--no-ri"
-else
- nori=""
-fi
-
+case $1 in
+ start)
+ echo "Starting myExperiment..."
+ source /usr/local/rvm/scripts/rvm
+ rvm --default use '${ruby_version}'
+ cd $MYEXP_DIR
+ rake solr:start 2>> $SOLR_ERR_FILE 1>> $SOLR_LOG_FILE
+ ruby script/server 2>> $MYEXP_ERR_FILE 1>> $MYEXP_LOG_FILE &
+ echo $! > $MYEXP_PID_FILE
+ echo "myExperiment started"
+ ;;
+ stop)
+ echo "Stopping myExperiment..."
+ source /usr/local/rvm/scripts/rvm
+ rvm --default use '${ruby_version}'
+ cd $MYEXP_DIR
+ rake solr:stop 2>> $SOLR_ERR_FILE 1>> $SOLR_LOG_FILE
+ if [ -s $MYEXP_PID_FILE ]; then
+ kill -9 `cat $MYEXP_PID_FILE`
+ rm $MYEXP_PID_FILE
+ else
+ echo "$MYEXP_PID_FILE does not exist or is empty"
+ if [ -f $MYEXP_PID_FILE ]; then
+ rm $MYEXP_PID_FILE
+ fi
+ exit 2
+ fi
+ echo "myExperiment stopped"
+ ;;
+ restart)
+ $0 stop
+ sleep 3
+ $0 start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart}" >&2
+ exit 1
+ ;;
+esac'
Modified: trunk/installers/ubuntu/install.bash (2938 => 2939)
--- trunk/installers/ubuntu/install.bash 2012-02-22 03:10:42 UTC (rev 2938)
+++ trunk/installers/ubuntu/install.bash 2012-02-22 04:09:43 UTC (rev 2939)
@@ -2,103 +2,88 @@
echo ""
echo "+----------------------------------------------------------------------------------------------+"
-echo "| Welcome to the myExperimemt Installer for Ubuntu 10.04! |"
+echo "| Welcome to the myExperiment Installer for Ubuntu 10.04! |"
echo "| Go to http://wiki.myexperiment.org/index.php/Developer:UbuntuInstallation for more details. |"
echo "+----------------------------------------------------------------------------------------------+"
echo ""
-settings_file=`dirname $0`/settings.bash
+d=`dirname $0`
+basedir=`cd ${d}; pwd`
+settings_file="${basedir}/settings.bash "
source ${settings_file} || { echo "Could not find settings file at ${settings_file}. Aborting ..."; exit 1; }
+echo "Creating temporary directory for installation files"
+tempdir=$(mktemp -d /tmp/myexp_installer.XXXXXXXXXX) || { echo "Could not create temporary file for writing patches to. Aborting ..."; exit 2; }
+
echo "Preseeding debconf"
-sudo su -c "echo mysql-server-5.1 mysql-server/root_password password `echo "'"``echo ${mysql_root_password}``echo "'"` | debconf-set-selections" || { echo "Could not set debconf option mysql-server-5.1 mysql-server/root_password. Aborting ..."; exit 2; }
-sudo su -c "echo mysql-server-5.1 mysql-server/root_password_again password `echo "'"``echo ${mysql_root_password}``echo "'"` | debconf-set-selections" || { echo "Could not set debconf option mysql-server-5.1 mysql-server/root_password_again. Aborting ..."; exit 3; }
+sudo su -c "echo mysql-server-5.1 mysql-server/root_password password `echo "'"``echo ${mysql_root_password}``echo "'"` | debconf-set-selections" || { echo "Could not set debconf option mysql-server-5.1 mysql-server/root_password. Aborting ..."; exit 3; }
+sudo su -c "echo mysql-server-5.1 mysql-server/root_password_again password `echo "'"``echo ${mysql_root_password}``echo "'"` | debconf-set-selections" || { echo "Could not set debconf option mysql-server-5.1 mysql-server/root_password_again. Aborting ..."; exit 4; }
-echo "Installing required APT packages"
-sudo apt-get update || { echo "Could not update apt-get. Aborting ..."; exit 4; }
-sudo -n apt-get install -y build-essential exim4 ruby ruby1.8-dev libzlib-ruby rdoc irb rubygems rake apache2 apache2-dev libapache2-mod-fcgid libfcgi-ruby1.8 libmysql-ruby gcj-4.4-jre-headless subversion libopenssl-ruby1.8 libcurl3 libcurl3-gnutls libcurl4-openssl-dev mysql-server graphicsmagick imagemagick librmagick-ruby1.8 libmagick9-dev graphviz mlocate || { echo "Could not install required APT packages. Aborting ..."; exit 5; }
+echo "Installing required packages using apt-get install"
+sudo apt-get update || { echo "Could not update apt-get. Aborting ..."; exit 5; }
+sudo -n apt-get install -y build-essential exim4 git-core curl libcurl3 libcurl3-gnutls libcurl4-openssl-dev openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev mysql-server libmysqlclient16-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion libmagickwand-dev graphviz gcj-4.4-jre-headless || { echo "Could not install required using apt-get install. Aborting ..."; exit 6; }
-echo "Installing Rake version ${rake_version} and Rails version ${rails_version} Ruby Gems"
-sudo gem install rake ${nordoc} ${nori} --version ${rake_version} || { echo "Could not install Rake Ruby Gem (version ${rake_version}). Aborting ..."; exit 6; }
-sudo gem install rails ${nordoc} ${nori} --version ${rails_version} || { echo "Could not install Rails Ruby Gem (v${rails_version}) and dependencies. Aborting ..."; exit 7; }
+echo "Installing and configuring RVM"
+sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer ) || { echo "Could not install RVM. Aborting ..."; exit 7; }
+echo '[[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm"' >> ~/.bashrc || { echo "Could not add RVM loading to $HOME/.bashrc. Aborting ..."; exit 8; }
-echo "Installing Ruby Gems required by myExperiment"
-if [ `cat /etc/environment | grep "/var/lib/gems/1.8/bin" | wc -l` -eq 0 ]; then
- cat /etc/environment | sed "s/\"$/:\/var\/lib\/gems\/1.8\/bin\"/" | sudo tee /etc/environment > /dev/null || { echo "Could not add Gems path to PATH. Aborting ..."; exit 8;}
-fi
-if [ `echo ${PATH} | grep "/var/lib/gems/1.8/bin" | wc -l` -eq 0 ]; then
- DOLLAR='$'; echo -e "export PATH=${DOLLAR}PATH:/var/lib/gems/1.8/bin\nalias sudo='sudo env PATH=${DOLLAR}PATH'" >> /home/${USER}/.bashrc || { echo "Could not write to /home/${USER}/.bashrc. Aborting ..."; exit 9;}
- source /home/${USER}/.bashrc || { echo "Could not source /home/${USER}/.bashrc. Aborting ..."; exit 10; }
-fi
-sudo gem install ${nordoc} ${nori} rubyzip libxml-ruby rmagick dsl_accessor ruby-openid openurl curb marc || { echo "Could not install all remaining generic Ruby Gems required by myExperiment. Aborting ..."; exit 11; }
+echo "Install and configuring Ruby version ${ruby_version}"
+source "/usr/local/rvm/scripts/rvm" || { echo "Could not source /usr/local/rvm/scripts/rvm to add RVM directory to path. Aborting ..."; exit 9; }
+rvmsudo rvm install ${ruby_version} || { echo "Could not install Ruby ${ruby_version} using RVM. Aborting ..."; exit 10; }
+rvm --default use ${ruby_version} || { echo "Could not set Ruby ${ruby_version} as the default environment for RVM. Aborting ..."; exit 11; }
-echo "Patching bug in Ubuntu 10.04 version of Ruby 1.8.7"
-tempdir=$(mktemp -d /tmp/myexp_installer.XXXXXXXXXX) || { echo "Could not create temporary file for writing patches to. Aborting ..."; exit 12; }
-cd ${tempdir} || { echo "Could not find temporary directory. Aborting ..."; exit 13; }
-echo "${net_http_patch}" > net_http.patch || { echo "Could not write net/http patch file. Aborting ..."; exit 14; }
-
-echo "Patching settings file to provide minimal configuration"
-echo "${settings_patch}" > settings.patch || { echo "Could not write settings patch file. Aborting ..."; exit 15; }
-sudo updatedb || { echo "Could not run updatedb so that http.rb that needs updating can be located. Aborting ..."; exit 16; }
-net_http_file=`locate net/http.rb`
-if [ ! -e ${net_http_file} ]; then
- echo "Could not locate net/http Ruby file that requires updating. Aborting ..."; exit 17;
-fi
-sudo patch ${net_http_file} ${tempdir}/net_http.patch || { echo "Could not patch net/http Ruby file: ${net_http_file}. Aborting ..."; exit 18; }
-
echo "Checking out myExperiment codebase from SVN"
cd /
for idir in `echo ${install_dir} | awk 'BEGIN{RS="/"}{print $1}'`; do
if [ -n ${idir} ]; then
if [ ! -d ${idir} ]; then
- sudo mkdir ${idir} || { echo "Could not create directory ${idir} in `pwd`. Aborting ..."; exit 19; }
+ sudo mkdir ${idir} || { echo "Could not create directory ${idir} in `pwd`. Aborting ..."; exit 12; }
fi
cd ${idir}
fi
done
-sudo chown ${USER}:www-data ${install_dir} || { echo "Could not update permissions on ${install_dir}. Aborting ..."; exit 20; }
-svn checkout svn://rubyforge.org/var/svn/myexperiment/${branch} ${install_dir} || { echo "Could not checkout SVN to ${install_dir}. Aborting ..."; exit 21; }
-cd ${install_dir}/config/ || { echo "Could not find config directory for myExperiment. Aborting ..."; exit 22; }
+sudo chown ${USER}:www-data ${install_dir} || { echo "Could not update permissions on ${install_dir}. Aborting ..."; exit 13; }
+svn checkout svn://rubyforge.org/var/svn/myexperiment/${branch} ${install_dir} || { echo "Could not checkout SVN to ${install_dir}. Aborting ..."; exit 14; }
+cd ${install_dir}/config/ || { echo "Could not find config directory for myExperiment. Aborting ..."; exit 15; }
echo "Setting up config files for myExperiment"
-cat database.yml.pre | sed "s/username: root/username: ${mysql_user_name}/" | sed "s/password:/password: ${mysql_user_password}/" > database.yml || { echo "Could not create database.yml file with appropriate configuration settings. Aborting ..."; exit 23; }
-cp default_settings.yml settings.yml || { echo "Could not copy default_settings.yml to settings.yml ..."; exit 24; }
-patch settings.yml ${tempdir}/settings.patch || { echo "Could not patch settings.yml. Aborting ..."; exit 25; }
-cp captcha.yml.pre captcha.yml || { echo "Could not create captcha.yml file. Aborting ..."; exit 26; }
-cd ..
+cat database.yml.pre | sed "s/password:/password: ${mysql_root_password}/" > database.yml || { echo "Could not create database.yml file with appropriate configuration settings. Aborting ..."; exit 16; }
+cp default_settings.yml settings.yml || { echo "Could not copy default_settings.yml to settings.yml ..."; exit 17; }
+echo "${settings_patch}" > ${tempdir}/settings.patch || { echo "Could not write settings patch file. Aborting ..."; exit 18; }
+patch settings.yml ${tempdir}/settings.patch || { echo "Could not patch settings.yml. Aborting ..."; exit 19; }
+cp captcha.yml.pre captcha.yml || { echo "Could not create captcha.yml file. Aborting ..."; exit 20; }
+echo "Installing Gems required by myExperiment using bundler"
+cp ${basedir}/Gemfile ${install_dir} || { echo "Could not copy Gemfile to myExperiment base directory: ${install_dir}. Aborting ..."; exit 21; }
+cd ${install_dir}
+bundle install || { echo "Could not install the Gems required by myExperiment using bundler. Aborting ..."; exit 22; }
+
echo "Setting up exim (Email) for myExperiment"
-echo "${exim_config}" | sudo tee /etc/exim4/update-exim4.conf.conf > /dev/null || { echo "Could not write new exim4 config. Aborting..."; exit 27; }
-echo "${fq_server_name}" | sudo tee /etc/mailname > /dev/null || { echo "Could not update hostname for /etc/mailname. Aborting..."; exit 28; }
-sudo dpkg-reconfigure -fnoninteractive exim4-config || { echo "Could not write new reconfingure exim4. Aborting..."; exit 29; }
+echo "${exim_config}" > ${tempdir}/update-exim4.conf.conf || { echo "Could not write exim4 config to ${tempdir}/update-exim4.conf.conf. Aborting ..."; exit 23; }
+sudo mv ${tempdir}/update-exim4.conf.conf /etc/exim4/ || { echo "Could not move new exim4 config to /etc/exim4/update-exim4.conf.conf. Aborting ..."; exit 24; }
+echo "${fq_server_name}" > ${tempdir}/mailname || { echo "Could not write mailname (${fq_server_name}) to ${tempdir}/mailname. Aborting ..."; exit 25; }
+sudo mv ${tempdir}/mailname /etc/ || { echo "Could not update hostname for /etc/mailname. Aborting..."; exit 26; }
+sudo dpkg-reconfigure -fnoninteractive exim4-config || { echo "Could not write new reconfingure exim4. Aborting..."; exit 27; }
-echo "Setting up myExperiment databases in MySQL"
-mysql -u root -p${mysql_root_password} -e "CREATE USER '${mysql_user_name}'@'localhost' IDENTIFIED BY '${mysql_user_password}'; CREATE DATABASE m2_development; CREATE DATABASE m2_production; CREATE DATABASE m2_test; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,INDEX,ALTER,DROP,CREATE TEMPORARY TABLES,CREATE VIEW,SHOW VIEW ON m2_development . * TO '${mysql_user_name}'@'localhost';GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,INDEX,ALTER,DROP,CREATE TEMPORARY TABLES,CREATE VIEW,SHOW VIEW ON m2_production . * TO '${mysql_user_name}'@'localhost';GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,INDEX,ALTER,DROP,CREATE TEMPORARY TABLES,CREATE VIEW,SHOW VIEW ON m2_test . * TO '${mysql_user_name}'@'localhost';" || { echo "Could not create myExperiment databases in MySQL and set up appropriate access for the ${mysql_user_name} user. Aborting ..."; exit 30; }
+echo "Creating and migrating myExperiment database"
+rake db:create:all || { echo "Could not create MySQL database for myExperiment data model. Aborting ..."; exit 28; }
+rake db:migrate || { echo "Could not migrate myExperiment data model to a MySQL database. Aborting ..."; exit 29; }
-echo "Migrating myExperiment database"
-rake db:migrate || { echo "Could not migrate myExperiment data model to a MySQL database. Aborting ..."; exit 31; }
+echo "Creating myExperiment init.d script and deploying so myExperiment automatically starts after machine start up"
+echo "${initd_script}" > ${tempdir}/myexperiment || { echo "Could not create myExperiment init.d script. Aborting ..."; exit 30; }
+sudo mv ${tempdir}/myexperiment /etc/init.d || { echo "Could not move myExperiment init.d script to /etc/init.d. Aborting ..."; exit 31; }
+sudo chown root:root /etc/init.d/myexperiment || { echo "Could not change ownwership of /etc/init.d/myexperiment. Aborting ..."; exit 32; }
+sudo chmod +x /etc/init.d/myexperiment || { echo "Could not modify permissions of /etc/init.d/myexperiment. Aborting ..."; exit 33; }
+sudo update-rc.d myexperiment defaults || { echo "Could not deploy /etc/init.d/myexperiment as a startup script. Aborting ..."; exit 34; }
-echo "Starting Solr (search) server and indexing"
-rake solr:start || { echo "Could not start Solr server. Aborting ..."; exit 32; }
+sudo service myexperiment start || { echo "Could not start myExperiment. Aborting ..."; exit 35; }
-echo "Installing and configuring Passenger Gem (mod_rails)";
-sudo gem install passenger --version ${passenger_version} || { echo "Could not install Passnger Gem version ${passenger_version}. Aborting ..."; exit 33; }
-sudo su -c "yes | /var/lib/gems/1.8/bin/passenger-install-apache2-module" || { echo "Could not install Apache2 module for Passenger. Aborting ..."; exit 34; }
-echo "${apache_config}" | sudo tee /etc/apache2/sites-available/myexperiment > /dev/null || { echo "Could not add bespoke myExperiment Apache configuration. Aborting ..."; exit 35; }
-if [ ! -h /etc/apache2/sites-enabled/myexperiment ]; then
- sudo ln -s /etc/apache2/sites-available/myexperiment /etc/apache2/sites-enabled/myexperiment || { echo "Could symlink Apache configuration to sites-enabled."; exit 36; }
-fi
-if [ -f "/etc/apache2/sites-enabled/000-default" ]; then
- sudo rm /etc/apache2/sites-enabled/000-default || { echo "Could not remove 000-default to sites-enabled. Aborting ..."; exit 37; }
-fi
-sudo apache2ctl stop || { echo "Could not stop Apache2. Aborting ..."; exit 38; }
-sleep 2
-sudo apache2ctl start || { echo "Could not start Apache2. Aborting ..."; exit 39; }
+echo "Tidying up"
+rm -r ${tempdir} || { echo "Could not delete temporary directory ${tempdir}. Aborting ..."; exit 36; }
-echo "Removing temporary directory created for writing patch files to"
-sudo rm -rf ${tempdir} || { echo "Could not remove temporary directory used by patch files."; exit 40; }
-
echo ""
-echo "+-----------------------------------------------------------------------------------------+"
-echo "| myExperiment is now fully installed. Go to http://$myexp_cname/ to use myExperiment |"
-echo "+-----------------------------------------------------------------------------------------+"
+echo "+----------------------------------------------------------------------------------------------+"
+echo "| myExperiment is now fully installed. Go to http://$myexp_cname:3000/ to use myExperiment |"
+echo "| To start, stop or restart myExperiment use: sudo service myexperiment start|stop|restart |"
+echo "+----------------------------------------------------------------------------------------------+"
+