- sudo su: Log in as root.
- cd /etc/init.d/: This is apparently the directory where startup scripts live.
- nano vncboot: Opens up a text file where the following commands were pasted. I don't really understand too much about what this is doing. The options in the VNC server are different from the ones I normally use, but I can't really tell what the difference is, so I'm going to assume for now that it's irrelevant.
### BEGIN INIT INFO # Provides: vncboot # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start VNC Server at boot time # Description: Start VNC Server at boot time. ### END INIT INFO #! /bin/sh # /etc/init.d/vncboot USER=root HOME=/root export USER HOME case "$1" in start) echo "Starting VNC Server" #Insert your favoured settings for a VNC session /usr/bin/vncserver :0 -geometry 1280x800 -depth 16 -pixelformat rgb565 ;; stop) echo "Stopping VNC Server" /usr/bin/vncserver -kill :0 ;; *) echo "Usage: /etc/init.d/vncboot {start|stop}" exit 1 ;; esac exit 0 - chmod 755 vncboot: This makes the script executable.
- update-rc.d vncboot defaults: I think this is what enables the script to run at bootup. There was another command that the website instructed me to use that didn't work (update-rc.d /etc/init.d/vncboot defaults). My guess is that the reason it doesn't work is because I was in the particular directory so that the extra location information was extraneous and caused some sort of problem.
EDIT: I later noticed that this setup logged you in as root, and that's not such a good thing. I tried changing the user=root to user=pi and HOME=/root to HOME=/home/pi, but that didn't seem to work for some reason. So I went around and found another website that had instructions for logging in as pi: http://www.maketecheasier.com/setting-vnc-raspberry-pi/. The script is very similar, but it is different.
#!/bin/sh
### BEGIN INIT INFO
# Provides: VNC
# Required-Start: $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start or stop the VNC server
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
eval cd ~pi
case "$1" in
start)
su pi -c "/usr/bin/vncserver :1 -geometry 1024x728 -depth 24"
echo "Started VNC server."
;;
stop)
su pi -c "/usr/bin/vncserver -kill :1"
echo "Stopped VNC server."
;;
*)
echo "Usage: vncserver [start|stop]" >&2
exit 3
;;
esac
:
However, this gave me some problems, too. The connection was now getting refused when I tried to the run the VNC client from my desktop. After staring blankly at the code for a while, I changed the :1 to :0. That did the trick. I don't really know why it behaves like this, but it does. I may or may not change the resolution later.
No comments:
Post a Comment