LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 05-29-2007, 03:53 PM   #1
MikeOfAustin
Member
 
Registered: Apr 2007
Location: texas
Distribution: mandriva 2007.0 / edgy
Posts: 63

Rep: Reputation: 15
VNCServer on startup: What am I doing wrong?


I've created a symbolic link inside init.d/
Code:
/etc/init.d/vncserver -> /usr/bin/vncserver
(one did not already exist).

and created a symbolic link in rc3.d/
Code:
/etc/rc3.d/S99vncserver -> /etc/init.d/vncserver

But it won't start automatically. It works if I manually start it. What else do I need to do?
 
Old 05-29-2007, 04:05 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966
/etc/init.d/vncserver is *NOT* a symlink to a binary, it is a service script which controls the startup processes. just read any other script to see how they work. there is often a very basic one you can customize.
 
Old 05-29-2007, 04:58 PM   #3
MikeOfAustin
Member
 
Registered: Apr 2007
Location: texas
Distribution: mandriva 2007.0 / edgy
Posts: 63

Original Poster
Rep: Reputation: 15
Correct, but 'vncserver' did not already exist under init.d (I had manually created the link).

So, I out of curiosity, I removed the link and copied the real thing over. vncserver from /usr/bin/ to the init.d directory, and it still won't start automatically. I would assume it's the correct script because about a dozen lines down it says

" # vncserver - wrapper script to start an X VNC server. "


So now I have

Code:
/etc/rc3.d/S99vncserver -> /etc/init.d/vncserver
and

Code:
/etc/init.d/vncserver
(not a link)

The permissions are all fine for both files.
 
Old 05-29-2007, 05:17 PM   #4
Phil-B
LQ Newbie
 
Registered: May 2007
Location: UK
Distribution: Redhat variants
Posts: 10

Rep: Reputation: 0
Hi there,

If you have a look at any of the other files in /etc/init.d you will be able to see the correct format of file you want in there.

You aren't supposed to simply link the binaries or startup scripts of whatever you're trying to run. I'm surprised there isn't already a script for this on your system: would have expected it to install one by default.

Nevertheless, try this:

Remove the vncserver file you copied into /etc/init.d and ensure it's back in it's original place (/usr/bin/vncserver as you said). At this point there should be no file named vncserver in your /etc/init.d.

Type:

Code:
vi /etc/init.d/vncserver
Press i

Paste the following in:

Code:
#!/bin/bash
#
# chkconfig: - 91 35
# description: Starts and stops vncserver. \
#              used to provide remote X administration services.

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

unset VNCSERVERARGS
VNCSERVERS=""
[ -f /etc/sysconfig/vncservers ] && . /etc/sysconfig/vncservers

prog=$"VNC server"

start() {
    echo -n $"Starting $prog: "
    ulimit -S -c 0 >/dev/null 2>&1
    RETVAL=0
    for display in ${VNCSERVERS}
    do
        echo -n "${display} "
        unset BASH_ENV ENV
        DISP="${display%%:*}"
        export USER="${display##*:}"
        export VNCUSERARGS="${VNCSERVERARGS[${DISP}]} -localhost" # -localhost
        initlog $INITLOG_ARGS -c \
            "su ${USER} -c \"cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}\""
        RETVAL=$?
        [ "$RETVAL" -ne 0 ] && break
    done
    [ "$RETVAL" -eq 0 ] && success $"vncserver startup" || \
        failure $"vncserver start"
    echo
    [ "$RETVAL" -eq 0 ] && touch /var/lock/subsys/vncserver
}

stop() {
    echo -n $"Shutting down $prog: "
    for display in ${VNCSERVERS}
    do
        echo -n "${display} "
        unset BASH_ENV ENV
        export USER="${display##*:}"
        initlog $INITLOG_ARGS -c \
            "su ${USER} -c \"vncserver -kill :${display%%:*}\" >/dev/null 2>&1"
    done
    RETVAL=$?
    [ "$RETVAL" -eq 0 ] && success $"vncserver shutdown" || \
        failure $"vncserver shutdown"
    echo
    [ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/vncserver
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
(Script taken from an old Fedora installation that works for me)

Press ESC, then type :wq and press Enter.

You should be left at a command prompt.

As root, do:

Code:
chmod 755 /etc/init.d/vncserver
chkconfig vncserver on
Assuming the script works, your VNC server should now run at boot time.

Hope this is of some help!
 
Old 05-29-2007, 06:02 PM   #5
MikeOfAustin
Member
 
Registered: Apr 2007
Location: texas
Distribution: mandriva 2007.0 / edgy
Posts: 63

Original Poster
Rep: Reputation: 15
Unfortunitly, the cut-n-paste you provided (for fedora) choked as I'm on edgy. This is what I have for a script under init.d/
I can start and stop the vncserver just fine using this ( etc/init.d/vncserver stop <or start>).

Quote:
#! /bin/sh
# /etc/init.d/vncserver
#

# Some things that run always

# none


# main
case "$1" in
start)
/usr/bin/vncserver
;;
stop)
/usr/bin/vncserver -kill :1
;;
*)
echo "Usage: /etc/init.d/vncserver {start|stop}"
exit 1
;;
esac

exit 0
I've ran the ' sudo update-rc.d vncserver defaults ' (ubuntu's version of chkconfig).
I've verified that /etc/rc#.d/ has the S##vncserver in the directories with the right permissions.
This is just strange. I can start and stop it all day, but it won't start on boot.

Also, FWIW, I'm currently editing this remotely and issuing a 'sudo reboot' everytime I make some changes to test it out. I can tell if it's working by ' ps x | grep vnc ' or just by vncviewer remotely.
 
Old 05-29-2007, 06:30 PM   #6
Phil-B
LQ Newbie
 
Registered: May 2007
Location: UK
Distribution: Redhat variants
Posts: 10

Rep: Reputation: 0
Ah right sorry for the presumptuous Fedora spam - call it first post nerves

It's a bit weird that "update-rc.d defaults" doesnt just work.

Perhaps you're booting into a runlevel for which vncserver has not been configured to run? I can't see why this would be the case though, because update-rc.d defaults should create a startup link for runlevels 2,3,4,5.

I take it theres nothing in the logs that's helpful?
 
Old 05-29-2007, 07:12 PM   #7
MikeOfAustin
Member
 
Registered: Apr 2007
Location: texas
Distribution: mandriva 2007.0 / edgy
Posts: 63

Original Poster
Rep: Reputation: 15
Yep. It's got me stumped!

I've got 'S20vncserver' in rc2.d, rc3.d and rc5.d . (these were created with 'update-rc.d vncserver defaults').

In /etc/init.d/ I have vncserver. This has all permissions granted and is executable.
While in terminal window under non-root user, I type '/etc/init.d/vncserver start' and I get a new X session on :1.
Manually starting it works great. No errors, etc.

...and, other than the usuall logs under /var/logs, I wouldn't know where to look for error messages. Do you???

Really weird. It's something small, I know it.
 
Old 05-30-2007, 01:44 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966
you're not paying attention to what we're saying ehh? /etc/init.d/vncserver is *NOT* *NOT* *NOT* the same as /usr/bin/vncserver. they do DIFFERENT things. copying that binary file to there will not work (unless sheer luck of command line options and default config files happen to line up) just read an existing script and modify it to suit your needs if you can't find an existing init.d script on google.
 
Old 05-30-2007, 03:45 AM   #9
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,017

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
I don't understand why you want to make this so complicated.
I start a vncserver at boot with this line in rc.local:
Code:
su - tredegar -c "cd /home/tredegar/ && vncserver :1 -geometry 1024x768 -depth 24"
It works just fine.
Edit: I forgot the final '"'

Last edited by tredegar; 05-30-2007 at 03:48 AM.
 
Old 05-30-2007, 04:20 AM   #10
Phil-B
LQ Newbie
 
Registered: May 2007
Location: UK
Distribution: Redhat variants
Posts: 10

Rep: Reputation: 0
Mike,

When I start my vncserver it puts logs into /var/log/messages, but nothing particularly useful.

There are also more specific logs in /home/myvncuser/.vnc/myhostname:1.log (man vncserver).

But obviously logs will only be helpful if the script is being run and failing, not if the script isnt running at all.

Like Chris says, the file at /etc/init.d/vncserver should be a SysV style init script. That's what your distribution expects to be there and if what you posted earlier is your /etc/init.d/vncserver then it looks alright.

One further thing though - your script doesnt start with any arguments and by default vncserver tries to start as the current user on display number 1. If your script were to run during boot it would try to set up a VNC session for root I would imagine. Try editing your command line in your script to something like what tredegar posted. If you look at the script I posted earlier, you can see it does the same as tredegars simple command line, albeit in a long winded but more general way (it will read a file and set up multiple VNC sessions depending on usernames and display numbers that I specify).

Something simple such as the following may work in your script as a replacement for your /usr/bin/vncserver line:

Code:
su - yourusername -c /usr/bin/vncserver
But you might want to specify some further options as tredegar has.

HTH!

Last edited by Phil-B; 05-30-2007 at 04:23 AM.
 
Old 05-30-2007, 12:49 PM   #11
MikeOfAustin
Member
 
Registered: Apr 2007
Location: texas
Distribution: mandriva 2007.0 / edgy
Posts: 63

Original Poster
Rep: Reputation: 15
Phil, that did it. Thanks very much to you and everyone that helped.

I had never setup the root password for vncserver, so it was choking when it tried to run as root. Giving it a su - myusername worked like a charm. I've learned quite a bit about scripting over this little exercise. One less whiny noob in the world...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
vncserver on startup greenmeanie *BSD 1 10-22-2005 11:16 AM
how to startup the vncserver ust Linux - Distributions 2 05-25-2005 07:58 AM
Robust vncserver startup file (rc.vncserver) arobinson74 Slackware 4 05-14-2005 05:33 AM
Starting a vncserver instance automatically at startup paul.nel Linux - General 6 01-08-2004 08:24 PM
VncServer - Startup issues TrueSword Linux - General 1 12-06-2002 05:13 PM


All times are GMT -5. The time now is 05:47 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration