LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Start RealVNC at boot using init.d (https://www.linuxquestions.org/questions/linux-newbie-8/start-realvnc-at-boot-using-init-d-372230/)

promethious 10-12-2005 07:40 AM

Start RealVNC at boot using init.d
 
I have searched hundreds of forums and tried several things however I keep winding up with a problem in one way or another. (Note- I am using RealVNC, not the vnc that comes with Fedora)

I am just trying to start my vnc server when the computer boots. I have created a file called vnc in my /etc/init.d
Code:

#! /bin/sh
export USER="root"
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11"
NAME=vnc
start()
{
    su - $USER -c"vncserver :3"
}
stop()
{
    su - $USER -c"vncserver -clean -kill :3"
}
case "$1" in
    start)
        echo -n "Starting Xvnc: "
        start
        ;;
    stop)
        echo -n "Stopping Xvnc "
        stop
        ;;
    restart)
    restart)
        echo -n "Restarting Xvnc "
        stop
        start
        ;;
    *)
        echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
        exit 1
        ;;
esac
exit 0

Then I ran the folowing
Code:

ln -s /etc/init.d/boot.vnc /etc/rc0.d/K99vnc
ln -s /etc/init.d/boot.vnc /etc/rc1.d/S99vnc
ln -s /etc/init.d/boot.vnc /etc/rc2.d/S99vnc
ln -s /etc/init.d/boot.vnc /etc/rc3.d/S99vnc
ln -s /etc/init.d/boot.vnc /etc/rc4.d/S99vnc
ln -s /etc/init.d/boot.vnc /etc/rc5.d/S99vnc
ln -s /etc/init.d/boot.vnc /etc/rc6.d/K99vnc

And when I restart my comptuer it says 'Starting VNC' and i get a green 'OK' and a few seconds later I get
Code:

su: /bin/bash Permission Denied
I get the same results when I change USER="root" to my username.

If I run
Code:

[root@intrepid init.d]# bash vnc start
Starting Xvnc:
New 'intrepid.federation:3 (root)' desktop is intrepid.federation:3

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/intrepid.federation:3.log

[root@intrepid init.d]#

The VNC server starts fine. This would lead me to believe the code is correct. Why do I get Permission Denied at boot?

kilgoretrout 10-12-2005 10:30 AM

The X server has to be up and running before you can start the VNC server. When init.d scripts run, X is not up. I think that's your problem; you're trying to start VNC too early. This would also explain why your script works when you run it after booting up; X is up and running at that time.
I'm not that familiar with fedora, but I think you need to add your script someplace like /etc/X11/xinit.d. I'm also not that familiar with gnome, but it may have a way of autostarting scripts/programs when it first comes up. In fact, I'm fairly certain that gnome has some way to do that. That would be where I would look.

LinuxDave 10-12-2005 04:07 PM

Quote:

The X server has to be up and running before you can start the VNC server
This most certainly is not true. VNC runs its own X server.

Fedora/Redhat already have vnc startup scripts in /etc/init.d Why can't you use that script but change it to use your version of VNC?

LinuxDave

promethious 10-14-2005 07:58 AM

:(
Well, I was trying to learn something about linux by installing and configuring a program my self instead of just letting it install its self and add all the scripts for me. But I have been searching for over 2 weeks now and no one can tell me how to start the downloaded rpm version of RealVNC using rc.local or inid.d so I have uninstalled it and installed the vnc that comes with Fedora.
Code:

rpm -e vnc
I then modifed /etc/sysconfig/vncservers by uncommenting the lines.

Code:

VNCSERVERS="3:username"
VNCSERVERARGS[3]="-geometry 800x600"

Rebooted and it works fine.

Here is a good site that explains how to do this on Fedora.
http://www.redhat.com/magazine/006apr05/features/vnc/

If anyone knows how to do what I was trying to do please respond. I would still like to learn how to do things manualy.

Thanks


All times are GMT -5. The time now is 09:18 PM.