redmine-installer 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +25 -0
  3. data/Gemfile +19 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +273 -0
  6. data/Rakefile +7 -0
  7. data/bin/redmine +8 -0
  8. data/lib/redmine-installer.rb +72 -0
  9. data/lib/redmine-installer/backup.rb +48 -0
  10. data/lib/redmine-installer/cli.rb +90 -0
  11. data/lib/redmine-installer/command.rb +142 -0
  12. data/lib/redmine-installer/config_param.rb +90 -0
  13. data/lib/redmine-installer/error.rb +5 -0
  14. data/lib/redmine-installer/exec.rb +158 -0
  15. data/lib/redmine-installer/ext/module.rb +7 -0
  16. data/lib/redmine-installer/ext/string.rb +15 -0
  17. data/lib/redmine-installer/git.rb +51 -0
  18. data/lib/redmine-installer/helper.rb +5 -0
  19. data/lib/redmine-installer/helpers/generate_config.rb +29 -0
  20. data/lib/redmine-installer/install.rb +56 -0
  21. data/lib/redmine-installer/locales/cs.yml +145 -0
  22. data/lib/redmine-installer/locales/en.yml +146 -0
  23. data/lib/redmine-installer/plugin.rb +9 -0
  24. data/lib/redmine-installer/plugins/base.rb +28 -0
  25. data/lib/redmine-installer/plugins/database.rb +168 -0
  26. data/lib/redmine-installer/plugins/email_sending.rb +82 -0
  27. data/lib/redmine-installer/plugins/redmine_plugin.rb +30 -0
  28. data/lib/redmine-installer/plugins/web_server.rb +26 -0
  29. data/lib/redmine-installer/profile.rb +74 -0
  30. data/lib/redmine-installer/step.rb +15 -0
  31. data/lib/redmine-installer/steps/backup.rb +120 -0
  32. data/lib/redmine-installer/steps/base.rb +60 -0
  33. data/lib/redmine-installer/steps/database_config.rb +15 -0
  34. data/lib/redmine-installer/steps/email_config.rb +11 -0
  35. data/lib/redmine-installer/steps/install.rb +21 -0
  36. data/lib/redmine-installer/steps/load_package.rb +180 -0
  37. data/lib/redmine-installer/steps/move_redmine.rb +22 -0
  38. data/lib/redmine-installer/steps/redmine_root.rb +29 -0
  39. data/lib/redmine-installer/steps/upgrade.rb +55 -0
  40. data/lib/redmine-installer/steps/validation.rb +38 -0
  41. data/lib/redmine-installer/steps/webserver_config.rb +22 -0
  42. data/lib/redmine-installer/task.rb +85 -0
  43. data/lib/redmine-installer/upgrade.rb +68 -0
  44. data/lib/redmine-installer/utils.rb +233 -0
  45. data/lib/redmine-installer/version.rb +5 -0
  46. data/redmine-installer.gemspec +25 -0
  47. data/spec/lib/install_spec.rb +46 -0
  48. data/spec/lib/upgrade_spec.rb +62 -0
  49. data/spec/load_redmine.rb +24 -0
  50. data/spec/spec_helper.rb +30 -0
  51. metadata +130 -0
@@ -0,0 +1,7 @@
1
+ class Module
2
+ unless method_defined?(:camelize)
3
+ def class_name
4
+ name.split('::').last
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ class String
2
+ unless method_defined?(:camelize)
3
+ # Base on ActiveSupport method
4
+ def camelize
5
+ self.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
6
+ end
7
+ end
8
+
9
+ unless method_defined?(:underscore)
10
+ def underscore
11
+ self.gsub(/\A([A-Z])/){$1.downcase}
12
+ .gsub(/([A-Z])/){'_'+$1.downcase}
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,51 @@
1
+ module Redmine::Installer
2
+ class Git
3
+
4
+ # Simple git clone. Create a shallow clone with 1 revision.
5
+ #
6
+ # - download specific branch
7
+ # - single branch
8
+ # - store repository to target
9
+ #
10
+ def self.clone(remote, target, branch='master')
11
+ success = Kernel.system("git clone --branch #{branch} --single-branch --depth 1 #{remote} #{target}")
12
+
13
+ unless success
14
+ error :git_repository_cannot_be_clonned
15
+ end
16
+ end
17
+
18
+ # Git repository is locally clonned to target. On copied git is
19
+ # executed `git fetch` (for preserve changes)
20
+ #
21
+ def self.copy_and_fetch(repository, target)
22
+ url = ''
23
+ # Store original remote url because copied repository will
24
+ # have remote set to local repo
25
+ Dir.chdir(repository) do
26
+ url = `git config --get remote.origin.url`.strip
27
+ end
28
+
29
+ success = Kernel.system("git clone --depth 1 --no-local #{repository} #{target}")
30
+
31
+ unless success
32
+ error :git_repository_cannot_be_localy_clonned
33
+ end
34
+
35
+ # Change remote to origin and run fetch
36
+ Dir.chdir(target) do
37
+ Kernel.system("git remote set-url origin #{url}")
38
+ success = Kernel.system('git fetch')
39
+ end
40
+
41
+ unless success
42
+ error :git_repository_cannot_be_fetched
43
+ end
44
+ end
45
+
46
+ def self.error(message)
47
+ raise Redmine::Installer::Error, I18n.translate(message)
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,5 @@
1
+ module Redmine::Installer
2
+ module Helper
3
+ autoload :GenerateConfig, 'redmine-installer/helpers/generate_config'
4
+ end
5
+ end
@@ -0,0 +1,29 @@
1
+ module Redmine::Installer::Helper
2
+ module GenerateConfig
3
+
4
+ def create_for(type)
5
+ choices = {}
6
+ type.all.each do |m|
7
+ choices[m] = m.title
8
+ end
9
+ choices[nil] = t(:skip)
10
+
11
+ # answer = choose(:"what_#{type.class_name.downcase}_do_you_want", choices, default: nil)
12
+ answer = choose(nil, choices, default: nil)
13
+
14
+ # Skip
15
+ return false if answer.nil?
16
+
17
+ instance = answer.new
18
+
19
+ say("(#{instance.class.title})", 2)
20
+ instance.params.for_asking.each do |p|
21
+ p.value = ask(p.title, default: p.default)
22
+ end
23
+
24
+ instance.make_config(base.tmp_redmine_root)
25
+ return true
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,56 @@
1
+ ##
2
+ # Install redmine
3
+ #
4
+ # You can instal redmine package from archive or git.
5
+ #
6
+ # == Steps:
7
+ # 1. Redmine root - where should be new redmine located
8
+ # 2. Load package - extract package
9
+ # 3. Database configuration - you can choose type of DB which you want to use
10
+ # 4. Email sending configuration - email sending configuration
11
+ # 5. Install - install commands are executed
12
+ # 6. Moving redmine - redmine is moved from temporarily folder to given redmine_root
13
+ # 7. Webserve configuration - generating webserver configuration
14
+ #
15
+ # == Usage:
16
+ #
17
+ # From archive::
18
+ # Supported archives are .zip and .tar.gz.
19
+ # =>
20
+ # # minimal
21
+ # redmine upgrade PATH_TO_PACKAGE
22
+ #
23
+ # # full
24
+ # redmine upgrade PATH_TO_PACKAGE --env ENV1,ENV2,ENV3
25
+ #
26
+ # From git::
27
+ # # minimal
28
+ # redmine upgrade GIT_REPO --source git
29
+ #
30
+ # # full
31
+ # redmine upgrade GIT_REPO --source git --env ENV1,ENV2,ENV3
32
+ #
33
+ module Redmine::Installer
34
+ class Install < Task
35
+
36
+ STEPS = [
37
+ step::RedmineRoot,
38
+ step::LoadPackage,
39
+ step::DatabaseConfig,
40
+ step::EmailConfig,
41
+ step::Install,
42
+ step::MoveRedmine,
43
+ step::WebserverConfig
44
+ ]
45
+
46
+ attr_accessor :package
47
+
48
+ def initialize(package, options={})
49
+ self.package = package
50
+ super(options)
51
+
52
+ check_package
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,145 @@
1
+ cs:
2
+ redmine_installer_summary: 'Snadný způsob instalace/upgradu redmine.'
3
+ backup: 'Záloha'
4
+ backup_is_stored_at: 'Záloha je uložena <bright>%{dir}</bright>'
5
+ cli_install_desc: 'Instalace'
6
+ cli_show_verbose_output: 'Zobrazení debug výstupu'
7
+ cli_upgrade_desc: 'Aktualizace redmine'
8
+ cli_backup_desc: 'Záloha'
9
+ cli_flag_source: 'Jaký typ je balíček'
10
+ cli_flag_branch: 'Jiná větev gitu'
11
+ cli_flag_environment: 'Prostředí redminu'
12
+ dir_not_exist_and_cannot_be_created: 'Složka %{dir} neexistuje a nemůže být vytvořena'
13
+ dir_is_not_writeable: 'Složka <bright>%{dir}</bright> není zapisovatelná'
14
+ do_you_want_repeat_command: 'Chcete opakovat příkaz?'
15
+ do_you_want_full_backup: 'Chcete plnou zálohu?'
16
+ do_you_want_backup_redmine: 'Chcete zálohovat redmine?'
17
+ do_you_want_save_step_for_further_use: 'Chcete uložit kroky pro využití v budoucnu'
18
+ error_redmine_not_contains_all: 'Redmine root neobsahuje tyto záznamy: <bright>%{records}</bright>'
19
+ error_plugins_should_be_on_plugins: 'Plugin by měl být v plugins složce'
20
+ error_argument_package_is_missing: 'Chybý argument: redmine package'
21
+ error_unsupported_source: 'Nepodporovaný zdroj: %{source}'
22
+ exit: 'exit'
23
+ file_not_exist: 'Soubor <bright>%{file}</bright> neexistuje'
24
+ file_must_have_format: 'Soubor <bright>%{file}</bright> musí mít formát: %{formats}'
25
+ full_backup: 'Plná záloha'
26
+ git_repository_cannot_be_clonned: 'Repozitář nemůže být klonován'
27
+ git_repository_cannot_be_localy_clonned: 'Repozitář nemůže být lokálně klonován'
28
+ git_repository_cannot_be_fetched: 'Repozitář nemůže stáhnout poslední verzi'
29
+ no_t: 'ne'
30
+ only_database: 'Pouze databáze'
31
+ path_for_redmine_root: 'Cesta pro redmine_root'
32
+ powered_by: 'Powered by EasyRedmine'
33
+ skip: 'Přeskočit'
34
+ try_again: 'zkusit znova'
35
+ what_dir_for_backups: 'Jaká složka pro zálohu?'
36
+ what_database_do_you_want: 'Jakou databázi chcete?'
37
+ what_web_server_do_you_want: 'Jaký web-server chcete?'
38
+ yes_t: 'ano'
39
+ your_profile_can_be_used_as: 'Váš profil je uložen jako #%{id} a může být použit s <bright>--profile %{id}</bright>'
40
+
41
+ step:
42
+ load_package:
43
+ title: 'Zpracování balíku'
44
+ database_config:
45
+ title: 'Konfigurace databáze'
46
+ email_config:
47
+ title: 'Konfigurace emailového nastavení'
48
+ install:
49
+ title: 'Installace'
50
+ move_redmine:
51
+ title: 'Přesun redmine'
52
+ webserver_config:
53
+ title: 'Webserver konfigurace'
54
+ validation:
55
+ title: 'Validace'
56
+ backup:
57
+ title: 'Záloha'
58
+ upgrade:
59
+ title: 'Aktualizace'
60
+ save_profile:
61
+ title: 'Uložení profilu'
62
+ redmine_root:
63
+ title: 'Redmine root'
64
+
65
+ plugin:
66
+ database:
67
+ mysql:
68
+ title: 'MySQL'
69
+ postgresql:
70
+ title: 'PostgreSQL'
71
+ emailsending:
72
+ gmail:
73
+ title: 'Gmail'
74
+ sendmail:
75
+ title: 'Sendmail'
76
+ smtpfromscratch:
77
+ title: 'SMTP od základu'
78
+ webserver:
79
+ webrick:
80
+ title: 'Webrick'
81
+ configuration: |
82
+ Webrick je výchozí webserver.
83
+ Server je připravený pro start.
84
+ thin:
85
+ title: 'Thin'
86
+ configuration: |
87
+ Přidejte:
88
+ <bright>gem 'thin'</bright>
89
+
90
+ do <bright>Gemfile.local</bright>
91
+
92
+ a spusťtě: <bright>bundle install</bright>
93
+
94
+ (Více informací na http://code.macournoyer.com/thin)
95
+ apachepassenger:
96
+ title: 'Passenger (apache)'
97
+ configuration: |
98
+ Přidejte toto do konfiguračního souboru.
99
+
100
+ <bright><VirtualHost *:80>
101
+ ServerName www.yourhost.com
102
+ DocumentRoot %{redmine_root}/public
103
+ <Directory %{redmine_root}/public>
104
+ # This relaxes Apache security settings.
105
+ AllowOverride all
106
+ # MultiViews must be turned off.
107
+ Options -MultiViews
108
+ # Uncomment this if you're on Apache >= 2.4:
109
+ #Require all granted
110
+ </Directory>
111
+ </VirtualHost></bright>
112
+
113
+ Více informací na https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html
114
+ nginxpassenger:
115
+ title: 'Passenger (nginx)'
116
+ configuration: |
117
+ Přidejte toto do konfiguračního souboru.
118
+
119
+ <bright>server {
120
+ listen 80;
121
+ server_name www.yourhost.com;
122
+ root %{redmine_root}/public; # <--- be sure to point to 'public'!
123
+ passenger_enabled on;
124
+ }</bright>
125
+
126
+ Více informací na https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html
127
+ puma:
128
+ title: 'Puma'
129
+ configuration: |
130
+ Přidejte:
131
+ <bright>gem 'puma'</bright>
132
+
133
+ do <bright>Gemfile.local</bright>
134
+
135
+ Více informací na http://puma.io
136
+ redmine_plugin:
137
+ easyproject:
138
+ install: 'Easyproject instalace'
139
+
140
+ command:
141
+ bundle_install: 'Bundle install'
142
+ rake_db_create: 'DB creating'
143
+ rake_db_migrate: 'DB migrating'
144
+ rake_redmine_plugin_migrate: 'Plugin migrating'
145
+ rake_generate_secret_token: 'Generate secret token'
@@ -0,0 +1,146 @@
1
+
2
+ en:
3
+ redmine_installer_summary: 'Easy way how install/upgrade redmine or plugin.'
4
+ backup: 'Backup'
5
+ backup_is_stored_at: 'Backup is stored at <bright>%{dir}</bright>'
6
+ cli_install_desc: 'Install redmine'
7
+ cli_show_verbose_output: 'Show verbose output'
8
+ cli_upgrade_desc: 'Upgrade redmine'
9
+ cli_backup_desc: 'Backup redmine'
10
+ cli_flag_source: 'What type is package argument'
11
+ cli_flag_branch: 'Different branch for git'
12
+ cli_flag_environment: 'Environment for redmine'
13
+ dir_not_exist_and_cannot_be_created: 'Dir %{dir} does not exist and can not be created'
14
+ dir_is_not_writeable: 'Dir <bright>%{dir}</bright> is not writeable'
15
+ do_you_want_repeat_command: 'Do you want repeat this command?'
16
+ do_you_want_full_backup: 'Do you want full backup?'
17
+ do_you_want_backup_redmine: 'Do you want backup redmine?'
18
+ do_you_want_save_step_for_further_use: 'Do you want save steps for further use?'
19
+ error_redmine_not_contains_all: 'Redmine root does not contains necessary folders: <bright>%{records}</bright>'
20
+ error_plugins_should_be_on_plugins: 'Plugin shoold be on plugins dir'
21
+ error_argument_package_is_missing: 'Missing argument: redmine package'
22
+ error_unsupported_source: 'Unsupported source: %{source}'
23
+ exit: 'exit'
24
+ file_not_exist: 'File <bright>%{file}</bright> does not exist'
25
+ file_must_have_format: 'File <bright>%{file}</bright> must have format: %{formats}'
26
+ full_backup: 'Full backup'
27
+ git_repository_cannot_be_clonned: 'Repository cannot be clonned'
28
+ git_repository_cannot_be_localy_clonned: 'Repository cannot be localy clonned'
29
+ git_repository_cannot_be_fetched: 'Repository cannot fetch new version'
30
+ no_t: 'no'
31
+ only_database: 'Only database'
32
+ path_for_redmine_root: 'Path for redmine_root'
33
+ powered_by: 'Powered by EasyRedmine'
34
+ skip: 'Skip'
35
+ try_again: 'try again'
36
+ what_dir_for_backups: 'What dir for backups?'
37
+ what_database_do_you_want: 'What database do you want?'
38
+ what_web_server_do_you_want: 'What web-server do you want?'
39
+ yes_t: 'yes'
40
+ your_profile_can_be_used_as: 'Your profile is saved as #%{id} and can be use with <bright>--profile %{id}</bright>'
41
+
42
+ step:
43
+ load_package:
44
+ title: 'Load package'
45
+ database_config:
46
+ title: 'Database configuration'
47
+ email_config:
48
+ title: 'Email sending configuration'
49
+ install:
50
+ title: 'Install'
51
+ move_redmine:
52
+ title: 'Moving redmine'
53
+ webserver_config:
54
+ title: 'Webserver configuration'
55
+ validation:
56
+ title: 'Validation'
57
+ backup:
58
+ title: 'Backup'
59
+ upgrade:
60
+ title: 'Upgrading'
61
+ save_profile:
62
+ title: 'Saving profile'
63
+ redmine_root:
64
+ title: 'Redmine root'
65
+
66
+ plugin:
67
+ database:
68
+ mysql:
69
+ title: 'MySQL'
70
+ postgresql:
71
+ title: 'PostgreSQL'
72
+ emailsending:
73
+ gmail:
74
+ title: 'Gmail'
75
+ sendmail:
76
+ title: 'Sendmail'
77
+ smtpfromscratch:
78
+ title: 'SMTP from scratch'
79
+ webserver:
80
+ webrick:
81
+ title: 'Webrick'
82
+ configuration: |
83
+ Webrick is default webserver.
84
+ Server is ready to start.
85
+ thin:
86
+ title: 'Thin'
87
+ configuration: |
88
+ Add:
89
+ <bright>gem 'thin'</bright>
90
+
91
+ to <bright>Gemfile.local</bright>
92
+
93
+ and run: <bright>bundle install</bright>
94
+
95
+ (More informations can be found at http://code.macournoyer.com/thin)
96
+ apachepassenger:
97
+ title: 'Passenger (apache)'
98
+ configuration: |
99
+ Add this to apache configuration file.
100
+
101
+ <bright><VirtualHost *:80>
102
+ ServerName www.yourhost.com
103
+ DocumentRoot %{redmine_root}/public
104
+ <Directory %{redmine_root}/public>
105
+ # This relaxes Apache security settings.
106
+ AllowOverride all
107
+ # MultiViews must be turned off.
108
+ Options -MultiViews
109
+ # Uncomment this if you're on Apache >= 2.4:
110
+ #Require all granted
111
+ </Directory>
112
+ </VirtualHost></bright>
113
+
114
+ More informations can be found at https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html
115
+ nginxpassenger:
116
+ title: 'Passenger (nginx)'
117
+ configuration: |
118
+ Add this to nginx configuration file.
119
+
120
+ <bright>server {
121
+ listen 80;
122
+ server_name www.yourhost.com;
123
+ root %{redmine_root}/public; # <--- be sure to point to 'public'!
124
+ passenger_enabled on;
125
+ }</bright>
126
+
127
+ More informations can be found at https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html
128
+ puma:
129
+ title: 'Puma'
130
+ configuration: |
131
+ Add:
132
+ <bright>gem 'puma'</bright>
133
+
134
+ to <bright>Gemfile.local</bright>
135
+
136
+ More informations can be found at http://puma.io
137
+ redmine_plugin:
138
+ easyproject:
139
+ install: 'Easyproject installing'
140
+
141
+ command:
142
+ bundle_install: 'Bundle install'
143
+ rake_db_create: 'DB creating'
144
+ rake_db_migrate: 'DB migrating'
145
+ rake_redmine_plugin_migrate: 'Plugin migrating'
146
+ rake_generate_secret_token: 'Generate secret token'