benberrypi
Posts: 6
Joined: Thu Dec 04, 2014 10:55 pm

My fail at auto-starting tightvncserver

Thu Dec 04, 2014 11:08 pm

So the first thing I'm trying to get working is tightvnc so that a secondary monitor/mouse/keyboard can leave my living room - until then I need to manually start the server.

I followed the manual on this site for automatically starting the server on boot yet it only seems to work when I manually run the first script it asks you to generate (or type it by hand). After reboot I got a message about desktop :0 already being taken, yet it won't connect, and when using "sudo netstat" it isn't there until I do I start it manually. The instructions were ambiguous about where the vnc.sh file is supposed to be placed, is there a certain directory it belongs in?

In order to create the script in init.d I've used both the echo command in the shell and merely created the file elsewhere and moved it there so that shouldn't be the problem. I've chmodded the file both 755 and 777 with no luck, enabled dependency based booting just fine. Everything seems to be in order, but the last command "Reboot your Raspberry Pi and you should find a VNC server already started" I fail at ;).

I've reinstalled raspian once and started fresh too in case I made a change I didn't realize. Are both files supposed to be chmodded 755? Do I have the .sh file in the wrong place? I'm sure I'm merely missing one tiny piece of the puzzle - thanks for any help!

benberrypi
Posts: 6
Joined: Thu Dec 04, 2014 10:55 pm

Re: My fail at auto-starting tightvncserver

Fri Dec 05, 2014 2:20 am

Thank you for approving my post so quickly... this has been driving me crazy.

I think I may have messed up somewhere in the configuration because upon restart it kept going to the login screen and when the username/pass were entered it would go black with only the mouse cursor and then return to the screen (except when the credentials were incorrect where it would merely tell you). So that makes three reformats.

I know I posted this in beginners, but if it more properly belongs in troubleshooting please move it.

Also - is it possible if you have two OSes installed to auto-boot a select one and require a key to switch?

Thanks for any replies!

-Ben

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: My fail at auto-starting tightvncserver

Fri Dec 05, 2014 7:40 am

benberrypi wrote:is it possible if you have two OSes installed to auto-boot a select one and require a key to switch?
The NOOBS Installer can do this. This is what the documentation says:

OS Boot Selector
After multiple OSes have been installed, you can select which OS to boot through this selection window that is automatically displayed. NOOBS will remember your choice and boot this OS by default unless a different option has been selected within 10 seconds.

Note that if only one OS is installed then the boot selector will not be displayed and the OS will be automatically booted.

benberrypi
Posts: 6
Joined: Thu Dec 04, 2014 10:55 pm

Re: My fail at auto-starting tightvncserver

Fri Dec 05, 2014 2:14 pm

B.Goode wrote:
benberrypi wrote:is it possible if you have two OSes installed to auto-boot a select one and require a key to switch?
The NOOBS Installer can do this. This is what the documentation says:

OS Boot Selector
After multiple OSes have been installed, you can select which OS to boot through this selection window that is automatically displayed. NOOBS will remember your choice and boot this OS by default unless a different option has been selected within 10 seconds.

Note that if only one OS is installed then the boot selector will not be displayed and the OS will be automatically booted.
Appreciate the reply but I should have edited that out. I reinstalled raspian again and threw in RaspiMC or whatever as well so I had a look at what you described.

I'm mostly irritated about not getting it right, but at least I got the ssh working so I can just ssh in to access the script.

However, I very much want to learn what the heck I did incorrectly - and it would be one less step if it loaded automatically (and be a learning experience).

benberrypi
Posts: 6
Joined: Thu Dec 04, 2014 10:55 pm

Re: My fail at auto-starting tightvncserver

Sun Dec 21, 2014 7:28 am

FYI for anyone who reads this thread with the same problems... I believe it was just the raspberrypi.org tutorial being ambiguous (such as telling you.. an assumed beginner, to create a file in a protected directory, and assuming you know to either do it in the CLI completely or to use sudo mv to move a file you created in the GUI into init.d, I'm a beginner but luckily this was an obvious solution to me).

From http://www.maketecheasier.com/setting-vnc-raspberry-pi/
(not my instructions see link above
I followed these instructions and it worked instantly, and they're shorter:


Start VNC server on boot

It is possible to get the VNC server to start at boot by creating a special initialization script. Create a file called vncserver in your home directory with the following shell code:

Code: Select all

#!/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
 
:
Now run the following commands to change the owner of the file to root, copy it to the init.d directory and install the script:

Code: Select all

sudo mv vncserver /etc/init.d/
sudo chown root:root /etc/init.d/vncserver
sudo chmod 755 /etc/init.d/vncserver
sudo update-rc.d vncserver defaults
Now reboot and check that the VNC server has been started automatically. There are a couple of things that you should note about this script. First it assumes that the you are using the default pi user and secondly, it will only work if you have previously set a password using vncpasswd or you have run the VNC server manually at least once.

Return to “Beginners”