net-radio-archiveを入れてみる

# apt-get update
# apt-get install rtmpdump libav-tools swftools ruby git
# gem install bundler
# adduser radioarc
# su - radioarc
$ git clone https://github.com/yayugu/net-radio-archive.git
$ cd net-radio-archive
$ git submodule update --init --recursive

ここまで実行したら次のようなエラーが出る。

$ git submodule update --init --recursive
Cloning into 'niconico'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Clone of 'git@github.com:yayugu/niconico.git' into submodule path 'niconico' failed

ニコ動は取らないのでとりあえず無視しておく。

$ bundle install --without development test agon

しまった。root権限を求められた。

# bundle install --without development test agon

rootで実行してみた。

Installing unf_ext 0.0.7.1 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/bin/ruby2.1 extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.1.0/gems/unf_ext-0.0.7.1 for inspection.
Results logged to /var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/unf_ext-0.0.7.1/gem_make.out
An error occurred while installing unf_ext (0.0.7.1), and Bundler cannot
continue.
Make sure that `gem install unf_ext -v '0.0.7.1'` succeeds before bundling.

何かが足りない。ruby-develって無いのかな。
Debian -- Package Contents Search Results -- ruby.hで調べてみた。

# apt-get install ruby-dev

ruby-devだった。

You have to install development tools first.

あー、build-essentialが入っていないか。

# apt-get install build-essential 

これで、unf_ext 0.0.7.1 with native extensionsが入った。
のこぎりのインストールにしばらく時間がかかる。

Installing mysql2 0.3.17 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/bin/ruby2.1 extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** 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.

lmysqlclientが足りないか。

# apt-get install libmariadb2

こうかな。
まだ足りない。

# apt-get install libmariadbd-dev 

違った…

# apt-get install mariadb-client
# apt-get install libmariadb-client-lgpl-dev

これも違う…

# gem install mysql2
# apt-get install libmysqld-dev 

これだとうまく行った。
どうやらmysqlにしか対応していない?

$ cp config/database.example.yml config/database.yml
$ cp config/settings.example.yml config/settings.yml
$ vim.tiny config/database.yml
$ vim.tiny config/settings.yml
apt-get install mariadb-server

mariadbのrootパスワードの設定を求められるので、head -c 16 /dev/random | base64で生成した。

$ RAILS_ENV=production bundle exec rake db:create db:migrate
Could not find gem 'niconico (>= 0) ruby' in source at niconico.
Source does not contain any versions of 'niconico (>= 0) ruby'

orz
niconicoが無いとダメなのか…
困った。
SSH経由でサブモジュールを読み込むらしいが、これはSSH鍵による認証が必要だ。
SSH鍵を管理するのはなかなか面倒なんだよな。

16:56追記:
鍵を作ってgithubに登録した。

$ git submodule update --init --recursive
$ RAILS_ENV=production bundle exec rake db:create db:migrate
rake aborted!
ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.

うぇ。何かが足りない。

# apt-get install nodejs

jessie標準なので古そうだが動いて欲しい。

$ RAILS_ENV=production bundle exec rake db:create db:migrate
== 20150515174349 CreateJob: migrating ========================================
== 20150515174349 CreateJob: migrated (0.0141s) ===============================

== 20150515174821 CreateOnsenProgram: migrating ===============================
== 20150515174821 CreateOnsenProgram: migrated (0.0123s) ======================

== 20150515174949 CreateHibikiProgram: migrating ==============================
== 20150515174949 CreateHibikiProgram: migrated (0.0112s) =====================

== 20150521174524 CreateAnitamaProgram: migrating =============================
== 20150521174524 CreateAnitamaProgram: migrated (0.0113s) ====================

== 20150527135411 CreateNiconicoLivePrograms: migrating =======================
== 20150527135411 CreateNiconicoLivePrograms: migrated (0.0120s) ==============

== 20150602100911 NicoAddColumn: migrating ====================================
== 20150602100911 NicoAddColumn: migrated (0.0361s) ===========================

== 20150607130411 KeyValue: migrating =========================================
== 20150607130411 KeyValue: migrated (0.0115s) ================================

== 20151002075432 CreateAgonProgram: migrating ================================
== 20151002075432 CreateAgonProgram: migrated (0.0146s) =======================

うまく行ったっぽい。

$ bundle exec whenever --update-crontab
[write] crontab file updated

これでセットアップ完了か?

新幹線の無線LANの遅延がひどすぎて、作業がなかなか進まなかったが、なんとか完了したようだ。

アップデート

$ git pull origin master
$ git submodule update --init --recursive
$ bundle install --without development test agon
$ RAILS_ENV=production bundle exec rake db:migrate
$ bundle exec whenever --update-crontab