From 623bad37339b66fa959e1e75e37f52a3c4c7b5b6 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Thu, 15 Nov 2012 16:38:52 +0100 Subject: [PATCH 1/6] introduce installation script * check for ruby, git, bundler * create databases * migrate databases * checkout plugins in vendor/plugins * configurable pluginset via plugin_config.yml --- plugin_config.yml | 22 +++++++ setup.rb | 146 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+) create mode 100644 plugin_config.yml create mode 100755 setup.rb diff --git a/plugin_config.yml b/plugin_config.yml new file mode 100644 index 0000000000..e53e0544c6 --- /dev/null +++ b/plugin_config.yml @@ -0,0 +1,22 @@ +--- +plugins/chiliproject_activity_module: + repository: "git@github.com:finnlabs/chiliproject_activity_module.git" + branch: master +plugins/chiliproject_help_link: + repository: "git@github.com:finnlabs/chiliproject_help_link.git" + branch: master +plugins/numbered_headings: + repository: "git@github.com:finnlabs/numbered_headings.git" + branch: master +plugins/redmine_checkout: + repository: "git@github.com:finnlabs/redmine_checkout.git" + branch: master +plugins/redmine_customize_modules: + repository: "git@github.com:finnlabs/redmine_customize_modules.git" + branch: master +plugins/redmine_favicon: + repository: "https://github.com/finnlabs/redmine_favicon" + branch: master +plugins/memcached_passenger: + repository: "git@github.com:finnlabs/memcached_passenger.git" + branch: master diff --git a/setup.rb b/setup.rb new file mode 100755 index 0000000000..56a9b4cebb --- /dev/null +++ b/setup.rb @@ -0,0 +1,146 @@ +#!/usr/bin/env ruby + +require 'yaml' + +def abort_installation + p "Something went wrong :(" + p "Installation aborted." +end + +def check_ruby_version + p "Checking Ruby Version" + ruby_version = `ruby --version` + + version_check = ruby_version.scan("ruby 1.8.7") + patchlevel_check = ruby_version.scan("patchlevel 370") + + if version_check.empty? + p "It seems you are not using the recommended ruby version." + p "Please make sure you have installed 'ruby 1.8.7 (2012-02-08 patchlevel 370)'" + elsif patchlevel_check.empty? + p "It seems you are not running the recommended patch level." + p "To avoid unexpected problems we would recommend to install 'ruby 1.8.7 (2012-02-08 patchlevel 370)'" + else + p "Found" + end +end + +def check_bundler + p "Checking Bundler" + unless system "bundle --version > /dev/null" + p "It seems bundler is not installed. Please install bundler before running setup.rb." + p "For bundler and more information visit: http://gembundler.com/" + return false + else + p "Found" + return true + end +end + +def check_git + p "Checking git" + unless system "git --version > /dev/null" + p "It seems git is not installed. Please install git before running setup.rb." + return false + else + p "Found" + return true + end +end + +def check_for_db_yaml + unless File.exists?(Dir.pwd + '/config/database.yml') + p "Please configure your database before installing openProject." + p "Create and configure config/database.yml to do that." + return false + else + return true + end +end + +def checkout_default_plugins + exec_dir = Dir.pwd + "/vendor" + plugin_install_dir = Dir.pwd + "/vendor/plugins/" + default_plugin_file = File.join(Dir.pwd, "plugin_config.yml") + + config = YAML.load_file(default_plugin_file) + + config.each_pair do |key, mod_config| + + Dir.chdir exec_dir + plugin_path = File.join(exec_dir, key) + + if mod_config.keys.include?("repository") and not File.exists?(plugin_path) + system "git clone #{mod_config["repository"]} #{key}" + end + + Dir.chdir plugin_path + + if mod_config.keys.include?("branch") + unless `git branch`.split.include?(mod_config['branch']) + system "git branch #{mod_config["branch"]} origin/#{mod_config["branch"]}" + end + + if `git branch | grep '*'`.delete('*').chomp.strip != mod_config["branch"] + system "git checkout #{mod_config["branch"]}" + system "git merge origin/#{mod_config["branch"]}" + else + system "git merge origin/#{mod_config["branch"]}" + end + end + + if mod_config.keys.include?("commit") + system "git reset #{mod_config['commit']}" + end + + Dir.chdir exec_dir + end +end + +def setup_openproject + p "Installing Gems via Bundler" + + unless system("bundle install --without rmagick") + return false + end + + if check_for_db_yaml + p "Creating database" + `rake db:create` + + p "Migrating database" + `rake db:migrate` + else + return false + end + + p "Generate Session Store" + system("rake generate_session_store") +end + +def migrate_plugins + p "Migrate Plugins" + system("rake db:migrate:plugins") +end + +def install + p 'Installing openProject...' + + check_ruby_version + if not check_bundler or + not check_git or not + setup_openproject + abort_installation + return false + end + + unless checkout_default_plugins + return false + end + + migrate_plugins + + p "Installation Succeeded" +end + +install From 3c109ebe55a5a6e5119611b62105f99b9c458dc0 Mon Sep 17 00:00:00 2001 From: jwollert Date: Wed, 21 Nov 2012 17:52:12 +0100 Subject: [PATCH 2/6] reworked some small aspects of setup script so we don't need to bundle install twice --- setup.rb | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/setup.rb b/setup.rb index 56a9b4cebb..e9de5bdcd6 100755 --- a/setup.rb +++ b/setup.rb @@ -2,9 +2,10 @@ require 'yaml' -def abort_installation +def abort_installation! p "Something went wrong :(" p "Installation aborted." + return false end def check_ruby_version @@ -49,7 +50,7 @@ def check_git end def check_for_db_yaml - unless File.exists?(Dir.pwd + '/config/database.yml') + unless File.exists?(ROOT + '/config/database.yml') p "Please configure your database before installing openProject." p "Create and configure config/database.yml to do that." return false @@ -108,8 +109,8 @@ def setup_openproject p "Creating database" `rake db:create` - p "Migrating database" - `rake db:migrate` + migrate_core + migrate_plugins else return false end @@ -118,29 +119,40 @@ def setup_openproject system("rake generate_session_store") end +def bundle_default_plugins + unless system("bundle install --without rmagick") + return false + end +end + def migrate_plugins p "Migrate Plugins" system("rake db:migrate:plugins") end +def migrate_core + p "Migrate Core" + `rake db:migrate` +end + def install p 'Installing openProject...' + check_ruby_version - if not check_bundler or - not check_git or not - setup_openproject - abort_installation - return false + if not check_bundler or not check_git + abort_installation! end unless checkout_default_plugins - return false + abort_installation! end - migrate_plugins + Dir.chdir ROOT + return abort_installation! unless setup_openproject p "Installation Succeeded" end +ROOT = Dir.pwd install From 102c56c58ce130f9a37290cceefd77f1ae5a8627 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Fri, 23 Nov 2012 16:44:14 +0100 Subject: [PATCH 3/6] abort if rake migrate a.s.o. fails --- setup.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/setup.rb b/setup.rb index e9de5bdcd6..c61f180c07 100755 --- a/setup.rb +++ b/setup.rb @@ -107,10 +107,8 @@ def setup_openproject if check_for_db_yaml p "Creating database" - `rake db:create` - migrate_core - migrate_plugins + return false unless system("rake db:create") and migrate_core and migrate_plugins else return false end @@ -127,12 +125,12 @@ end def migrate_plugins p "Migrate Plugins" - system("rake db:migrate:plugins") + return system("rake db:migrate:plugins") end def migrate_core p "Migrate Core" - `rake db:migrate` + return system("rake db:migrate") end def install From 30612af220faebf46ed7f52f521ecf62e23fcb36 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Fri, 23 Nov 2012 17:14:00 +0100 Subject: [PATCH 4/6] update repositories --- plugin_config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin_config.yml b/plugin_config.yml index e53e0544c6..ba895d1ddf 100644 --- a/plugin_config.yml +++ b/plugin_config.yml @@ -3,7 +3,7 @@ plugins/chiliproject_activity_module: repository: "git@github.com:finnlabs/chiliproject_activity_module.git" branch: master plugins/chiliproject_help_link: - repository: "git@github.com:finnlabs/chiliproject_help_link.git" + repository: "git@github.com:finnlabs/help_link.git" branch: master plugins/numbered_headings: repository: "git@github.com:finnlabs/numbered_headings.git" @@ -12,10 +12,10 @@ plugins/redmine_checkout: repository: "git@github.com:finnlabs/redmine_checkout.git" branch: master plugins/redmine_customize_modules: - repository: "git@github.com:finnlabs/redmine_customize_modules.git" + repository: "git@github.com:finnlabs/customize_modules.git" branch: master plugins/redmine_favicon: - repository: "https://github.com/finnlabs/redmine_favicon" + repository: "git@github.com:finnlabs/redmine_favicon.git" branch: master plugins/memcached_passenger: repository: "git@github.com:finnlabs/memcached_passenger.git" From 2525600f752294f36bfad7311e8d8509385190c2 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Wed, 28 Nov 2012 14:46:28 +0100 Subject: [PATCH 5/6] rename plugin folders according to repo --- plugin_config.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin_config.yml b/plugin_config.yml index ba895d1ddf..42d45d0af2 100644 --- a/plugin_config.yml +++ b/plugin_config.yml @@ -2,7 +2,7 @@ plugins/chiliproject_activity_module: repository: "git@github.com:finnlabs/chiliproject_activity_module.git" branch: master -plugins/chiliproject_help_link: +plugins/help_link: repository: "git@github.com:finnlabs/help_link.git" branch: master plugins/numbered_headings: @@ -11,7 +11,7 @@ plugins/numbered_headings: plugins/redmine_checkout: repository: "git@github.com:finnlabs/redmine_checkout.git" branch: master -plugins/redmine_customize_modules: +plugins/customize_modules: repository: "git@github.com:finnlabs/customize_modules.git" branch: master plugins/redmine_favicon: @@ -20,3 +20,4 @@ plugins/redmine_favicon: plugins/memcached_passenger: repository: "git@github.com:finnlabs/memcached_passenger.git" branch: master + From 8b86e1bbd865886c0e1f6e4fc6ef47d5a27371e4 Mon Sep 17 00:00:00 2001 From: Romano Licker Date: Wed, 28 Nov 2012 14:49:13 +0100 Subject: [PATCH 6/6] rename databases in example config file --- config/database.yml.example | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/database.yml.example b/config/database.yml.example index bd8f95f465..96d5e4cade 100644 --- a/config/database.yml.example +++ b/config/database.yml.example @@ -2,15 +2,15 @@ production: adapter: mysql - database: chiliproject + database: openproject host: localhost username: root password: encoding: utf8 - + development: adapter: mysql - database: chiliproject_development + database: openproject_development host: localhost username: root password: @@ -21,7 +21,7 @@ development: # Do not set this db to the same as development or production. test: adapter: mysql - database: chiliproject_test + database: openproject_test host: localhost username: root password: @@ -29,7 +29,7 @@ test: test_pgsql: adapter: postgresql - database: chiliproject_test + database: openproject_test host: localhost username: postgres password: "postgres"