起動スクリプトの作成

仮想フレームバッファ用の起動スクリプトを作ってみた。
chkconfig --addで組み込むためには、以下のような2行が必要らしい。

# chkconfig: 345 86 14
# description: need for GraphicsEnvironment.getDefaultScreenDevice()

chkconfig: 345 86 14の345はランレベル、86と14は起動と停止順位。
詳しくはman chkconfig#RUNLEVEL FILES

#!/bin/sh
#
# Startup script for Xvfb
#
# chkconfig: 345 86 14
# description: need for GraphicsEnvironment.getDefaultScreenDevice()
#

case "$1" in
start)
echo "Starting Xvfb: "
Xvfb :2 -screen 0 1024x768x16 &
echo $! > /var/run/xvfb.pid
;;
stop)
test ! -f /var/run/xvfb.pid && exit 0
echo "Shutting down Xvfb: "
pid=`cat /var/run/xvfb.pid`
test ! -z $pid && kill $pid && rm -f /var/run/xvfb.pid
;;
*)
echo -n "Usage: $0 {start|stop}"
exit 1
esac

exit 0