@thorikiriのてょりっき

@thorikiriがWebとかAndroidとかの技術ネタや本を読んだブログです

capistranoでアップデート後の処理を追加する

capistranoを使ってデプロイ作業をしているのですが、アップロード後に処理を追加したいなと思いました。
やりたいことは、シンボリックリンクを別途貼りたかったのです。
こんな感じに後処理を追加することで出来ました。

namespace :deploy do
  after "deploy:finalize_update", :except => { :no_release => true } do
    run "ln -s #{shared_path}/hogehoge #{latest_release}/hogehoge"
  end
end

Capistranoでデプロイする | kenkennote
こちらのブログが非常に参考になりました。

ubuntuにVirtualBox4.3をインストールする

How To Install Virtualbox 4.3 On Ubuntu 13.04, 12.10, 12.04, Linux Mint 15, 14, 13, Pear OS 8, Pear OS 7 And Elementary OS 0.2 Via The Official Virtualbox Repository | LinuxG.net
こちらを見ました。

$ wget -q -O - http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc | sudo apt-key add -
$ sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian raring non-free contrib" >> /etc/apt/sources.list.d/virtualbox.org.list'
$ sudo apt-get update
$ sudo apt-get install virtualbox-4.3
$ wget -q -O - http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc | sudo apt-key add -
$ sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian quantal non-free contrib" >> /etc/apt/sources.list.d/virtualbox.org.list'
$ sudo apt-get update
$ sudo apt-get install virtualbox-4.3
$ wget -q -O - http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc | sudo apt-key add -
$ sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian precise non-free contrib" >> /etc/apt/sources.list.d/virtualbox.org.list'
$ sudo apt-get update
$ sudo apt-get install virtualbox-4.3

MavericksにChefをインストール

Mac OS 10.9 MavericksにChefをインストールしようとしました。
Learn Chefに書いてある通り、やります。

$ curl -L https://www.opscode.com/chef/install.sh | sudo bash
Password:  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6790  100  6790    0     0   2790      0  0:00:02  0:00:02 --:--:--  2831

No builds for platform: 10.9
Please file a bug report at http://tickets.opscode.com
Project: Chef
Component: Packages
Label: Omnibus
Version:

Please detail your operating system type, version and any other relevant details

うん、なんか、今のところ10.9向けのビルドが無いって怒られてしまいますね。
なので、gemでインストールしましょう。

$ gem install chef
Fetching: mixlib-config-1.1.2.gem (100%)
Successfully installed mixlib-config-1.1.2
Fetching: mixlib-cli-1.3.0.gem (100%)
Successfully installed mixlib-cli-1.3.0
Fetching: mixlib-log-1.6.0.gem (100%)
Successfully installed mixlib-log-1.6.0
Fetching: mixlib-authentication-1.3.0.gem (100%)
Successfully installed mixlib-authentication-1.3.0
Fetching: mixlib-shellout-1.2.0.gem (100%)
Successfully installed mixlib-shellout-1.2.0
Fetching: systemu-2.5.2.gem (100%)
Successfully installed systemu-2.5.2
Fetching: yajl-ruby-1.1.0.gem (100%)
Building native extensions.  This could take a while...
/Users/thorikiri/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/ext/builder.rb:69: warning: Insecure world writable dir /opt/local/maven in PATH, mode 040777
Successfully installed yajl-ruby-1.1.0
Fetching: ipaddress-0.8.0.gem (100%)
Successfully installed ipaddress-0.8.0
Fetching: ohai-6.18.0.gem (100%)
Successfully installed ohai-6.18.0
Fetching: rest-client-1.6.7.gem (100%)
Successfully installed rest-client-1.6.7
Fetching: net-ssh-2.7.0.gem (100%)
Successfully installed net-ssh-2.7.0
Fetching: net-ssh-gateway-1.2.0.gem (100%)
Successfully installed net-ssh-gateway-1.2.0
Fetching: net-ssh-multi-1.1.gem (100%)
Successfully installed net-ssh-multi-1.1
Fetching: highline-1.6.20.gem (100%)
Successfully installed highline-1.6.20
Fetching: chef-11.6.2.gem (100%)
Successfully installed chef-11.6.2
Installing ri documentation for chef-11.6.2
Installing ri documentation for highline-1.6.20
Installing ri documentation for ipaddress-0.8.0
Installing ri documentation for mixlib-authentication-1.3.0
Installing ri documentation for mixlib-cli-1.3.0
Installing ri documentation for mixlib-config-1.1.2
Installing ri documentation for mixlib-log-1.6.0
Installing ri documentation for mixlib-shellout-1.2.0
Installing ri documentation for net-ssh-2.7.0
Installing ri documentation for net-ssh-gateway-1.2.0
Installing ri documentation for net-ssh-multi-1.1
Installing ri documentation for ohai-6.18.0
Installing ri documentation for rest-client-1.6.7
Installing ri documentation for systemu-2.5.2
Installing ri documentation for yajl-ruby-1.1.0
15 gems installed

OKのようですね。

MacをMavericksにしたらVagrantが起動しなくなった

先日MacをMavericksにアップデートしたわけだが、今度はVagrantが起動しなくなりました。

$ vagrant up
/Applications/Vagrant/embedded/gems/gems/vagrant-1.3.1/lib/vagrant/util/which.rb:32: warning: Insecure world writable dir /opt/local/maven in PATH, mode 040777
Bringing machine 'default' up with 'virtualbox' provider...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["hostonlyif", "create"]

Stderr: 0%...
Progress state: NS_ERROR_FAILURE
VBoxManage: error: Failed to create the host-only adapter
VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory

VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component HostNetworkInterface, interface IHostNetworkInterface
VBoxManage: error: Context: "int handleCreate(HandlerArg*, int, int*)" at line 68 of file VBoxManageHostonly.cpp

こんな感じのエラーが出ました。
Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory · Issue #1671 · mitchellh/vagrant · GitHub
ググったら上の記事にあたりまして、VirtualBoxをリスタートしなさいととのことでした。

$ sudo /Library/StartupItems/VirtualBox/VirtualBox restart
Password:
Unloading VBoxUSB.kext
Unloading VBoxDrv.kext
/Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart => /Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxBalloonCtrl => /Applications/VirtualBox.app/Contents/MacOS/VBoxBalloonCtrl-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxDD2GC.gc => /Applications/VirtualBox.app/Contents/MacOS/VBoxDD2GC.gc-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxDDGC.gc => /Applications/VirtualBox.app/Contents/MacOS/VBoxDDGC.gc-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxExtPackHelperApp => /Applications/VirtualBox.app/Contents/MacOS/VBoxExtPackHelperApp-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxHeadless => /Applications/VirtualBox.app/Contents/MacOS/VBoxHeadless-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxManage => /Applications/VirtualBox.app/Contents/MacOS/VBoxManage-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxNetAdpCtl => /Applications/VirtualBox.app/Contents/MacOS/VBoxNetAdpCtl-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxNetDHCP => /Applications/VirtualBox.app/Contents/MacOS/VBoxNetDHCP-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxSVC => /Applications/VirtualBox.app/Contents/MacOS/VBoxSVC-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxXPCOMIPCD => /Applications/VirtualBox.app/Contents/MacOS/VBoxXPCOMIPCD-amd64
/Applications/VirtualBox.app/Contents/MacOS/VMMGC.gc => /Applications/VirtualBox.app/Contents/MacOS/VMMGC.gc-amd64
/Applications/VirtualBox.app/Contents/MacOS/VirtualBox => /Applications/VirtualBox.app/Contents/MacOS/VirtualBox-amd64
/Applications/VirtualBox.app/Contents/MacOS/VirtualBoxVM => /Applications/VirtualBox.app/Contents/MacOS/VirtualBoxVM-amd64
/Applications/VirtualBox.app/Contents/MacOS/vboxwebsrv => /Applications/VirtualBox.app/Contents/MacOS/vboxwebsrv-amd64
Loading VBoxDrv.kext
Loading VBoxUSB.kext
Loading VBoxNetFlt.kext
Loading VBoxNetAdp.kext

これで、vagrant upをしたらうまく起動してくれました。

macportをアップデートしようとしたらエラーになった。

先日、Mac OS X Mavericksにアップデートしました。
そして、今日Ruby2.0入ってたっけ?とrvmコマンドで確認したらrc1でした。あれれ。最新版を入れようとしました。
とりあえず、rvm get stableをして、rvm install 2.0.0としたところでエラーになった。
macportが古そうだったので、とりあえずアップデートしようとしたところ、こちらでもエラーになったとさ。

$ sudo port -v selfupdate
(略)
Command failed: cd /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/base && CC=/usr/bin/cc OBJC=/usr/bin/cc ./configure --prefix=/opt/local --with-tclpackage=/Library/Tcl --with-install-user=root --with-install-group=admin --with-directory-mode=0755 --enable-readline && make SELFUPDATING=1 && make install SELFUPDATING=1
Exit code: 1
Error: Error installing new MacPorts base: command execution failed
To report a bug, follow the instructions in the guide:
    http://guide.macports.org/#project.tickets
Error: /opt/local/bin/port: port selfupdate failed: Error installing new MacPorts base: command execution failed

osx - Can't update Macports (with Mac OS X Mavericks) - Stack Overflow
ググった結果、sudo xcode-select --installをしなければいけないらしい。
このコマンドを打つと、コマンドラインツールのインストールをするか聞かれるので、インストールする。
そして、再度実行してみよう。

Congratulations, you have successfully upgraded the MacPorts system.


The ports tree has been updated. To upgrade your installed ports, you should run
  port upgrade outdated

どうやら成功したようだ。
確認してみる。

$ port
MacPorts 2.2.1
Entering interactive mode... ("help" for help, "quit" to quit)
[Users/thorikiri] > exit
Goodbye

大丈夫っぽいですね。