ubuntu设置tightvncserver自动启动

vi /etc/init.d/vnc
#!/bin/bash
PATH="$PATH:/usr/bin/"
export USER="root"
DISPLAY="1"
DEPTH="24"
GEOMETRY="1024x768"
OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY} -localhost"
. /lib/lsb/init-functions


case "$1" in
        start)
                log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
                su ${USER} -c "/usr/bin/tightvncserver ${OPTIONS}"
        ;;

        stop)
                log_action_begin_msg "Stopping vncserver for user '${USER}' on localhost:${DISPLAY}"
                su ${USER} -c "/usr/bin/tightvncserver -kill :${DISPLAY}"
        ;;

        restart)
                $0 stop
                $0 start
        ;;

        *)
                echo "Usage: /etc/init.d/vnc (start|stop|restart)"
                exit 1
        ;;
esac

exit 0
:wq!
chmod +x /etc/init.d/vnc
update-rc.d vnc defaults
 
上一篇:

Comments