AirVideoServer FreeBSD用起動スクリプト

CentOS用の起動スクリプトやFreeBSD用の色々な起動スクリプトを参考にAirVideoServerの起動スクリプトを作成したので、需要はともかくとして公開する。
あまりFreeBSDの起動スクリプトのお作法を知らない状態な上に、動けばいい精神で作成しているので、無保証であり、本スクリプトを使用した際に何か起きても当方はいかなる責任も負わない。

使い方

スクリプトの設置

/usr/local/etc/rc.d 等に設置し、実行権限を与えてください。

# cd /usr/local/etc/rc.d
# fetch http://www.funi2.jp/files/airvideoserver
# chmod 700 airvideoserver

自動起動設定

/etc/rc.conf.local等に下記の様に記述します。

airvideoserver_enable="YES"
airvideoserver_dir="/usr/local/airvideo"
airvideoserver_conf="test.properties"
  • airvideoserver_enable: YESにすることで自動起動を有効にする
  • airvideoserver_dir: AirVideoServerが設置されているディレクトリを指定する。ここで指定したディレクトリに本体(AirVideoServerLinux.jar)と設定ファイルが設置されている事。
  • airvideoserver_conf: 設定ファイル名を指定。上記例の場合、/usr/local/airvideo/test.properties が使用される。
  • 起動スクリプトを使う

    # service airvideoserver start (起動)
    # service airvideoserver status (起動確認)
    # service airvideoserver stop (終了)

    このスクリプトについて

    • 動かなかった:残念ですね。
    • ○○をこのように変えるともっと良くなるよ:ご指摘いただければ大変助かります。

    参考サイト

    スクリプト

    http://www.funi2.jp/files/airvideoserver

    #!/bin/sh
    #
    # PROVIDE: airvideoserver
    # REQUIRE: LOGIN DAEMON NETWORKING mountcritlocal
    # KEYWORD: shutdown
    #
    # Add the following lines to /etc/rc.conf.local to enable the AirVideo Server:
    #
    # airvideoserver_enable="YES"
    # airvideoserver_dir="<path to AirBideoServer directory>"
    # airvideoserver_conf="<path to conf/properties file>"
    #
    
    . /etc/rc.subr
    
    name="airvideoserver"
    rcvar=`set_rcvar`
    
    load_rc_config ${name}
    
    java="/usr/local/bin/java"
    grep="/usr/bin/grep"
    awk="/usr/bin/awk"
    xargs="/usr/bin/xargs"
    kill="/bin/kill"
    
    pidfile="/var/run/${name}.pid"
    logfile="/var/log/${name}.log"
    
    extra_commands="status"
    start_cmd="${name}_start"
    stop_cmd="${name}_stop"
    status_cmd="${name}_status"
    
    : ${airvideoserver_enable="NO"}
    : ${airvideoserver_dir="/usr/local/airvideo"}
    : ${airvideoserver_conf="test.properties"}
    
    airvideoserver_start() {
        echo -n "Starting ${name}"
        if airvideoserver_running; then
    	echo ": already running?"
        else
    	${java} -jar ${airvideoserver_dir}/AirVideoServerLinux.jar ${airvideoserver_dir}/${airvideoserver_conf} >>$logfile 2>&1 &
    	if [ $? -eq 0 ]; then
    	    ps -ww | ${grep} ${airvideoserver_dir}/${airvideoserver_conf} | ${grep} -v grep | ${awk} '{print $1}' > $pidfile
    	    echo "."
    	else
    	    echo ": Error!"
    	fi
        fi
    }
    
    airvideoserver_stop() {
        echo -n "Stopping ${name}"
        ps -ww | ${grep} ${airvideoserver_dir}/${airvideoserver_conf} | ${grep} -v grep | ${awk} '{print $1}' | ${xargs} ${kill} -9 >/dev/null 2>&1
        if [ $? -eq 0 ]; then
            rm -f $pidfile
            echo "."
        else
            echo ": Error!"
        fi
    }
    airvideoserver_status() {
        if airvideoserver_running; then
    	echo "${name} is running."
        else
    	echo "${name} is not running."
        fi
    }
    
    airvideoserver_running() {
        local running
        running=`ps -ww | ${grep} ${airvideoserver_dir}/${airvideoserver_conf} | ${grep} -v grep | ${awk} '{print $1}'`
        if [ $running ]; then
            return 0
        else
            return 1
        fi
        return 1
    }
    
    run_rc_command $1
    

AirVideoServer FreeBSD用起動スクリプト” に1件のフィードバックがあります

  1. ピンバック: AirVideoServer on FreeBSD 9.1-STABLE | funi2.jp

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です