manatee-itの備忘ログ

プログラム初心者のブログ。ruby on railsでWebサービスを作成中。(仕事が忙しくなかななか進まず) つまずいた所をなんでも記録。 環境:Ruby2.1 + Rails4.1.1 + Passenger + CentOS6.4(Apache + sqlite/MySQL)

vagrant基本操作メモ (編集中)

こちらに記載されている内容を参考しました。

http://blog.raqda.com/vagrant/cli/index.html
vagrantコマンド一覧 - Qiita
Vagrantの使い方とコマンド一覧のまとめ - Qiita
Vagrant のコマンドをメモしておく - Programming log - Shindo200


■バージョン確認

$ vagrant --version
Vagrant 1.7.2

■作成/編集/削除

$ vagrant reload
$ vagrant destroy 


■BOXサブコマンド

$ vagrant box add CentOS6.6 https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.0.0/centos-6.6-x86_64.box

ダウンロードした実体は以下に格納される。
$HOME/.vagrant.d/boxes/
$ vagrant box -h
Usage: vagrant box <subcommand> [<args>]

Available subcommands:
     add
     list
     outdated
     remove
     repackage
     update

For help on any individual subcommand run `vagrant box <subcommand> -h`
$ vagrant box list
hashicorp/precise32     (virtualbox, 1.0.0)
chef/centos-6.5 (virtualbox, 1.0.0)
chef/centos-7.1 (virtualbox, 1.0.0)
$ vagrant box remove hashicorp/precise32
Box 'hashicorp/precise32' (v1.0.0) with provider 'virtualbox' appears
to still be in use by at least one Vagrant environment. Removing
the box could corrupt the environment. We recommend destroying
these environments first:

default (ID: 5b58c53dbf674efb872117bb6047f3ce)

Are you sure you want to remove this box? [y/N] y
Removing box 'hashicorp/precise32' (v1.0.0) with provider 'virtualbox'...


■ログイン/ログアウト

$ pwd
/home/manatee/VagrantTest/testcentos65
$ vagrant ssh
Last login: Sun Jul  5 23:03:31 2015 from 10.0.2.2
$ exit
logout
Connection to 127.0.0.1 closed.


■起動/停止/状態確認

$ pwd
/home/manatee/VagrantTest/testcentos65
$ vagrant status
Current machine states:

default                   running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.


>||
$ vagrant suspend
==> default: Saving VM state and suspending execution...

$ vagrant status
Current machine states:

default                   saved (virtualbox)

To resume this VM, simply run `vagrant up`.

$ vagrant halt
==> default: Discarding saved state of VM...
$ vagrant status
Current machine states:

default                   poweroff (virtualbox)

The VM is powered off. To restart the VM, simply run `vagrant up`

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'chef/centos-6.5' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /home/manatee/VagrantTest/testcentos65
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant

The error output from the last command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device


「Failed to mount folders in Linux guest. This is usually because...」のエラーについては、以下情報を参考にして解消させました。
対応するまでデフォルト設定となっているゲストOSとの共有が有効になっていませんでした。

vagrantでmountエラーの解決方法 - Qiita

$ rpm -qf   /etc/init.d/vboxadd-service
ファイル /etc/init.d/vboxadd-service はどのパッケージにも属していません。
[vagrant@localhost ~]$ sudo /etc/init.d/vboxadd setup
Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]
Building the VirtualBox Guest Additions kernel modules
The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.
The missing package can be probably installed with
yum install kernel-devel-2.6.32-504.23.4.el6.x86_64

Building the main Guest Additions module                   [失敗]
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions              [  OK  ]

$ sudo yum install kernel-devel-2.6.32-504.23.4.el6.x86_64

$ rpm -qa |grep kernel
dracut-kernel-004-356.el6_6.2.noarch
kernel-2.6.32-504.23.4.el6.x86_64
kernel-headers-2.6.32-504.23.4.el6.x86_64
kernel-firmware-2.6.32-504.23.4.el6.noarch
kernel-devel-2.6.32-504.23.4.el6.x86_64
kernel-2.6.32-431.el6.x86_64

$ sudo /etc/init.d/vboxadd setup
Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module                   [  OK  ]
Building the shared folder support module                  [  OK  ]
Building the OpenGL support module                         [  OK  ]
Doing non-kernel setup of the Guest Additions              [  OK  ]
Starting the VirtualBox Guest Additions                    [  OK  ]

ネットワークの変更を行った後に起動

$ vim Vagrantfile
$ vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'chef/centos-7.1' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 2200 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2200
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /home/manatee/VagrantTest/testcentos71
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.

CentOS環境にvagrant+VirtualBoxを導入

CentOS環境にvagrant+chef(+VirtualBox)を導入するメモ


以下理由により、VMWareESXi5.0をインストールしていたPCを潰して、CentOS6.6をインストールした。
vagrantVMWare(player)でも動作する様子。また、vagrant-vsphereというものがあるが、単体のVMWareESXiのみでは動くのかわからなかった。
・インストールしていたPCは、OSレスで購入していた。

導入にあたり、以下URLが大変役に立ちました。GUIを利用しないのは、大変スムーズですね。

qiita.com



○DKMS のインストール

$ sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[sudo] password for manatee:
http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm を取得中
警告: /var/tmp/rpm-tmp.TgJlkV: ヘッダ V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
準備中...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

$ sudo yum install dkms

$ chkconfig --list |grep dkms
dkms_autoinstaller      0:off   1:off   2:on    3:on    4:on    5:on    6:off

注意:DKMSのインストールにて、kernel-develパッケージが追加インストールされるが、
同時にkernelのバージョンをそろえないとモジュールがロードしない。



VirtualBox のインストール

リポジトリ追加

$ cd /etc/yum.repos.d/
$ sudo wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo

VirtualBoxのインストール

$ sudo yum install VirtualBox-4.3

$ chkconfig --list |grep box
vboxautostart-service   0:off   1:off   2:on    3:on    4:on    5:on    6:off
vboxballoonctrl-service 0:off   1:off   2:on    3:on    4:on    5:on    6:off
vboxdrv         0:off   1:off   2:on    3:on    4:on    5:on    6:off
vboxweb-service 0:off   1:off   2:on    3:on    4:on    5:on    6:off

VirtualBoxを実行するユーザーアカウントを、VirtualBoxのグループ(vboxusers)に割り当て

$ sudo usermod -a -G vboxusers manatee

Vagrant の導入

最新版のURLを以下から確認

Download Vagrant - Vagrant


$ sudo rpm -Uvh https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2_x86_64.rpm

セットアップして起動
Getting Started - Vagrant Documentation


これ以降、kernel-develとkernelパッケージのバージョンが一致していなかったため、エラーが発生。
エラー解消の試行錯誤のため、不要な操作が含まれている可能性があります。

$ vagrant init hashicorp/precise32
The user that is running Vagrant doesn't have the proper permissions
to write a Vagrantfile to the specified location. Please ensure that
you call `vagrant init` in a location where the proper permissions
are in place to create a Vagrantfile.


$ vagrant up
A Vagrant environment or target machine is required to run this
command. Run `vagrant init` to create a new Vagrant environment. Or,
get an ID of a target machine from `vagrant global-status` to run
this command on. A final option is to change to a directory with a
Vagrantfile and to try again.

(OS再起動)

$ vagrant init hashicorp/precise32
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

$ vagrant up
VirtualBox is complaining that the kernel module is not loaded. Please
run `VBoxManage --version` or open the VirtualBox GUI to see the error
message which should contain instructions on how to fix this error.

⇒エラー発生

$ VBoxManage --version
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
         available for the current kernel (2.6.32-504.el6.x86_64) or it failed to
         load. Please recompile the kernel module and install it by

           sudo /etc/init.d/vboxdrv setup

         You will not be able to start VMs until this problem is fixed.
4.3.28r100309

⇒エラー発生

$ sudo /etc/init.d/vboxdrv setup
[sudo] password for manatee:
Stopping VirtualBox kernel modules                         [  OK  ]
Uninstalling old VirtualBox DKMS kernel modules            [  OK  ]
Trying to register the VirtualBox kernel modules using DKMSError! echo
Your kernel headers for kernel 2.6.32-504.el6.x86_64 cannot be found at
/lib/modules/2.6.32-504.el6.x86_64/build or /lib/modules/2.6.32-504.el6.x86_64/source.
                                                           [失敗]
  (Failed, trying without DKMS)
Recompiling VirtualBox kernel modules                      [失敗]
  (Look at /var/log/vbox-install.log to find out what went wrong)

⇒エラー発生

$ cat /var/log/vbox-install.log
Uninstalling modules from DKMS
  removing old DKMS module vboxhost version  4.3.28

'------------------------------
Deleting module version: 4.3.28
completely from the DKMS tree.
'------------------------------
Done.
Attempting to install using DKMS

Creating symlink /var/lib/dkms/vboxhost/4.3.28/source ->
                 /usr/src/vboxhost-4.3.28



DKMS: add completed.
Failed to install using DKMS, attempting to install without
Makefile:183: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  中止.

カーネル環境変数が定義されていない様子なので、exportしてみたが、再度エラーが発生。

$ export KERN_DIR=/usr/src/kernels/2.6.32-504.23.4.el6.x86_64

$ sudo /etc/init.d/vboxdrv setup
[sudo] password for manatee:
Stopping VirtualBox kernel modules                         [  OK  ]
Uninstalling old VirtualBox DKMS kernel modules            [  OK  ]
Trying to register the VirtualBox kernel modules using DKMSError! echo
Your kernel headers for kernel 2.6.32-504.el6.x86_64 cannot be found at
/lib/modules/2.6.32-504.el6.x86_64/build or /lib/modules/2.6.32-504.el6.x86_64/source.
                                                           [失敗]
  (Failed, trying without DKMS)
Recompiling VirtualBox kernel modules                      [失敗]
  (Look at /var/log/vbox-install.log to find out what went wrong)

⇒再度エラー発生。

$ rpm -qa | grep kernel
kernel-headers-2.6.32-504.el6.x86_64
libreport-plugin-kerneloops-2.0.9-21.el6.centos.x86_64
kernel-devel-2.6.32-504.23.4.el6.x86_64
kernel-firmware-2.6.32-504.el6.noarch
abrt-addon-kerneloops-2.0.8-26.el6.centos.x86_64
dracut-kernel-004-356.el6.noarch
kernel-2.6.32-504.el6.x86_64

⇒kernel-develとkernelパッケージのバージョンの不一致を確認。
vagrantyumでインストールした際に、依存関係でkernel-develのみ最新になっていたのが原因。


カーネル関連パッケージについて、すべて最新にアップデートした。

$ sudo yum install kernel kernel-firmware kernel-headers

●OS再起動

$ rpm -qa | grep kernel
libreport-plugin-kerneloops-2.0.9-21.el6.centos.x86_64
kernel-devel-2.6.32-504.23.4.el6.x86_64
kernel-2.6.32-504.23.4.el6.x86_64
abrt-addon-kerneloops-2.0.8-26.el6.centos.x86_64
kernel-firmware-2.6.32-504.23.4.el6.noarch
kernel-headers-2.6.32-504.23.4.el6.x86_64
dracut-kernel-004-356.el6.noarch
kernel-2.6.32-504.el6.x86_64
<||

サービスの起動状態を確認。モジュールはロードされている様子。

>||
$ service vboxautostart-service   status
Usage: /etc/init.d/vboxautostart-service {start|stop}
$ service vboxballoonctrl-service status
Checking for VBox watchdog service ...not running
$ service vboxdrv        status
VirtualBox kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) are loaded.
$ service vboxweb-service status
Checking for VBox Web Service ...not running

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/precise32' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.2.0
    default: VirtualBox Version: 4.3
==> default: Mounting shared folders...
    default: /vagrant => /home/manatee
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.
>||

CentOS 6.6インストール・各種設定 (随時追加)

Linux環境でVirtualBoxVagrantを動作させるために、VMWareESXi 5.0をインストールしていたPCを潰して、CentOS 6.6をインストールした。

その後に行った各種設定メモ ※随時追加予定。

今後は、Ansible のPlaybook というもので自動化を図る予定。
以下ドットインストールのスクリプトが参考になりそう。

github.com


■一般ユーザをsudo可能にする。

visudoで/etc/sudoerに以下を追加

$ visudo
  :
manatee ALL=(root)      ALL

■各ユーザのhistoryの件数増加+日付記録

$ vim .bashrc
  :
HISTSIZE=50000
HISTTIMEFORMAT='%Y/%m/%d %H:%M:%S '

$ source .bashrc

■ntpdサービスを起動

# chkconfig ntpd on
# service ntpd start
# /etc/ntpd.confはとりあえずそのままで起動。

$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
'==============================================================================
'+li763-114.membe 145.174.168.164  3 u   24   64    1    6.128   -1.946   0.847
'+chobi.paina.jp  131.112.181.48   2 u   56   64    1   14.463   -5.081   1.458
' extendwings.com 133.243.238.243  2 u   66   64    0    0.000    0.000   0.000
'*y.ns.gin.ntt.ne 103.1.106.69     2 u   55   64    1   13.515   -2.613   0.072

■Gitインストール
$ sudo yum -y install git

$ rpm -q git
git-1.7.1-3.el6_4.1.x86_64

deviseのメール認証の追加

device のユーザ認証は導入していたが、確認メールの機能は利用していなかったので、追加しました。※メモ程度に記載したので、抜け漏れあるかもしれません。

■deviseのメール認証の追加

(1)confirmableを追加
$ vim remindertv/app/models/user.rb


devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable 
(←confirmableを追加)

(2)マイグレーションの追加
$ rails generate migration AddUserConfirmation
invoke active_record
create db/migrate/20150620131801_add_user_confirmation.rb

$ vim db/migrate/20150620131801_add_user_confirmation.rb


class AddUserConfirmation < ActiveRecord::Migration
def change
change_table(:users) do |t|
t.string :confirmation_token
t.datetime :confirmed_at
t.datetime :confirmation_sent_at
t.string :unconfirmed_email # Only if using reconfirmable
end

add_index :users, :confirmation_token, unique: true

end
end

$ rake db:migrate
$ RAILS_ENV=production rake db:migrate

参考:
マイグレーションを利用してConfirmedを追加しようとしたところ、エラーが発生した。
テーブルにカラムが追加されていなかったのが原因。
追加なのに「change_table」で記載していたから、マイグレートが行われていなかった。

undefined local variable or method `confirmed_at'


■メールの設定
$ vim config/environments/development.rb
$ vim config/environments/production.rb
以下を修正
config.action_mailer.default_url_options = { host: '<サイトのURL>`:3000' }
config.action_mailer.default_url_options = { host: '<サイトのURL>' }
以下を追加
config.action_mailer.delivery_method = :sendmail
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_options = {from: 'no-reply@example.com'}

Googleではない。。


■日本語化
以下を日本語化
app/views/devise/mailer/confirmation_instructions.html.erb
app/views/devise/mailer/reset_password_instructions.html.erb
app/views/devise/mailer/unlock_instructions.html.erb

→エラー時のメッセージなど他にもありそう。

その他、画面上のメッセージを日本語に変更
app/views/devise/shared/_links.erb
config/locales/devise.ja.yml (devise.en.ymlをコピーして修正)
config/locales/helpers.ja.yml

check_box_tagでtoggle、rake routes実行でつまずいた点

■その1
ドットインストールを参考にcheck_box_tagとtoggleの機能を追加しようとしたところ、以下のエラーが発生。

ActionView::MissingTemplate (Missing template programs/toggle, application/toggle with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :vcf, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in:
* "/var/www/html/XXXX/app/views"
* "/usr/local/lib/ruby/gems/2.1.0/gems/devise-3.2.4/app/views"

コントローラーの記載に以下が抜けていたため、発生していた様子。
render nothing: true

renderはデフォルトのテンプレート以外の動作をさせるものと理解。

ドットインストールの動画だけを参考にしていると、自分でテキスト化する際にミスがあったり、なかなか大変。頻繁に時間が取れないけど、会員になってしまおうかな。。
本設定で行っているトグルの機能ですが、なぜかSQLiteではうまくいきませんでした。boolean型がないから?
MySQLでは、tinyint(1)となっており、試したところ正常に動作しています。

参考URL
Missing template - Railsのお部屋
Ruby On Railsでタスク管理アプリを作ってみる | jekylog
ドットインストール「Ruby on Rails 4入門」メモ - Qiita
ドットインストール Rails まとめ - gotagota日記

SQLiteからMySQLへのデータ変換
参考URL
SQLiteからMySQLへデータのマイグレーション(変換)|DB|ブログ|ノノログ



■その2
rake routesを実行したところ、以下のエラーが発生。

$ rake routes
rake aborted!
Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.3.2. Prepending `bundle exec` to your command may solve this.
(以降省略)

以下を実行して解消した。
bundle update rake

参考URL
Rails - 「rake db:migrate」コマンドで「rake aborted」になったら - Qiita

Windows8.1 +無線ルーターでWi-Fi ネットワーク「制限あり」

以前利用していた無線ルーターの調子が悪くなったので、新しいバッファローの無線ルータに買い換えたところ、ネットワークに制限ありとでてしまい、通信が全くできなくなった。
ネットワークIPアドレスは割り当てられるものの、pingが通らない。

[構成]
AirStation HighPower Giga WSR-1166DHP
lenovo Z480+Windows8.1

http://support.lenovo.com/jp/ja/documents/ht080645
WINDOWS 8.1WIFI アイコンに黄色い ! マークが付く - ノートブック

上記レノボのサポートURLの方法 1~方法 4を試したが、状況かわらず接続不可。

WPA2-パーソナルをWPA2-エンタープライズに変えることができるのかも不明。

方法 5のドライバーのアップデートで接続できるようになったものの、たびたび
ネットワークで「制限あり」の状態が再発している状況。

http://ztms.blog.fc2.com/blog-entry-53.html
Lenovo G500 (Windows 8.1) で無線LAN接続が「制限あり」となり通信できないのは… | いなじゅん


上記のブログサイトで紹介されていたWMMを無効化する方法を実施したところ、現状問題がない様子。

WMM
Wireless Multimedia Extensions - Wikipedia

帯域制御が行われないらしく、有効→無効に変更して測定したところ、回線速度24Mbps→15~18Mbps程度に下がってしまった。

linuxサーバ+radiko+ dropboxでサウージ!サウダージ

j-wareの「サウージ!サウダージ」をずっと聞いていたいので、
linuxサーバでradikoの番組を録音する設定を設定してみました。

環境:CentOS6

linuxサーバでradikoを録音

参考にさせていただいたURL
http://linux.matchy.net/archives/152
http://namaraii.com/archives/19670

yumリポジトリを使用するために、以下をインストール
rpmforge-release-0.5.3-1.el7.rf.x86_64
epel-release-6-8.noarch
remi-release-6.4-1.el6.remi.noarch

radiko録音スクリプトのrec_radiko.shをダウンロード

radiko録音スクリプトを利用するために、以下のパッケージをyumからインストール
swftools-0.9.1-1.el6.rf.x86_64
zziplib-0.13.62-1.el6.x86_64
libmp3lame0-3.99.3-23.el6.x86_64
fftw3-3.3.3-44.1.x86_64
rtmpdump-2.3-1.el6.rf.x86_64
librtmp-2.3-1.el6.rf.x86_64

試しにスクリプトを実行
# ./rec_radiko.sh FMJ 3 /tmp test.mp3
RTMPDump v2.3
(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
WARNING: No application or playpath in URL!
Connecting ...
WARNING: Trying different position for server digest!
INFO: Connected...
Starting Live Stream
For duration: 180.000 sec
INFO: Metadata:
INFO: StreamTitle
1096.188 kB / 180.01 sec
Download complete
./rec_radiko.sh: line 152: ffmpeg: コマンドが見つかりません

ffmpegを入れ忘れていた。

ffmpegrpmインストール

参考させていただいたURL
http://fujimi.eshi-net.org/archives/1007

以下のメッセージが出力され、なぜかうまくいかない。
# yum install ffmpeg
Loaded plugins: downloadonly, fastestmirror, security
Loading mirror speeds from cached hostfile
* base: www.ftp.ne.jp
* extras: www.ftp.ne.jp
* updates: www.ftp.ne.jp
Setting up Install Process
No package ffmpeg available.
Error: Nothing to do

何の操作で変わったかふめいですが、途中で、以下のエラーが発生。
# yum install ffmpeg
Loaded plugins: downloadonly, fastestmirror, security
Loading mirror speeds from cached hostfile
* base: www.ftp.ne.jp
* extras: www.ftp.ne.jp
* rpmforge: ftp.kddilabs.jp
* updates: www.ftp.ne.jp
rpmforge | 1.9 kB 00:00
Not using downloaded repomd.xml because it is older than what we have:
Current : Wed Jun 25 10:46:36 2014
Downloaded: Tue Jun 24 10:46:27 2014
Setting up Install Process
No package ffmpeg available.
Error: Nothing to do

以下を実行して解消。
# yum clean all

Linuxdropbox の設定

参考させていただいたURL
http://www.maruko2.com/mw/Dropbox%E3%82%92Linux%E3%81%A7%E5%88%A9%E7%94%A8%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95
http://linux.matchy.net/archives/152


$ ~/.dropbox-dist/dropboxd
このコンピュータは Dropbox アカウントにリンクされていません...
このデバイスをリンクするには、https://www.dropbox.com/cli_link?host_id=xxxxxxxxxxxxxxxxxx にアクセスしてください。
このコンピュータは Dropbox アカウントにリンクされていません...
このデバイスをリンクするには、https://www.dropbox.com/cli_link?host_id=xxxxxxxxxxxxxxxxxx にアクセスしてください。
このコンピュータは Dropbox アカウントにリンクされていません...
このデバイスをリンクするには、https://www.dropbox.com/cli_link?host_id=xxxxxxxxxxxxxxxxxx にアクセスしてください。
:
:
:
Linuxサーバ上でブラウザを開くものだと思って慌てましたが、違いました。
他のPCで上記の「https://www.dropbo....」にアクセスしてログイン
:
:
このコンピュータは Dropbox にリンクされました。ようこそ、xxxxxxxx さん。

$ dropbox.py status
Dropbox isn't running!
$ dropbox.py start
Starting Dropbox...Done!
$ dropbox.py status
インデックスを作成中...
$ dropbox.py status
同期中(残り 14 件のファイル, 残り 6 分)

14 件のファイルをダウンロード中 (6,580KB/秒、残り 6 分)
$ dropbox.py status
同期中(残り 2 件のファイル, 残り 1 分)
「2012-09-28 22.01.46.mp4」のインデックスを作成中...
「20131012_xxxxxxxx.zip」をダウンロード中 (8,692KB/秒、残り 1 分)
$ dropbox.py status
最新の状態
% dropbox.py lansync n

テストがうまくいきました。/usr/local/bin/とかに入れるべきでしょうか。
$ /etc/rec_radiko/rec_radiko.sh FMJ 1 /tmp test

サウージサウダージの時間に/etc/crontabを設定 (1分前開始、ntpd時刻同期は設定済み)
59 16 * * 7 root /etc/rec_radiko/rec_radiko.sh FMJ 55 /home/xxxxxx/Dropbox/public/radiko SAUDE_SAUDADE

番組終了後、ファイルができていた。これでスマートフォンからいつでも聞けます。

OS再起動後も動作するようにdropbox起動スクリプトの設定も実施しました。

#2018-02-25追加
ファイル管理ができていなくてドライブ使用容量が100%となっていました。容量を確保しましたが、録音がエラーとなるので、調べてみると2016/10/12からradikoの仕様が変更されていたとのこと。以下URLを参考させていただき、修正しました。
ドライブがいっぱいになったと思われる2017-08-20まではなぜか録音できていたようなのですが、、
radikoの仕様変更によるRaspberry Piでの録音失敗対応 - Qiita