vnc4server のバックアップ(No.1)


vnc4server

Xをvnc経由でのみ起動させるスクリプト。xdm/gdmは実行しないようにしておく必要があります。

#!/bin/bash
#
# chkconfig: 345 96 04
# description: vnc4server
#
# Startup script for VNC4 Server
#


# ----- Save and Set Environment Variables --------------------------------

PROGDIR=/usr/bin
PROGUSER=root
UMASK_VALUE=002
LOCALE=ja_JP.eucJP
DISPLAYNUMBER=:0
OPTIONS=":0 -depth 16"
LOGFILE=/var/log/vnc/vnc4server.log


# ----- Define Function ---------------------------------------------------

start() {
  su - ${PROGUSER} -c "umask ${UMASK_VALUE}; env LC_ALL=${LOCALE} ${PROGDIR}/vnc4server ${OPTIONS} ${DISPLAYNUMBER} 2>&1" 2>&1 >> ${LOGFILE}
}

stop() {
  su - ${PROGUSER} -c "rm -f /tmp/.X0-lock"
  su - ${PROGUSER} -c "rm -f /tmp/.X11-unix/X0"
  su - ${PROGUSER} -c "umask ${UMASK_VALUE}; env LC_ALL=${LOCALE} ${PROGDIR}/vnc4server -kill ${DISPLAYNUMBER} 2>&1" 2>&1 >> ${LOGFILE}
}


# ----- Execute The Requested Command -------------------------------------

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart|reload)
    stop
    start
    ;;
  *)
    echo "Usage:"
    echo "  $0 (start|stop|restart)"
    echo ""
    echo "Commands:"
    echo "  start   -  Start server"
    echo "  stop    -  Stop server"
    echo "  restart -  Restart server"
    echo ""
    ;;
esac

exit 0