roberthazelby
Posts: 6
Joined: Wed Jul 18, 2012 12:34 pm

Can't Get VNCServer to Autostart

Fri Jul 20, 2012 8:03 am

Morning all,

Issue 1126 of MIcro Mart featured an excellent Raspberry Pi Starters Guide, written by David Hayward.

The guide explained how to set up your CF card, how to get the GUI to autostart, and also how to get VNCServer to start a session once the GUI had loaded.

Last night I installed Raspbian, and hoped to get VNCServer up and running upon boot again.

The simple way David Hayward got VNCServer up and running wasn't the most elegant method, and in fact, stopped the GUI from loading on the Pi (the GUI was still available if you remotely logged in ), so I decided to use this guide and try to get it running that way:

http://elinux.org/RPi_VNC_Server

I've gone through everything up to the line where it reads "Reboot your Raspberry PI and you should find a vncserver already started." However, when I reboot I'm unable to log on via my Mac.

If I open up a terminal window on the Pi and simply type vncserver (without the :1 and the geometry settings), the Mac's able to connect without an issue. The window I type this in on the Pi also tells me it's session 1, so I can only assume the script to automatically kick the session off isn't working.

I've tried the script with and without the session number and geometry settings, but neither method seems to work.

Are the instructions at elinux.org not applicable to Raspbian, or, as I suspect, could I be doing something wrong?

Any help would be appreciated, as at present the only screen in the house with an HDMI port is the main TV in the house, and I don't think the fiancee would be too impressed with me using that for hours when she wants to watch some rubbish on there.

Thanks for reading!

pjc123
Posts: 911
Joined: Thu Mar 29, 2012 3:37 pm

Re: Can't Get VNCServer to Autostart

Fri Jul 20, 2012 7:24 pm

I believe these are the instructions I tried with Wheezy beta and they didn't work for me either. As a workaround I am logging into the pi using putty and starting the vncserver manually.
My Raspberry Pi Project Page:
http://www.flaminghellmet.com/launch/

User avatar
Jim JKla
Posts: 2218
Joined: Sun Jan 29, 2012 11:15 pm
Location: Newcastle upon Tyne UK

Re: Can't Get VNCServer to Autostart

Fri Jul 20, 2012 7:45 pm

Noob is not derogatory the noob is just the lower end of the noob--geek spectrum being a noob is just your first step towards being an uber-geek ;)

If you find a solution please post it in the wiki the forum dies too quick

roberthazelby
Posts: 6
Joined: Wed Jul 18, 2012 12:34 pm

Re: Can't Get VNCServer to Autostart

Sat Jul 21, 2012 1:04 pm

Afternoon!

Thank you so much to the both of you for your help.

Thanks to you both I'm now back up and tinkering with my Pi via VNC.

You've made me very happy.

Have a great weekend!

EJ22
Posts: 3
Joined: Tue May 08, 2012 5:45 pm

Re: Can't Get VNCServer to Autostart

Sun Jul 22, 2012 12:39 am

Hey!

I came across this while searching on how to get VNCServer to autostart as well and I've figured it out by following a mixture from the elinux wiki and penguintutor.com as neither were correct for Raspbian.

To get it to autorun, create a file in /etc/init.d call it whatever you want, for this purpose i'll call mine tightvncserver

Code: Select all

sudo nano /etc/init.d/tightvncserver
When the editor comes up, enter the following code

Code: Select all

### BEGIN INIT INFO
# Provides:          tightvncserver
# 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/tightvncserver
# Set the VNCUSER variable to the name of the user to start tightvncserver under
VNCUSER='pi'
case "$1" in
  start)
    su $VNCUSER -c '/usr/bin/tightvncserver :1'
    echo "Starting TightVNC server for $VNCUSER "
    ;;
  stop)
    pkill Xtightvnc
    echo "Tightvncserver stopped"
    ;;
  *)
    echo "Usage: /etc/init.d/tightvncserver {start|stop}"
    exit 1
    ;;
esac
exit 0
Once thats saved, edit the permissions to make it executable

Code: Select all

sudo chmod 755 /etc/init.d/tightvncserver
Then add it to the startup scripts

Code: Select all

update-rc.d tightvncserver defaults
Reboot your pi and the VNC server should load on boot.

As I said above, a lot of it is copy and pasting from both sites to make it work fully under raspbian. This isn't my own work, just a fix to get it working. Hope this helps people :)

pjc123
Posts: 911
Joined: Thu Mar 29, 2012 3:37 pm

Re: Can't Get VNCServer to Autostart

Sun Jul 22, 2012 11:39 am

EJ22 wrote:Hey!

I came across this while searching on how to get VNCServer to autostart as well and I've figured it out by following a mixture from the elinux wiki and penguintutor.com as neither were correct for Raspbian.
I come from the "Fedora" Linux world which uses a slightly different format for the startup scripts, and I haven't had the time to figure out what was wrong with all these examples. So, thanks for getting it working. I am going to give it a try on Wheezy Beta.
My Raspberry Pi Project Page:
http://www.flaminghellmet.com/launch/

pjc123
Posts: 911
Joined: Thu Mar 29, 2012 3:37 pm

Re: Can't Get VNCServer to Autostart

Mon Jul 23, 2012 9:08 pm

EJ22 wrote:Hey!

I came across this while searching on how to get VNCServer to autostart as well and I've figured it out by following a mixture from the elinux wiki and penguintutor.com as neither were correct for Raspbian.
It did not work for me.

1. First, when I ran "update-rc.d tightvncserver defaults" there were quite a few warnings, although the “tightvncserver” and “Xtightvnc” services are both running when viewed with a “ps -aux” command:

update-rc.d: using dependency based boot sequencing
update-rc.d: warning: tightvncserver start runlevel arguments (2 3 4 5) do not match LSB Default-Start values (2 3 4 5)
update-rc.d: warning: tightvncserver stop runlevel arguments (0 1 6) do not match LSB Default-Stop values (0 1 6)
insserv: Script tightvncserver is broken: incomplete LSB comment.
insserv: missing valid name for `Provides:' please add.

2. Secondly, when I try to vnc into the pi from my Windows computer I get the following error:
"No connection could be made because the target machine actively refused it".

I double checked that it still works when manually starting the vncserver with "/usr/bin/vncserver" and it still works properly, so I reverted back to the old manual method.
My Raspberry Pi Project Page:
http://www.flaminghellmet.com/launch/

pjc123
Posts: 911
Joined: Thu Mar 29, 2012 3:37 pm

Re: Can't Get VNCServer to Autostart

Wed Jul 25, 2012 6:08 pm

alexeames posted a working version here. I am now up and running:

by alexeames » 25 Jul 2012 02:20

Stewart Watkiss shows you how to do what the OP wants right here. I've tried it on Wheezy beta and Raspbian and it works an absolute treat...
http://www.penguintutor.com/linux/tightvnc

Video to prove it of me playing Chuckie Egg on spectrum emulator through tightvnc
http://raspi.tv/2012/install-and-use-ti ... oid-or-ios
My Raspberry Pi Project Page:
http://www.flaminghellmet.com/launch/

freezerburn
Posts: 2
Joined: Sat Jul 28, 2012 7:10 pm

Re: Can't Get VNCServer to Autostart

Sat Jul 28, 2012 8:33 pm

i removed the bash info because that was giving me errors for impropeer `Provides:' .. but now if i do

sudo update-rc.d tightvncserver defaults

i get this:

update-rc.d: using dependency based boot sequencing
insserv: warning: script 'K01tightvncserver' missing LSB tags and overrides
insserv: warning: script 'tightvncserver' missing LSB tags and overrides

when i run: sudo /etc/init.d/tightvncserver start

i get:
/etc/init.d/tightvncserver: 6: /etc/init.d/tightvncserver: Syntax error: word unexpected (expecting ")")

i don't know what the syntax error is as i am unfamilliar with this. it was co;py and pasted...

Splitlocked
Posts: 1
Joined: Wed Aug 01, 2012 3:15 pm

Re: Can't Get VNCServer to Autostart

Wed Aug 01, 2012 3:49 pm

I have updated the "vncboot" script on the http://elinux.org/RPi_VNC_Server page to enable copy/pasting it.

The cause of the "insserv: missing valid name for `Provides:' please add." error was the multiple spaces between "# Provides:" and "vncboot". I replaced them with single spaces and now it works flawlessly.

prlosana
Posts: 1
Joined: Thu Oct 25, 2012 2:38 pm

Re: Can't Get VNCServer to Autostart

Thu Oct 25, 2012 2:53 pm

Splitlocked wrote:I have updated the "vncboot" script on the http://elinux.org/RPi_VNC_Server page to enable copy/pasting it.

The cause of the "insserv: missing valid name for `Provides:' please add." error was the multiple spaces between "# Provides:" and "vncboot". I replaced them with single spaces and now it works flawlessly.
Many thanks for the hint! Removing blank spaces make the command:

Code: Select all

update-rc.d tightvncserver defaults
run without errors, however when I restarted my RPi it showed and error when it try to start automatically the VNC server (something about a symbol ")" missing). To fix this remove all unnecessary spaces in ALL THE CODE. Here is my final code working! :D

Code: Select all

### BEGIN INIT INFO
# Provides:  vncserver
# 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/tightvncserver

# Set the VNCUSER variable to the name of the user to start vncserver under
VNCUSER='pi'

case "$1" in
start)
echo "Starting VNC server for $VNCUSER "
su $VNCUSER -c '/usr/bin/vncserver :1 -geometry 1920x1080 -depth 24'
;;

stop)
echo "Stopping VNC server"
/usr/bin/vncserver -kill :1
;;

*)
echo "Usage: /etc/init.d/tightvncserver {start|stop}"
exit 1
;;

esac

exit 0

User avatar
Polydnj
Posts: 25
Joined: Wed Oct 10, 2012 1:59 am
Contact: Website

Re: Can't Get VNCServer to Autostart

Thu Jan 10, 2013 3:58 pm

I tried your code, still on adding it to defaults I got LSB errors! What worked for myself was getting the files with

Code: Select all

wget http://www.penguintutor.com/otherfiles/tightvncserver-init.txt

sudo mv tightvncserver-init.txt /etc/init.d/tightvncserver
After, I edited the file where necessary, wit terminals nano or a GUI
1. Change to username between the quotes if you have a different username.

Code: Select all

 export USER='pi'
2. Add visual settings by adding the text after :1.

Code: Select all

    su $USER -c '/usr/bin/tightvncserver :1 -geometry 1920x1080 -depth 24 ' 
The rest is the same, just make it executable and add the script to defaults.
Tested on Soft-float Debian “wheezy”

daffy
Posts: 2
Joined: Tue Feb 12, 2013 9:26 am

Re: Can't Get VNCServer to Autostart

Tue Feb 12, 2013 11:01 am

hey guys
i got a problem
i want to autostart the vncserver so i follow the instructions and i have the script,
i can read it by sudo nano /ect/init.d/tightvncserver
but i cant move it or do anything because it says "no such file or directory" "or cannot access no story"
please help me :(

RobinMosedale
Posts: 23
Joined: Tue Jan 29, 2013 10:55 am

Re: Can't Get VNCServer to Autostart

Fri Feb 15, 2013 4:14 pm

pjc123 wrote:alexeames posted a working version here. I am now up and running:

by alexeames » 25 Jul 2012 02:20

Stewart Watkiss shows you how to do what the OP wants right here. I've tried it on Wheezy beta and Raspbian and it works an absolute treat...
http://www.penguintutor.com/linux/tightvnc

Video to prove it of me playing Chuckie Egg on spectrum emulator through tightvnc
http://raspi.tv/2012/install-and-use-ti ... oid-or-ios

Alex, Steve, Many thanks for this. Of all the advice in posts that has been tried, this is the only one that has worked.

Excellent stuff Steve and Alex.

Robin

crystal13
Posts: 67
Joined: Tue Jan 22, 2013 2:13 pm

Re: Can't Get VNCServer to Autostart

Mon Mar 11, 2013 9:25 pm

Hello,

I have followed your suggestion but I don't know if it works correctly. In short, after the download of tightvncserver, I created this file:

Code: Select all

sudo nano /etc/init.d/tightvncserver
then I pasted the script that I took here:
http://www.penguintutor.com/otherfiles/ ... r-init.txt

where I have removed ALL the spaces.

Code: Select all

#!/bin/sh
### BEGIN INIT INFO
# Provides:          tightvncserver
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/stop tightvncserver
### END INIT INFO

# More details see: 
# http://www.penguintutor.com/linux/tightvnc

### Customize this entry
# Set the USER variable to the name of the user to start tightvncserver under
export USER='pi'
### End customization required

eval cd ~$USER

case "$1" in
start)
su $USER -c '/usr/bin/tightvncserver :1 -geometry 1440x900 -depth 24'
echo "Starting TightVNC server for $USER "
;;
stop)
pkill Xtightvnc
echo "Tightvncserver stopped"
;;
*)
echo "Usage: /etc/init.d/tightvncserver {start|stop}"
exit 1
;;
esac
exit 0
then I have executed:

Code: Select all

sudo chmod 755 /etc/init.d/tightvncserver
Finally, I have done:

Code: Select all

update-rc.d tightvncserver defaults
but I have these warning:
update-rc.d: using dependency based boot sequencing
insserv: warning: script 'K01tightvncserver' missing LSB tags and overrides
insserv: warning: script 'tightvncserver' missing LSB tags and overrides


Is it normal, or I should resolve this, too?

Thank you very much!!

crystal13
Posts: 67
Joined: Tue Jan 22, 2013 2:13 pm

Re: Can't Get VNCServer to Autostart

Tue Mar 12, 2013 9:32 am

Hello,

I found this document
http://help.directadmin.com/item.php?id=379

where is explained that it's just a warning. Today I will try to remove the:
#!/bin/sh
because it's the only difference with the example of the script on the link.

bye!

leopheard
Posts: 49
Joined: Thu Jun 27, 2013 5:34 pm

Re: Can't Get VNCServer to Autostart

Thu Jan 23, 2014 3:40 am

crystal13 wrote:I found this document
http://help.directadmin.com/item.php?id=379
where is explained that it's just a warning. Today I will try to remove the:
#!/bin/sh
because it's the only difference with the example of the script on the link.
Thanks for that, although it explains why a bit, their solution is to remove the program!

Not exactly running with the idea of programming/tinkering! More a case of if a light on your dashboard comes on, put some sticky tape over it so you can't see it!

jarymokin
Posts: 2
Joined: Sat Dec 26, 2015 9:48 am

Re: Can't Get VNCServer to Autostart

Sat Dec 26, 2015 10:30 am

The directions did not exactly work for me. I got this message when I tried to run "update-rc.d vncboot defaults"

unable to read /etc/init.d//etc/init.d

After changing the script to the following, my rc update was sucessful.

root@raspberrypi:/etc/init.d# update-rc.d vncboot defaults
update-rc.d: using dependency based boot sequencing

I wanted to keep it as close to the original directions as possible so I used a mixture of the script from the first guy on this page and the original from here.

https://www.raspberrypi.org/documentati ... ccess/vnc/


I liked using a variable for the username, even though not necessary. I left that from the guy on this page, but I did export it. I used the original /usr/bin/vncserver instead of /usr/bin/tightvncserver from the script on this page.

This worked for me:

1. I set it all up from this https://www.raspberrypi.org/documentati ... ccess/vnc/
2. I could not use port 0 because that was taken, so I also changed the port to :1.
3. Changed the /etc/init.d/vncboot script to this:

Code: Select all


#! /bin/sh
## /etc/init.d/vncboot

### BEGIN INIT INFO
# Script: vncboot
# Provides:          tightvncserver
# 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

##  Original Script /etc/init.d/tightvncserver
# Set the VNCUSER variable to the name of the user to start tightvncserver under
VNCUSER='pi'
export VNCUSER

case "$1" in
  start)
    su $VNCUSER -c '/usr/bin/vncserver :1'
    echo "Starting VNC server for $VNCUSER "
    ;;
  stop)
    /usr/bin/vncserver -kill :1
    echo "vncserver stopped"
    ;;
  *)
    echo "Usage: /etc/init.d/vncboot {start|stop}"
    exit 1
    ;;
esac
exit 0


jarymokin
Posts: 2
Joined: Sat Dec 26, 2015 9:48 am

Re: Can't Get VNCServer to Autostart

Sat Dec 26, 2015 10:48 am

This code should replace the code I posted before.

Code: Select all

#! /bin/sh
## /etc/init.d/vncboot

### BEGIN INIT INFO
# Script: vncboot
# Provides:          tightvncserver
# 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

##  Original Script /etc/init.d/tightvncserver
# Set the VNCUSER variable to the name of the user to start tightvncserver under
VNCUSER='pi'
export VNCUSER

case "$1" in
  start)
#    su $VNCUSER -c '/usr/bin/vncserver :1'
 su - $VNCUSER -c "/usr/bin/vncserver :1 -geometry 1280x800 -depth 16 -pixelformat rgb565"
    echo "Starting VNC server for $VNCUSER "
    ;;
  stop)
    su  - $VNCUSER -c  '/usr/bin/vncserver -kill :1'
    echo "vncserver stopped"
    ;;
  *)
    echo "Usage: /etc/init.d/vncboot {start|stop}"
    exit 1
    ;;
esac
exit 0

HappyAndrew
Posts: 5
Joined: Tue Dec 29, 2015 12:19 pm

Re: Can't Get VNCServer to Autostart

Tue Dec 29, 2015 12:29 pm

THANK YOU!! At last! I have managed to get the vnc to auto start thanks to jarymokin. I am going to change his code just a little as I want the screen size to fit my monitor which is 1920x1080, and the colour depth to 24 so the code I will change will be

su $VNCUSER -c '/usr/bin/vncserver :1 -geometry 1024x1080 -depth 24'

Return to “Troubleshooting”

Who is online

Users browsing this forum: bulletmark, Rascas, Tzarls, XueHai8 and 57 guests