MacGuyver mode for Raspberry Pi
#!/bin/bash | |
if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi | |
apt-get update | |
apt-get install realvnc-vnc-server dnsmasq -y | |
cd /usr/local/share/ | |
wget https://github.com/novnc/noVNC/archive/v1.0.0.zip | |
unzip v1.0.0.zip | |
rm v1.0.0.zip | |
mv noVNC-1.0.0 noVNC | |
cd noVNC | |
cp vnc.html index.html | |
cd utils | |
wget https://github.com/novnc/websockify/archive/v0.8.0.zip | |
unzip v0.8.0.zip | |
rm v0.8.0.zip | |
mv websockify-0.8.0 websockify | |
{ | |
echo '# MacGuyver settings' | |
echo 'interface eth0' | |
echo 'static ip_address=10.0.0.1/24' | |
echo 'netmask 255.255.255.0' | |
} >> /etc/dhcpcd.conf | |
systemctl restart dhcpcd.service | |
mv /etc/dnsmasq.conf /etc/dnsmasq.default | |
{ | |
echo 'interface=eth0' | |
echo 'dhcp-range=10.0.0.2,10.0.0.10,255.255.255.0,12h' | |
echo 'dhcp-option=3,10.0.0.1' | |
echo 'dhcp-option=6,10.0.0.1' | |
} > /etc/dnsmasq.conf | |
systemctl restart dnsmasq.service | |
{ | |
echo '[Unit]' | |
echo 'Description=MacGuyver service (vnc)' | |
echo 'After=syslog.target network.target' | |
echo '' | |
echo '[Service]' | |
echo 'Type=forking' | |
echo 'User=pi' | |
echo 'PAMName=login' | |
echo 'PIDFile=/home/pi/.vnc/%H:%i.pid' | |
echo 'ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1' | |
echo 'ExecStart=/usr/bin/vncserver -Encryption=AlwaysOff -Authentication=None -localhost=1 -depth 24 -geometry 1280x800 :%i' | |
echo '' | |
echo '[Install]' | |
echo 'WantedBy=multi-user.target' | |
} > /etc/systemd/system/vncMacGuyver@.service | |
{ | |
echo '[Unit]' | |
echo 'Description=MacGuyver noVNC service (websockify)' | |
echo 'After=syslog.target network.target' | |
echo '' | |
echo '[Service]' | |
echo 'ExecStartPre=-/sbin/iptables -A INPUT -i wlan0 -p tcp --dport 80 -j DROP' | |
echo 'ExecStart=/usr/local/share/noVNC/utils/launch.sh --vnc localhost:590%i --listen 80' | |
echo '' | |
echo '[Install]' | |
echo 'WantedBy=multi-user.target' | |
} > /etc/systemd/system/novncMacGuyver@.service | |
systemctl daemon-reload | |
systemctl enable vncMacGuyver@1.service | |
systemctl enable novncMacGuyver@1.service | |
systemctl start vncMacGuyver@1.service | |
systemctl start novncMacGuyver@1.service | |
echo '' | |
echo 'MacGuyver mode installed and enabled' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
To Install
Start > Preferences > Raspberry Pi Configuration > Boot - To CLI
To use
10.0.0.1
into the address bar. If nothing happens, just reboot the host laptop and try again.To disable
# MacGuyver settings
Ctrl - O
followed byEnter
to save and thenCtrl - X
to quit back to the Terminal.To re-enable
# MacGuyver settings
Ctrl - O
followed byEnter
to save and thenCtrl - X
to quit back to the Terminal.