Hejdaの見る夢

一人前のエンジニアを目指して頑張ったこととかをつらつら書くブログ

dockerのimageのキーボード設定で泣いている話

出来なかったという、ちょっとした小話です。

最近dockerを覚え(≠習得)まして

自前のスクリプトのローカル環境をvagrantのboxから載せ替えたり

werckerのymlをしっかり書いてみてテストが通ってニヤニヤしています。

で、ここ2日ほどハマっているのが「OSのキーボード設定」なのです。

自身でスクリプトやアプリを作る時の基本的な自分ルールとして

  • インフラ作成(所謂LAMP環境)時は公式のrepoを元とし、必ずインフラ作成はコード管理を行う
    • 例えば、vagrantやdockerならpublicやofficialなものを使用
    • コード管理はchefかansibleを使用してます(需要によって替えてる両刀派)

というルールを課しているがゆえに以下の問題にぶち当たって進めないでいる

理由としては

  • officialのイメージがキーボード設定がなされてないこと
    • キーボード設定をするには dpkg-reconfigure keyboard-configuration とかやらないといけないが、ウィザードが立ち上がり、apt-getだと入力待ちになり止まってしまう
    • 参考

みたいな感じです。

解決作はいくつかあって、

  • 他の設定してあるimageを使う
  • キーボード設定だけは目をつむって設定する

は嫌なので、

  • そもそもcmatrixをapt-getでインストールせず、Dockerfile内でmakeする

をするかなぁとか思案中です(´・ω・`)

githubで検索すると結構レポジトリが見つかるので、それに頼ってもいいかもとは思ってますが

やはり自分で構築して公開したいものです(´・ω・`)

冒頭でも書きましたが出来なかったという小話です。

何かの話のネタになれば幸いです。

後日記録

調べていたらキーボード設定をshellで出来るとの記事を発見

Raspberry Pi Raspbian Wheezy(2015-05-05)で最速Wi-Fiセットアップ

これは試してみるのもありかも…

「コンソール上の処理終了通知をslackに投稿する」を書いた裏話

久しぶりにQiitaの記事を書いたので後記録でも。 qiita.com

記事を書き始めたきっかけ

vagrantとansibleでテスト環境を作って検証していた時に、

終わったタイミングを成功、失敗に関わらずとにかく通知して欲しかったため。

itermのtabと画面割を駆使して並列でvagrantを使っていたけど、

ぱっと見どれが終わったのか分かりにくかったのです。

記事に書いた以外の使い方

記事内では ; で繋げて出力結果に関せずにslackに通知をさせているけど、

出力内容を出したい場合は元のスクリプトにパイプラインでshellに渡してあげれば良いです。

alias nm="sh ~/cmd-shell/slack/notify-me.sh"
  • 実行
$ command | nm

しかし、slackに非常に長い通知が来ることが予想されるので

出力結果をまとめるスクリプトを入れた方がいいかも。

アイコンについて

最初はauのCMの一寸法師を使っていたのですが、

何度も通知が来るようになると途端にうざく美人に通知して欲しくなったので、

最近Azureをさわりはじめていることもあってクラウディアさんをお借りました。

通知系なので秘書みたいなものだしいいよね。

そして、秘書は美人につきますね(ㆁᴗㆁ✿)

Warning: Remote connection disconnect. Retrying...の話

最近、macvagrantがおかしい様子…

ローカル開発でvagrantを使っているのですが、最近になって様子がおかしい…

最初のupでは普通に立ち上がるのだけど、halt後のupやsnapshotをロールバックした後のupもコケる様子。

$ vagrant snapshot go first_snap
Powering off machine 3264830a-160b-4bb2-8d06-d5a1fb1f4721
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Restoring snapshot 6ba7eaa2-d91e-4a2f-a1c5-6bf2e0cbda96
Starting restored VM
==> svr03: Checking if box 'bento/centos-6.7' is up to date...
==> svr03: Resuming suspended VM...
==> svr03: Booting VM...
==> svr03: Waiting for machine to boot. This may take a few minutes...
    svr03: SSH address: 127.0.0.1:2201
    svr03: SSH username: vagrant
    svr03: SSH auth method: private key
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
    svr03: Warning: Remote connection disconnect. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase

過去にも同様のとこで悩んでいる方々もちらほら…

Vagrant で default: Warning: Remote connection disconnect. Retrying…

で、解決策としては1回destroyしてまっさらにすればup出来るのだけど、

それだとansibleのrole作成等々でとても不便…

今はboxを変えてみたりして試行錯誤中です(´・ω・`)

brew updateでエラーが出た話

普段はMacを使っているのですが、ローカルのphpをupdateしたくて

軽い気持ちでbrew updateしたら怒られた…

$ brew update
error: The following untracked working tree files would be overwritten by merge:
    Library/Formula/agedu.rb
    Library/Formula/appledoc.rb
    Library/Formula/blackbox.rb
    Library/Formula/connect.rb
    Library/Formula/dromeaudio.rb
    Library/Formula/geany.rb
    Library/Formula/gerbv.rb
    Library/Formula/gkrellm.rb
    Library/Formula/glade.rb
    Library/Formula/gnumeric.rb
    Library/Formula/gtksourceviewmm.rb
    Library/Formula/gtksourceviewmm3.rb
    Library/Formula/ldid.rb
    Library/Formula/mlton.rb
    Library/Formula/mydumper.rb
    Library/Formula/owamp.rb
    Library/Formula/serf.rb
    Library/Formula/sslscan.rb
    Library/Formula/sylpheed.rb
    Library/Formula/tcpurify.rb
    Library/Formula/zenity.rb
Please move or remove them before you can merge.
Aborting
Error: Failure while executing: git pull --ff --no-rebase --quiet origin refs/heads/master:refs/remotes/origin/master

結構あるな〜(´・ω・`)なんて眺めていても仕方ないので、さくさくっと更新します。

参考したのは以下のサイト

ヾ(o゚ω゚o)ノ゙brew updateでエラーでたった[Homebrew]

※ 尚、OSはMacOSX 10.11.4です

対応コマンド(下準備)

実際にはこんな感じ

$ cd $(brew --prefix)
$ git fetch origin
$ sudo git reset --hard origin/master

参考資料には

$ git reset --hard origin/master

ってあったけど、

$ git reset --hard origin/master
warning: unable to unlink CONTRIBUTING.md: Permission denied
warning: unable to unlink SUPPORTERS.md: Permission denied

って怒られる。今思えば、権限変更すれば良かった思っている。

また、pathに関しても参考資料と一致していたので

OSが1つくらい違っても無問題。

$ cd $(brew --prefix)
$ pwd
/usr/local

対応コマンド(upadte)

あとは、updateするのみ!

$ brew update
Error: /usr/local must be writable!

…また、怒られました。

どうやら、上記でsudoでupdateしたところの権限が問題のようです。

権限を直してリトライしたところ、通るようになりました

$ sudo chown -R $(whoami):admin /usr/local
Password:
$ brew update
$ brew upgrade 

追記 1

作法としては

$ brew doctor
$ brew update
$ brew upgrade

の様です。

素人がEl Capitanにアップデートしてみたやつ。

追記 2

当初の目的に関してはmacにhomebrewでPHP5.6環境をインストールしてみるを参考にやりました。

$ xcode-select --install
  • brewを最新にする
$ brew update
$ brew upgrade
$ brew tap homebrew/php
$ brew tap homebrew/dupes
$ brew install php56 --with-apxs2=/usr/sbin/apxs
$ brew services start homebrew/php/php56

上記で対応できます。

追記 3

実はFormulaeでこけていた

php5.6をインストールしようとしたら、フォーミュラでコケた…

$ brew install homebrew/php/php56 --with-apxs2=/usr/sbin/apxs
==> Installing php56 from homebrew/php
Error: Formulae found in multiple taps: 
 * homebrew/php/php53
 * josegonzalez/php/php53

フォーミュラの名前重複が気に食わないらしいので、それを解除する。

$ brew untap josegonzalez/php

追記 4

インストール後に再起動が必要になるが、 それでもphpのバージョンがupdateされない場合は以下を設定

  • ~/.bashrc
# php56
export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"

# php70
export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH"