まだMacの起動スクリプトのことをなんと呼べばいいのかわからないのですが、 とりあえずなくて困ったので、 HyperEstraier用の起動スクリプトを作ってみました。

hyperestraier.plist

   1  <?xml version="1.0" encoding="UTF-8"?>
   2  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
   3  <plist version="1.0">
   4  <dict>  
   5          <key>Debug</key>
   6          <false/>
   7          <key>Label</key>
   8          <string>org.macports.hyperestraier</string>
   9          <key>OnDemand</key>
  10          <false/>
  11          <key>ProgramArguments</key>
  12          <array> 
  13                  <string>/opt/local/bin/daemondo</string>                <string>--label=hyperestraier</string>
  14                  <string>--start-cmd</string>
  15                  <string>/opt/local/etc/LaunchDaemons/org.macports.hyperestraier/hyperestraier.wrapper</string>
  16                  <string>start</string>
  17                  <string>;</string>
  18                  <string>--stop-cmd</string>
  19                  <string>/opt/local/etc/LaunchDaemons/org.macports.hyperestraier/hyperestraier.wrapper</string>
  20                  <string>stop</string>
  21                  <string>;</string>
  22                  <string>--restart-cmd</string>
  23                  <string>/opt/local/etc/LaunchDaemons/org.macports.hyperestraier/hyperestraier.wrapper</string>
  24                  <string>restart</string>
  25                  <string>;</string>
  26                  <string>--pid=none</string>
  27          </array>
  28          <key>RunAtLoad</key>
  29          <false/>
  30  </dict>
  31  </plist>

plistファイルの中で指定されているhyperestraier.wrapper は以下の通り。

   1  !/bin/sh
   2  #
   3  # MacPorts generated daemondo support script
   4  #
   5  
   6  #
   7  # Init
   8  #
   9  prefix=/opt/local
  10  
  11  #
  12  # Start
  13  #
  14  Start()
  15  {
  16    if test ! "`netstat -a -n | grep 1978`"; then
  17      rm -f /opt/local/var/run/hyperestraier/_pid
  18    fi
  19  
  20    /opt/local/bin/estmaster start -bg /opt/local/var/run/hyperestraier
  21  }
  22  
  23  #
  24  # Stop
  25  #
  26  Stop()
  27  {
  28    /opt/local/bin/estmaster stop /opt/local/var/run/hyperestraier
  29  }
  30  
  31  #
  32  # Restart
  33  #
  34  Restart()
  35  {
  36    Stop
  37    Start
  38  }
  39  
  40  #
  41  # Run
  42  #
  43  Run()
  44  {
  45  case $1 in
  46    start  ) Start   ;;
  47    stop   ) Stop    ;;
  48    restart) Restart ;;
  49    *      ) echo "$0: unknown argument: $1";;
  50  esac
  51  }
  52  
  53  #
  54  # Run a phase based on the selector
  55  #
  56  Run $1

macportsで入れたmysql5-develの起動スクリプトを元にしているので、 ディレクトリ構成などがmacports的になっています。

posted by Png genki on Fri 12 Sep 2008 at 15:11 with 1 comment

MacportsでMySQLをインストールしているという前提で。 普通に

   1  sudo gem install msyql

をすると、libmysqlclientが見つからずにインストールが失敗します。 そこで、/opt/local/lib/ruby/gems/1.8/gems/mysql-2.7に移動し、

   1  # ruby extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config
   2  # make
   3  # make install

でOK。

posted by Png genki on Fri 12 Sep 2008 at 14:23 with 2 comments

あなたは今までにインストールしたMySQLの数を覚えているだろうか。

何度となくインストールしてきたMySQLですが、 Macの場合は、いくつもインストールする方法があるので、 どれが良いか迷いました。 @shachiさんにアドバイスをいただいて パッケージ版をインストールしてみたのですが、 Macports版のmysql5-develも捨てがたく、 結局mysql5-devel+GUI Toolsという構成に落ち着きました。

Macportsからインストールした場合、/opt/local 以下にインストールされるので、以下のようにシンボリックリンクを 作成しました。

  • /var/run/mysqld -> /opt/local/var/run/mysql5
  • /etc/my.cnf -> /opt/local/etc/mysql5/my.cnf

だいたいこんな感じです。 非常に快適になりました。

See Also

追記

なぜか不思議なことに、Macを再起動すると、/var/run/mysqld に作成したシンボリックリンクが消えてしまうことがわかりました。 /private/var/run/mysqldにしてみるなど、 いろいろ試してみたのですが、 結局再起動するとなくなってしまいます。 何が原因なのかまだわからないですが、 とりあえず対処療法として、mysqlの起動スクリプトでシンボリックリンクを作成するようにしてみました。

/opt/local/etc/LaunchDaemons/org.macports.mysql5-devel/mysql5-devel.wrapper(抜粋)

   1  #
   2  # Start
   3  #
   4  Start()
   5  {
   6    ln -s -f /opt/local/var/run/mysql5 /private/var/run/mysqld
   7    /opt/local/share/mysql5/mysql/mysql.server start
   8  }

これでひとまず大丈夫になりました。 しかし再起動するとシンボリックリンクが無くなってしまうというのは不可解ですね。きっと何か理由があるんでしょうけれど。

posted by Png genki on Fri 12 Sep 2008 at 12:13 with 1 comment

Macの環境でstat -cが使えなかったので、ついでに以前作成した Rakeタスク補完関数を書き換えてみました。

   1  _rake () {
   2    if [ -f Rakefile ]; then
   3      compadd `rake -T | awk "{print \\$2}" | xargs`
   4    fi
   5  }
   6  
   7  compdef _rake rake

posted by Png genki on Fri 12 Sep 2008 at 06:58 with 1 comment
Contents
Mac用のHyperEstraier起動スクリプト
MacでRuby/MySQLのGemをインストールする手順のメモ
MySQL on Mac設定メモ
ZshのRakeタスク補完関数[改訂版]
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
瀧内元気: おお、チェックしてみます。thx! '11-12
overisland: Reeder for iPhone もこの UI を実装していますね。 '11-12
瀧内元気: その情報は見たのですが、以下のサイトによると、現在はまた必要になってるっぽいんですよね。 ... '11-12
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ