Link to home
Start Free TrialLog in
Avatar of Hacking_For_Christ
Hacking_For_Christ

asked on

Linux CentOS 5.4 Auto run not runing /etc/rc.d/rc.local

I am trying to run rdesktop with switches on start-up.  The system will be a thin-client only connecting to a 2003 TS.  The first thing the user will see after boot up is the Logon screen for the TS.  The Linux box will login and run rdesktop ideally.  I have the command & switches in the  /etc/rc.d/rc.local.  If I run the file it launches rdesktop but the OS does not run it on start up.  If I add the file to the session manager it launches but then the desktop replaces the TS logon screen.  Any ideas is welcome, thanks.
Avatar of Deepak Sharma
Deepak Sharma
Flag of India image

If you want to run it during startup and if it is not getting started during boot then you keep it in init.d and enable it by chkconfig. Verify that it is enabled for your run-level and reboot your server. Hopefully it should start once the server comes up after reboot.

If still getting error,send me the details.
assuming X is your runlevel,
check if the file in /etc/rcX.d/
is
S99local
or
K99local

if its K, move it to S.
Avatar of Hacking_For_Christ
Hacking_For_Christ

ASKER

I will look at these in the morning when I am in the office thanks
When I tried chkconfig, it tells me  the TS can not be configured in chkconfig.

When I tried placing the file in the \etc\rc5.d nothing happens

I tried both and neither work, what else can I try, thanks for the help.
Can you post a copy of your script here so we can see what it is you're trying to do, then possibly come up with a solution for it?
Here is the original rc.local file I added to:

touch /var/lock/subsys/local
rdesktop -f -a16 -u USERNAME -k en-us TS.X.com

Then I also tried just the :

rdesktop -f -a16 -u USERNAME -k en-us TS.X.com

If I double click and run the file it works but just not autorun.
I created a quick and dirty script (see below) that is chkconfig usable. Just copy and paste it into a file called rdesktop_control and put it in the /etc/init.d directory. Then do 'chmod +x /etc/init.d/rdesktop_control' and 'chkconfig rdesktop_control on'.

Inside the rdesktop_control script, there are a couple of variables you need to change before it can be usable:

USERNAME=*changeme*
SERVERNAME=*changeme*

Then try doing '/etc/init.d/rdesktop_control start' and see if that works for you.

NOTE: The rdesktop application will NOT run unless it can open the display, so the server needs to have X-Windows running (i.e. init 5).

#!/bin/sh
#
# RDesktop Control Script (rdesktop_control)
#
# chkconfig: 2345 95 20
# description: Quick and dirty script to start/stop the rdesktop
# processname: rdesktop_control

RDP_DIR=/usr/bin/
LOG=/dev/null
RDP=rdesktop

# change these as per requirements
USERNAME=*changeme*
SERVERNAME=*changeme*

# source function library
. /etc/rc.d/init.d/functions

cd $RDP_DIR

if ! test -x $RDP
then
  echo "$RDP is not executable"
  exit 0
fi

rdp_start()
{
  echo -n "Starting: rdesktop "
  $RDP_DIR/$RDP -f -a16 -u $USERNAME -k en-us $SERVERNAME >> $LOG
  sleep 1
  return 0;
}

rdp_stop()
{
  echo -n "Stopping: rdesktop "
  killall $RDP >> $LOG
  return 0;
}

is_rdp_running()
{
  ps u --noheading -C $RDP | grep -q -i $RDP
  if test $? -eq 0
  then
    return 1;
  else
    return 0;
  fi
}


check_up()
{
  # Cleanup : If rdp isn't running, but the pid exists, erase it.
  is_rdp_running
  if test $? -eq 0
  then
    if test -e /var/run/rdp.pid
    then
      rm /var/run/rdp.pid
    fi
  fi
  return 0;
}

case "$1" in
  start)
    check_up
    is_rdp_running
    if ! test $? -eq 0
    then
      echo "rdesktop is already loaded "
      exit 1
    fi
    rdp_start
    ;;
  stop)
    check_up
    is_rdp_running
    if test $? -eq 0
    then
      echo "rdesktop is not loaded "
    fi
    rdp_stop
    ;;
  force-reload|restart)
    check_up
    echo "Restarting rdesktop "
    rdp_stop
    is_rdp_running
    while ! test $? -eq 0
    do
      check_up
      sleep 1
      is_rdp_running
    done
    rdp_start
    ;;
  *)
    echo "Usage: rdesktop_control {start|stop|restart|force-reload}"
    exit 1
esac

exit 0

Open in new window

The script when ran manual works but as a service it does not open the TS windows.  When I restart it as a service in Gnome nothings happens. I check in chkconfig it shows it running in lvl 2-5 but no window.  I like the script; any other ideas to get this to show the window?
It's quite possibly that this application cannot run as a foreground 'service', thus no window is appearing.

Example:
 - VNCServer is a terminal services background 'service'.
 - Rdesktop is like Windows version of RDP, thus a foreground application and not a service.

Thus even the /etc/rc.local way of kicking off the script won't be possible unless the XWindows system environment is already up and actively running.
One option I can think of would be to autostart the rdesktop application when the XWindows environment comes up fully...

Autostart programs in KDE or GNOME - the manual way
http://www.captain.at/howto-autostart-program-in-kde-gnome.php

How to autostart any program when Gnome desktop session starts
http://blog.taragana.com/index.php/archive/how-to-autostart-any-program-when-gnome-desktop-session-starts/
ASKER CERTIFIED SOLUTION
Avatar of Hacking_For_Christ
Hacking_For_Christ

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial