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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-29-2007, 03:53 PM
|
#1
|
|
Member
Registered: Apr 2007
Location: texas
Distribution: mandriva 2007.0 / edgy
Posts: 63
Rep:
|
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?
|
|
|
|
05-29-2007, 04:05 PM
|
#2
|
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 42,702
|
/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.
|
|
|
|
05-29-2007, 04:58 PM
|
#3
|
|
Member
Registered: Apr 2007
Location: texas
Distribution: mandriva 2007.0 / edgy
Posts: 63
Original Poster
Rep:
|
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.
|
|
|
|
05-29-2007, 05:17 PM
|
#4
|
|
LQ Newbie
Registered: May 2007
Location: UK
Distribution: Redhat variants
Posts: 10
Rep:
|
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!
|
|
|
|
05-29-2007, 06:02 PM
|
#5
|
|
Member
Registered: Apr 2007
Location: texas
Distribution: mandriva 2007.0 / edgy
Posts: 63
Original Poster
Rep:
|
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.
|
|
|
|
05-29-2007, 06:30 PM
|
#6
|
|
LQ Newbie
Registered: May 2007
Location: UK
Distribution: Redhat variants
Posts: 10
Rep:
|
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?
|
|
|
|
05-29-2007, 07:12 PM
|
#7
|
|
Member
Registered: Apr 2007
Location: texas
Distribution: mandriva 2007.0 / edgy
Posts: 63
Original Poster
Rep:
|
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.
|
|
|
|
05-30-2007, 01:44 AM
|
#8
|
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 42,702
|
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.
|
|
|
|
05-30-2007, 03:45 AM
|
#9
|
|
Guru
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,002
|
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.
|
|
|
|
05-30-2007, 04:20 AM
|
#10
|
|
LQ Newbie
Registered: May 2007
Location: UK
Distribution: Redhat variants
Posts: 10
Rep:
|
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.
|
|
|
|
05-30-2007, 12:49 PM
|
#11
|
|
Member
Registered: Apr 2007
Location: texas
Distribution: mandriva 2007.0 / edgy
Posts: 63
Original Poster
Rep:
|
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...
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 09:48 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|