Bitnami Redmine 5.6 VM初期設定

Bitnami Redmine 5.6のVMイメージが出ていたので初期設定メモ。
ssh設定を最初に実施する分は割愛しています。

# apt update

カタログのダウンロードはされますが、インストールはされないので割愛してよさそうです。

```
sudo apt update
```

```
Get:1 http://security.debian.org/debian-security bullseye-security InRelease [48.4 kB]
Get:2 http://security.debian.org/debian-security bullseye-security/main Sources [156 kB]
Get:3 http://security.debian.org/debian-security bullseye-security/main amd64 Packages [254 kB]
Get:4 http://security.debian.org/debian-security bullseye-security/main Translation-en [164 kB]
Get:5 http://http.us.debian.org/debian bullseye InRelease [116 kB]
Get:6 http://http.us.debian.org/debian bullseye-updates InRelease [44.1 kB]
Get:7 http://http.us.debian.org/debian bullseye/main Sources [8,502 kB]
Get:8 http://http.us.debian.org/debian bullseye/main amd64 Packages [8,062 kB]
Get:9 http://http.us.debian.org/debian bullseye/main Translation-en [6,236 kB]
Get:10 http://http.us.debian.org/debian bullseye-updates/main Sources [6,468 B]
Get:11 http://http.us.debian.org/debian bullseye-updates/main amd64 Packages [17.4 kB]
Get:12 http://http.us.debian.org/debian bullseye-updates/main Translation-en [10.1 kB]
Fetched 23.6 MB in 41s (571 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
42 packages can be upgraded. Run 'apt list --upgradable' to see them.
```

# エイリアス設定

llがつかいたいので。
```
vi .bash_aliases
```

中身
```
alias ls='ls --color=auto'
alias ll='ls -alF'
alias la='ls -A'
alias l='clear && ll'

# ドットの数で表現
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'

# 数字で表現
alias ..2='cd ../..'
alias ..3='cd ../../..'

# apt-get
alias ag='sudo apt-get'
alias agi='sudo apt-get install'
alias agr='sudo apt-get remove'
alias agu='sudo apt-get update'

# bundle系
alias b='bundle'
alias be='bundle exec'
alias bx='bundle exec'
alias bi='bundle install'
alias bo='bundle outdated'
alias bu='bundle update'
alias rc='bundle exec rails c'

# カレントディレクトリのパスをクリップボードにコピー(cpwd, copypathなど)
alias pwdc='pwd | tr -d "\n" | pbcopy'
export HT="/opt/bitnami/apps/redmine/htdocs"

alias ctl='sudo /opt/bitnami/ctlscript.sh'
alias cdh='cd ${HT}'

function unins() {
        echo "Uninstall Redmine Plugin : ${1}  OK?(y/N)"
        read ans

        if [ "${ans}" == "y" -o "${ans}" == "Y" ] ; then
                command bundle exec rake redmine:plugins:migrate NAME=${1} VERSION=0 RAILS_ENV=production
                rm -rf /opt/bitnami/apps/redmine/htdocs/plugins/${1}
        fi
}

```
反映
```
. .bash_aliases
```

# タイムゾーン設定

JSTにしておきます
```
sudo ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
```

# シンボリックリンク作成

`/opt/bitnami/redmine`はしょっちゅう使うので、ショートカットを張っておきます
```
ln -s /opt/bitnami/redmine/
```

# プラグイン導入

## 事前準備

プラグインを入れる前に、bitnamiユーザの権限を強化します。
デフォルトの状態だとプラグイン導入時に`Permission denied`されてしまいます。
参考ページ：https://github.com/bitnami/vms/issues/691
```
sudo chown -R bitnami:daemon /opt/bitnami/redmine /bitnami/redmine
sudo chmod -R g+w /opt/bitnami/redmine /bitnami/redmine
```

で、カレントディレクトリをpluginsに。

```
cd redmine/plugins
```

## view customize

いろいろ拡張するためには必須。
https://github.com/onozaty/redmine-view-customize

```
git clone https://github.com/onozaty/redmine-view-customize.git view_customize
cd ../
bundle install --without development test
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
```

bundle installのところで躓きます。
```
bitnami@debian:~/redmine$ bundle install --without development test
[DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set --local without 'development test'`, and stop using this flag
The dependencies in your gemfile changed, but the lockfile can't be updated because frozen mode is set

You have added to the Gemfile:
* activerecord-compatible_legacy_migration

Run `bundle install` elsewhere and add the updated Gemfile.lock to version control.
If this is a development machine, remove the Gemfile freeze by running `bundle config set frozen false`.
```
指示に従ってコマンド`bundle config set frozen false`を投入し再実行すると成功する。
`activerecord-compatible_legacy_migration`が必要だったようです。

```
bitnami@debian:~/redmine$ bundle config set frozen false
bitnami@debian:~/redmine$ bundle install --without development test
[DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set --local without 'development test'`, and stop using this flag
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching activerecord-compatible_legacy_migration 0.1.2
Installing activerecord-compatible_legacy_migration 0.1.2
Bundle complete! 46 Gemfile dependencies, 77 gems now installed.
Gems in the groups 'development' and 'test' were not installed.
Bundled gems are installed into `./vendor/bundle`
bitnami@debian:~/redmine$
```

## work_time

続いて、工数管理に必要なプラグインであるwork_timeをいれます。
https://github.com/tkusukawa/redmine_work_time

```
cd plugins
git clone https://github.com/tkusukawa/redmine_work_time.git
cd ..
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
ctl restart
```

## redmine_theme_changer

テーマにこだわる人のためにテーマチェンジャーを入れておきます。
https://github.com/haru/redmine_theme_changer

```
git clone https://github.com/haru/redmine_theme_changer.git
cd ..
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
ctl restart
```

## redmine_absolute_dates

カレンダーに出すのは日付であってほしい。
https://github.com/suer/redmine_absolute_dates

```
git clone https://github.com/suer/redmine_absolute_dates.git
ctl restart
```

## wiki lists

Wiki(チケットも可)内に検索結果を出したい。
https://github.com/tkusukawa/redmine_wiki_lists.git

```
git clone https://github.com/tkusukawa/redmine_wiki_lists.git
```

## Wiki ext

Wikiの機能拡張に。
https://github.com/haru/redmine_wiki_extensions

```
git clone https://github.com/haru/redmine_wiki_extensions.git
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
```

## Excel形式出力

redmine_xlsx_format_issue_exporter

```
git clone https://github.com/two-pack/redmine_xlsx_format_issue_exporter.git redmine_xlsx_format_issue_exporter
cd ..
bundle install --without test
```

ffiが入れられない、とエラーになる。
```
bitnami@debian:~/redmine$ bundle install --without test
[DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set --local without 'test'`, and stop using this flag
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching ffi 1.16.2
Installing ffi 1.16.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/ffi-1.16.2/ext/ffi_c
/opt/bitnami/ruby/bin/ruby extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.
```

Try&Errorの結果、makeやらgccやらが必要なので入れます。
```
sudo apt install make
sudo apt install gcc
sudo apt install libc6-dev
sudo apt-get install zlib1g-dev
```

無事成功。
```
bitnami@debian:~/redmine$ bundle install --without test
[DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set --local without 'test'`, and stop using this flag
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Installing ffi 1.16.2 with native extensions
Fetching rb-fsevent 0.11.2
Installing rb-fsevent 0.11.2
Fetching rb-inotify 0.10.1
Installing rb-inotify 0.10.1
Fetching listen 3.8.0
Installing listen 3.8.0
Fetching write_xlsx 1.11.1
Installing write_xlsx 1.11.1
Fetching yard 0.9.34
Installing yard 0.9.34
Bundle complete! 47 Gemfile dependencies, 83 gems now installed.
Gems in the group 'test' were not installed.
Bundled gems are installed into `./vendor/bundle`
```

## knowledgebase 　→　ダメでした。

使えるかな？　→　ダメでした。
https://github.com/alexbevi/redmine_knowledgebase

```
git clone https://github.com/alexbevi/redmine_knowledgebase.git
cd ..
bundle install
```

bundle install すると以下が入ります。
```
bitnami@debian:~/redmine$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching awesome_nested_set 3.6.0
Installing awesome_nested_set 3.6.0
Fetching liquid 2.6.3
Installing liquid 2.6.3
Fetching redmine_crm 0.0.61
Installing redmine_crm 0.0.61
Fetching ya2yaml 0.31
Installing ya2yaml 0.31
Bundle complete! 50 Gemfile dependencies, 87 gems now installed.
Gems in the group 'test' were not installed.
Bundled gems are installed into `./vendor/bundle`
```

反映
```
bundle exec rake redmine:plugins:migrate NAME=redmine_knowledgebase
```

エラーいっぱい。5に対応してなさそう。
```
bitnami@debian:~/redmine$ bundle exec rake redmine:plugins:migrate NAME=redmine_knowledgebase
rake aborted!
LoadError: cannot load such file -- macros
<internal:/opt/bitnami/ruby/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
<internal:/opt/bitnami/ruby/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
/opt/bitnami/redmine/plugins/redmine_knowledgebase/init.rb:2:in `<top (required)>'
/opt/bitnami/redmine/lib/redmine/plugin_loader.rb:31:in `load'
/opt/bitnami/redmine/lib/redmine/plugin_loader.rb:31:in `run_initializer'
/opt/bitnami/redmine/lib/redmine/plugin_loader.rb:108:in `each'
/opt/bitnami/redmine/lib/redmine/plugin_loader.rb:108:in `block in load'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:427:in `instance_exec'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:427:in `block in make_lambda'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:604:in `block (2 levels) in default_terminator'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:603:in `catch'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:603:in `block in default_terminator'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:199:in `block in halting'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:512:in `block in invoke_before'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:512:in `each'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:512:in `invoke_before'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:105:in `run_callbacks'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.7.6/lib/active_support/reloader.rb:88:in `prepare!'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.7.6/lib/rails/application/finisher.rb:124:in `block in <module:Finisher>'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.7.6/lib/rails/initializable.rb:32:in `instance_exec'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.7.6/lib/rails/initializable.rb:32:in `run'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.7.6/lib/rails/initializable.rb:61:in `block in run_initializers'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.7.6/lib/rails/initializable.rb:60:in `run_initializers'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.7.6/lib/rails/application.rb:391:in `initialize!'
/opt/bitnami/redmine/config/environment.rb:16:in `<top (required)>'
<internal:/opt/bitnami/ruby/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
<internal:/opt/bitnami/ruby/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:in `block in require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:299:in `load_dependency'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:in `require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.7.6/lib/rails/application.rb:367:in `require_environment!'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.7.6/lib/rails/application.rb:533:in `block in run_tasks_blocks'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/opt/bitnami/redmine/bin/bundle:108:in `load'
/opt/bitnami/redmine/bin/bundle:108:in `<main>'
Tasks: TOP => redmine:plugins:migrate => environment
(See full trace by running task with --trace)
```

Virtualboxで切り戻し。

## Easy gannt 

ガントチャートを高機能化するのはもはや必須。
Easy gannt をダウンロードして入れます。個人的に癖強イメージなので文言多め。
https://www.easyredmine.com/redmine-gantt-plugin

ゲットできるのはzipファイルなので、zipファイルを展開できるようにunzipを入れてしまいます。
※何かで使うかもしれないし

```
apt install unzip
```

sshでeasy_gantt_pro-5-x.zipを転送し、`/home/bitnami`に入れておきます。
```
bitnami@debian:~$ ll /home/bitnami/easy_gantt_pro-5-x.zip
-rw-r--r-- 1 bitnami bitnami 966721 Oct  8 14:42 /home/bitnami/easy_gantt_pro-5-x.zip
```

unzipすると`easy_baseline/` `easy_gantt/` `easy_gantt_pro/` の３つができます。
```
unzip easy_gantt_pro-5-x.zip
```
```
bitnami@debian:~$ ls -ld easy*
drwxr-xr-x 8 bitnami bitnami   4096 Nov  9  2022 easy_baseline
drwxr-xr-x 8 bitnami bitnami   4096 Nov  9  2022 easy_gantt
drwxr-xr-x 8 bitnami bitnami   4096 Nov  9  2022 easy_gantt_pro
-rw-r--r-- 1 bitnami bitnami 966721 Oct  8 14:42 easy_gantt_pro-5-x.zip
```

今回はeasy_ganntを入れたいので、easy_ganntを移動
```
mv easy_gantt/ redmine/plugins/.
```

db更新
```
cd redmine
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
ctl restart
```

`warning: already initialized constant IssueRelation`や`already initialized constant IssueRelation`というwarningがいっぱい出ますが無視。(ググったけど解決法が不明)
```
bitnami@debian:~/redmine$ bundle exec rake redmine:plugins:migrate RAILS_ENV=production
/bitnami/redmine/plugins/easy_gantt/lib/easy_gantt/issue_relation_patch.rb:40: warning: already initialized constant IssueRelation::TYPE_START_TO_START
/opt/bitnami/redmine/plugins/easy_gantt/lib/easy_gantt/issue_relation_patch.rb:40: warning: previous definition of TYPE_START_TO_START was here
/bitnami/redmine/plugins/easy_gantt/lib/easy_gantt/issue_relation_patch.rb:41: warning: already initialized constant IssueRelation::TYPE_FINISH_TO_FINISH
/opt/bitnami/redmine/plugins/easy_gantt/lib/easy_gantt/issue_relation_patch.rb:41: warning: previous definition of TYPE_FINISH_TO_FINISH was here
/bitnami/redmine/plugins/easy_gantt/lib/easy_gantt/issue_relation_patch.rb:42: warning: already initialized constant IssueRelation::TYPE_START_TO_FINISH
/opt/bitnami/redmine/plugins/easy_gantt/lib/easy_gantt/issue_relation_patch.rb:42: warning: previous definition of TYPE_START_TO_FINISH was here
/bitnami/redmine/plugins/redmine_wiki_extensions/lib/wiki_extensions_emoticons.rb:6: warning: already initialized constant WikiExtensionsEmoticons::YAML_FILE
/opt/bitnami/redmine/plugins/redmine_wiki_extensions/lib/wiki_extensions_emoticons.rb:6: warning: previous definition of YAML_FILE was here
== 20170213152215 AddDefaultPrintableTemplate: migrating ======================
== 20170213152215 AddDefaultPrintableTemplate: migrated (0.0000s) =============

== 20170224134615 UpdateRestApiSettings: migrating ============================
== 20170224134615 UpdateRestApiSettings: migrated (0.0097s) ===================
```


# 終わりに

とりあえず茶々っとやれる範囲でTry&errorした結果ではありますが、5.xで動作するプラグインかどうかを見極めるのが大変だな、、っておもいました。Bitnamiだといろいろ入ってないから、5.xで動かないのか、Bitnamiだから動かないのかを切り分けるのにも一手間かかるし。(とはいえ、これは素のOSを何で入れるか次第なので、手間は一緒かもしれませんが)