Startup Script for VNC-server


Forum: Networking
Topic: Startup Script for VNC-server
started by: thoremil

Posted by thoremil on July 12 2006,09:54
Hello, I am fairly new to Linux (have had Ubuntu on my laptop for like 6 months), but yesterday I decided to blow the dust off of a old 500MHz computer with 32MB memory.  I have installed DSL and the VNC-server-addon and I have this working with a password in X, but I would like for it to start up with password-verification upon bootup so that I do not have to keep the monitor/mouse/keyboard connected to get VNC up and running.  Therefore, I am kindly asking for how to create a script that will do this.  :)
Posted by Zucca on July 12 2006,10:18
As I said before (not blaiming you to start new topic):
Quote
In some cases must create a password file by:
Code Sample
vncpasswd <password_file>

Type a password of your choice.

Then for example if you want to run your vnc server grab your current display but have it to ask the password you chosed
Code Sample
x0vncserver -PasswordFile=<password_file>


I hope this helps...


I don't clearly remember how to start VNC server to other display... But adding line
Code Sample
x0vncserver -PasswordFile=<password_file> &
to your .bash_profile will then start automatically your VNC server for display 0.

I'll post later some more. I'm at work right now and my break is almost over.  :p

Posted by thoremil on July 12 2006,15:07
Thank you for your quick reply, but I had already figured out how to get the password to work from your post about that. :)

I have figured out how to create a script now, that's a start.  I created the file startvnc in /etc/init.d/ and made it writable.  Then I started writing in the code:

##This script will start up the vnc-server upon bootup
/usr/local/bin/vnc4x.sh
xvncserver -PasswordFile=tjajaja
/usr/local/bin/vnc4x0.sh
x0vncserver -PasswordFile=tjajaja
x0vncserver -PasswordFile=tjajaja

As this is my first script, I am curious to know if this will work, I do not want to restart the box if this will not work without editing other files in /etc/init.d/ or the code is downright wrong  :laugh:

Posted by Zucca on July 12 2006,17:28
I'm not sure but I think your script hangs to the second line.
xvncserver will wait there until it has copleted its tasks. Propably as long as you want it to be running...

Basic bash scriptting is quite easy:
Code Sample
xvncserver
anotherprogram
Now. If I was right this script also hangs. This will hang to the first line.
Here's a way to make it run in the background:
Code Sample
xvncserver &
anotherprogram
Adding & will tell script to advance to next task and let preivious task to run 'freely'. You could always do it like this:
Code Sample
xvncserver & anotherprogram


Here's some < beginner guidance > to bash scripting. And
< here >'s bit information related to this backgound thing...

I hope this helped and didn't confuse you.

Posted by clivesay on July 12 2006,17:34
< HERE's > a link to the wiki on an old post about setting up VNC at boot.

Chris

Posted by Zucca on July 12 2006,18:26
Nice, but without password.  :(
Posted by thoremil on July 12 2006,21:23
Very nice indeed, too bad about the password thingie.  
Edit:
I got it to work like this (have to figure out how to make dsl boot into X before login though so it will work, but am too tired to look into this at the moment)  Thank you for your help so far :)

Edit2:
Heh, the box did not like this script, the whole computer froze (Not shocking for me as the CPU in the computer is insane. It has refused any reinstall of windows and most distros of linux, but DSL works.

Edit3:
After fixing the script, DSL is working again :)
Then I did some more tinkering with the .xinitrc file in /home/dsl.  I got the vnc-server up and running by supplying the line /usr/local/bin/x0vncserver -PasswordFile=<password_file> in the very beginning of the file.

The result being that I could log onto the box from another computer with it asking me for a password, but only the X-server had started, not Fluxbox.  I am not very savvy with these scripts, so maybe somebody else can come with the solution  :;):

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.