まだ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

Comments:

Png 瀧内元気 over 15 years ago.

Start()関数の中で、hyperestraierが立ち上がってない場合には、_pidファイルを消去するようにしてみました。

or Preview
Social Bookmarks
  • Delicious
  • B_entry887
  • Clip_16_12_w
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ