LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   starting vncserver from rc.local (https://www.linuxquestions.org/questions/slackware-14/starting-vncserver-from-rc-local-867073/)

explorer 03-07-2011 05:40 PM

starting vncserver from rc.local
 
I'm a little new to Slackware so maybe this isn't the right way to initiate vncserver on boot, but here's what I've got. The last two lines in my rc.local are:

/usr/bin/vncserver :1 &
mount.cifs //192.168.1.99/shared /mnt/shared -o username='uname',password='passwd'

the second line runs successfully on boot, but the first line doesn't. However, after I am logged on, I can execute /etc/rc.d/rc.local and both lines will run successfully. Does the system need to be fully logged on to start the vncserver, or should I start it elsewhere other than rc.local ? Thanks in advance.

Mike
-----------------------------
Using Slackware 13.1 (32 bit) and the Vnc package that came with the Slackware image, not sure of the version.

chrisretusn 03-07-2011 06:32 PM

You should be starting /etc/rc.vncservers from rc.local. There is also a /etc/rd.d/rc.vncservers.conf that may require editing.

Code:

if [ -x /etc/rc.d/rc.vncservers ]; then
  /etc/rc.d/rc.vncservers start
fi


gilead 03-07-2011 07:11 PM

I used to use the following as a start-up script for VNC. It was called from /etc/rc.d/rc.local (and therefore run by root):
Code:

#!/bin/sh
#
# description: Starts and stops vncserver. \
#        used to provide remote X administration services.

unset VNCSERVERARGS
VNCSERVERS="1:steve 2:james"
VNCSERVERARGS[1]="-geometry 1600x1200"
VNCSERVERARGS[2]="-geometry 1024x768"

start() {
  echo -n $"Starting VNC server: "

  if [ ! -d /tmp/.X11-unix ]
  then
    mkdir -m 1777 /tmp/.X11-unix || :
  fi
  for display in ${VNCSERVERS}
  do
    echo -n "${display} "
    unset BASH_ENV ENV
    DISP="${display%%:*}"
    export USER="${display##*:}"
    export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
    su - ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS} -localhost"
  done
}

stop() {
  echo -n $"Shutting down VNC server: "
  for display in ${VNCSERVERS}
  do
    echo -n "${display} "
    unset BASH_ENV ENV
    export USER="${display##*:}"
    su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
  done
  echo "Done."
}

# See how we were called.
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart|reload)
    stop
    sleep 3
    start
    ;;
  *)
    echo $"Usage: $0 {start|stop|restart}"
esac


explorer 03-07-2011 07:27 PM

Thanks fellas. Was that code your rc.venserver gilead ? I don't think I have a rc.vncserver so I probably need to make one.

gilead 03-07-2011 09:04 PM

Yep, that's right - it was in /etc/rc.d/rc.vncserver (call it whatever you like though)

explorer 03-08-2011 10:50 AM

got it fixed ! Thanks again fellas, I appreciate it. I think I'm gonna like being a slacker !

explorer 03-08-2011 02:06 PM

one more thing.....
 
When I want to end the session from the vnc-viewer machine, I click the vnc icon at the very top-left of the vnc-viewer window, the one at the left end of the title bar, and click the Close option from the menu that pops up. Then I can start a new session again later if I want. If I try to log off using the logoff menu-item on the remote screen like a local user would do, the viewer window goes black but doesn't close and the session is left open. Then you have to manually close the window anyway, and after you close it, you can't start a new session until a "rc.vncservers restart" has been done or a new server session started. I only post this in case anyone else might be wondering how to end a viewer session.

gilead 03-08-2011 04:43 PM

That's good to know - thanks for posting it. If you find VNC slow over the network, there's also rdesktop (Linux and Windows) or NX type solutions (nomachine, freenx for Linux environments).

Gerard Lally 03-08-2011 04:53 PM

Quote:

Originally Posted by gilead (Post 4283304)
That's good to know - thanks for posting it. If you find VNC slow over the network, there's also rdesktop (Linux and Windows) or NX type solutions (nomachine, freenx for Linux environments).

Another one worth keeping in mind is xrdp, which proxies VNC on the server through the RDP protocol, also on the server. It makes for a very smooth remote desktop session. Easy to install and run, and then just connect to port 3389 on the server using an RDP client - mstsc on Windows, rdesktop on Linux/BSD.


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