-
-
Save sunapi386/109235a4f52d77f889a3b022047d3a2c to your computer and use it in GitHub Desktop.
Starts VNC server for the current session
This file contains 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 | |
########################################################################### | |
# /usr/local/bin/x11vnc-start | |
# Starts VNC server for the current session | |
# | |
# Gustavo Neves - 4th Jul 2016 | |
# | |
# Install x11vnc: | |
# sudo apt-get install x11vnc | |
# | |
# Install this script: | |
# sudo wget -q https://gist.githubusercontent.com/tavinus/dc98f9a34f24efa8c34717a925e4fcc2/raw/ -O /usr/local/bin/x11vnc-start && sudo chmod +x /usr/local/bin/x11vnc-start | |
# | |
# Setup: | |
# mkdir -p ~/.vnc && touch ~/.vnc/passwd | |
# x11vnc -storepasswd "YOUR_PASSWORD_HERE" ~/.vnc/passwd | |
# | |
# Run on boot: | |
# Look for Configuration >> Session and Initialization (or some like it) | |
# Add a new entry under Automatic Initializaion with the command: | |
# /usr/local/bin/x11vnc-start &/dev/null & | |
# | |
########################################################################### | |
vnc_bin="$(which x11vnc)" | |
vnc_port="5900" # Change port here | |
vnc_auth_path="$HOME/.vnc" # Change auth path here | |
vnc_auth_file="$vnc_auth_path/passwd" # Change auth file here | |
if [[ -z $vnc_bin ]]; then | |
echo "Could not find x11vnc executable, aborting.." | |
echo "Maybe you want to:" | |
echo " sudo apt-get install x11vnc" | |
exit 1 | |
elif [[ ! -f $vnc_auth_file ]]; then | |
echo "There is no passwd file." | |
echo "Please run:" | |
echo " mkdir -p $vnc_auth_path && touch $vnc_auth_file" | |
echo " x11vnc -storepasswd "'"YOUR_PASSWORD_HERE"'" $vnc_auth_file" | |
exit 2 | |
else | |
"$vnc_bin" -auth guess -forever -loop -noxdamage -repeat -rfbauth "$vnc_auth_file" -rfbport "$vnc_port" -shared &>/dev/null & | |
exit 0 | |
fi | |
exit 9 # should never get here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment