Created
March 21, 2012 18:24
-
-
Save turicas/2150763 to your computer and use it in GitHub Desktop.
Starts a VNC server, automatically configuring password and display options
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Options: | |
| PASSWORD="mysecret" | |
| DISPLAY=":10" | |
| VNCSERVER_OPTIONS="-geometry 1024x768 -alwaysshared" | |
| PASSWD_PATH="$HOME/.vnc/passwd" | |
| XSTARTUP_PATH="$HOME/.vnc/xstartup" | |
| VNCSERVER="tightvncserver" | |
| VNCPASSWD="tightvncpasswd" | |
| # NOTE: you can change `tightvncpasswd` by `vncpasswd` if you don't use | |
| # TightVNC but it won't work in some VNC implementations | |
| NEW_SESSION="exec gnome-session" | |
| vncserver_stop() { | |
| # Kill server for this display if is running | |
| $VNCSERVER -clean -kill $DISPLAY | |
| } | |
| vncserver_start() { | |
| echo "$PASSWORD" | $VNCPASSWD -f > $PASSWD_PATH | |
| chmod 600 $PASSWD_PATH | |
| echo "$NEW_SESSION" > $XSTARTUP_PATH | |
| $VNCSERVER $DISPLAY $VNCSERVER_OPTIONS | |
| } | |
| case "$1" in | |
| start) | |
| vncserver_start | |
| ;; | |
| stop) | |
| vncserver_stop | |
| ;; | |
| restart) | |
| vncserver_stop | |
| vncserver_start | |
| ;; | |
| *) | |
| echo "Usage: $0 <start|stop|restart>" | |
| exit 1 | |
| esac |
walbon
commented
Mar 22, 2012
Author
@walbon, thank, you!
Corrected this bug and added more configuration in variables.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment