Created
November 18, 2019 22:26
-
-
Save MartinHarding/9cb5b8eb0200c9906e0a42faa73152fc to your computer and use it in GitHub Desktop.
Raspbian -> macOS VNC Setup
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 | |
# Source: https://stackoverflow.com/a/32361133 | |
sudo apt-get update -y | |
sudo apt-get install -y x11vnc | |
x11vnc -storepasswd | |
X11VNC_PATH=~/.config/autostart/x11vnc.desktop | |
AFPD_PATH=/etc/avahi/services/afpd.service | |
RFB_PATH=/etc/avahi/services/rfb.service | |
if [[ -f $X11VNC_PATH ]]; then | |
echo "$X11VNC_PATH already exists" | |
else | |
mkdir -p `dirname $X11VNC_PATH` | |
cat <<EOF >>$X11VNC_PATH | |
[Desktop Entry] | |
Encoding=UTF-8 | |
Type=Application | |
Name=X11VNC | |
Comment= | |
Exec=x11vnc -forever -usepw -display :0 -ultrafilexfer | |
StartupNotify=false | |
Terminal=false | |
Hidden=false | |
EOF | |
sudo chmod a+r ~/.config/autostart/x11vnc.desktop | |
fi | |
sudo apt-get install -y netatalk | |
sudo apt-get install -y avahi-daemon | |
update-rc.d avahi-daemon defaults | |
if [[ -f $AFPD_PATH ]]; then | |
echo "afpd.service already exists" | |
else | |
mkdir -p `dirname $AFPD_PATH` | |
cat <<EOF >>$AFPD_PATH | |
<?xml version="1.0" standalone='no'?><!--*-nxml-*--> | |
<!DOCTYPE service-group SYSTEM "avahi-service.dtd"> | |
<service-group> | |
<name replace-wildcards="yes">%h</name> | |
<service> | |
<type>_afpovertcp._tcp</type> | |
<port>548</port> | |
</service> | |
</service-group> | |
EOF | |
fi | |
if [[ -f $RFB_PATH ]]; then | |
echo "$RFB_PATH already exists" | |
else | |
mkdir -p `dirname $RFB_PATH` | |
cat <<EOF >>$RFB_PATH | |
<?xml version="1.0" standalone='no'?> | |
<!DOCTYPE service-group SYSTEM "avahi-service.dtd"> | |
<service-group> | |
<name replace-wildcards="yes">%h</name> | |
<service> | |
<type>_rfb._tcp</type> | |
<port>5900</port> | |
</service> | |
</service-group> | |
EOF | |
fi | |
echo "Setup complete, restarting daemon" | |
/etc/init.d/avahi-daemon restart | |
echo "Connect to this pi at `sudo hostname --ip-address`" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment