Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 29 Jul 2014, 23:17
All times are UTC - 4
 Forum index » House Training » Beginners Help ( Start Here)
Log into server (with rdesktop) on bootup?
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 2 [25 Posts]   Goto page: Previous 1, 2
Author Message
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Thu 22 Jan 2009, 22:44    Post subject:  

You could give the script a loop so that it will wait for a network connection.
Code:
#don't bother starting until there's a network connection
NOCONNECTION=1
while [ ! $NOCONNECTION = 0 ]; do
  ping -c 2 google.com
  NOCONNECTION=$?
  [ ! $NOCONNECTION = 0 ] && sleep 10
done
rdesktop -w -h -a -t -e -v -e -r


Then place it in /root/Startup. It will start running when X starts, and will look for a connection every ten seconds. Once it sees a connection it will run the commands after the 'done'.

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
Mikrodots

Joined: 31 Mar 2006
Posts: 30
Location: Boston, MA USA

PostPosted: Fri 23 Jan 2009, 12:07    Post subject:  

This is a couple years old now but it may help.

It did a lot more than start RDC -
Make sure xwin is running
Connected by bluetooth to the Inernet
Test Internet connection
Started Dynamic DNS
Created a VPN connection
Launch RDC

Of course the script won't run wthout a lot of other daemons and such.

You'll need to pick through and try the pieces you need, but it should help you write your own scripts to test if RDC is running, start RDC, test if the remote host is available etcetera.

script /etc/rc.d/startrdc

Code:


#!/bin/sh
#
# startrdc
# Startup script for RDC
#

exec 1>>/var/log/rdc.log 2>&1
now=`date ‘+%d%m%y-%H:%M’`
echo -e “RUNNING STARTRDC $now ”
echo -e

# Status Functions

function status_xwin
{
echo -e “function status_xwin”
local rv=
rv=`grep true /etc/.XLOADED | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function wait_for_xwin
{
echo -e “function wait_for_xwin”
local rv=
rv=`grep true /etc/.XLOADED | wc | awk ‘{print $1}’`
while [ ! "$rv" != "0" ] # loop until X is up
do
echo -n ” XWIN true should be 0: $rv”
rv=`grep true /etc/.XLOADED | wc | awk ‘{print $1}’`
echo -e “Waiting for X to start = $rv”
sleep 1
continue
done
echo -e “Return Value = $rv”
return $rv
}

function wait_for_vpn
{
echo -e “function wait_for_vpn”
local rv=
rv=`ping -c 1 10.3.0.6 | grep from | wc | awk ‘{print $1}’`
while [ ! "$rv" != "0" ] # loop until X is up
do
echo -n “wait_for_vpn = $rv”
rv=`ping -c 1 10.3.0.6 | grep from | wc | awk ‘{print $1}’`
echo -e “Waiting for VPN to start = $rv”
sleep 1
continue
done
echo -e “Return Value = $rv”
return $rv
}

function status_pppd
{
echo -e “function status_pppd”
local rv=
rv=`ps | grep pppd | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_hcid
{
echo -e “function status_hcid”
local rv=
rv=`ps | grep hcid | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_rfcomm
{
echo -e “function status_rfcomm”
local rv=
rv=`ps | grep rfcomm | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_internet
{
echo -e “function status_internet”
local rv=
#rv=`ps | grep pppd | wc | awk ‘{print $1}’`
rv=`netstat -i | grep ppp | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_ping_internet
{
echo -e “function status_ping_internet”
local rv=
rv=`ping -c 1 4.2.2.1 | grep from | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_dns
{
echo -e “function status_ping_yahoo”
local rv=
rv=`ping -c 1 yahoo.com | grep from | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_dyn_dns
{
echo -e “function status_dyn_dns”
local rv=
rv=`ps | grep inadyn | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_openvpn_daemon
{
echo -e “function status_openvpn”
local rv=
rv=`ps | grep openvpn | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_openvpn_tun
{
echo -e “function status_openvpn”
local rv=
# rv=`ps | grep openvpn | wc | awk ‘{print $1}’`
rv=`netstat -i | grep tun | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_ping_vpn
{
echo -e “function status_ping_vpn”
local rv=
# rv=`netstat -i | grep tun | wc | awk ‘{print $1}’`

#10.3.0.6 is your servers TUN adapter address

rv=`ping -c 1 10.3.0.6 | grep from | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_rdc
{
echo -e “function status_rdesktop”
local rv=
rv=`ps | grep rdesktop | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

# Start Functions

function start_dyn_dns
{
echo -e “\n Function start_dyn_dns”
echo -e “\n call status_dyn_dns”
status_dyn_dns
rv=$?
echo -e “status_dyn_dns: Returned value: $rv”
if [ ! "$rv" != "0" ]; then
echo -e “\n Starting inadyn dynamic DNS”
/usr/local/inadyn/inadyn.sh &
echo -e “\n start_dyn_dns to Test to see if inadyn started”
sleep 2
start_dyn_dns
elif [ ! "$rv" != "1" ]; then
echo -e “\n Starting inadyn dynamic DNS”
/usr/local/inadyn/inadyn.sh &
echo -e “\n start_dyn_dns to Test to see if inadyn started”
sleep 2
start_dyn_dns
fi
}

function start_bluetoothmodem
{
echo -e “\n function start_bluetoothmodem”
echo -e “\n ping the internet to see if we are connected”
status_ping_internet
rv=$?
echo -e “\n status_ping_internet: Returned value: $rv”
if [ ! "$rv" != "0" ]; then
echo -e “\n calling status_hcid from start_bluetoothmodem”
status_hcid
rv=$?
echo -e “\n status_hcid: Returned value: $rv”
if [ ! "$rv" != "0" ]; then
echo -e “\n Running /etc/rc.d/bluetoothmodem”
/etc/rc.d/bluetoothmodem >> /var/log/gprs.log &
elif [ ! "$rv" != "1" ]; then
echo -e “\n Running /etc/rc.d/bluetoothmodem”
/etc/rc.d/bluetoothmodem >> /var/log/gprs.log
fi

fi
}

function fix_dns
{
echo -en
}
function start_vpn
{
echo -e “function start_vpn”
/etc/openvpn/openvpn –config /etc/openvpn/mikro1.ovpn > /var/log/openvpn.log &
}

function start_rdc
{
echo -e “\n Test VPN then START RDC”
wait_for_xwin
status_ping_internet
wait_for_vpn
/usr/bin/rdesktop -a 16 -f -z -x m -E -P -N 10.3.0.6 &
echo -e “Started rdesktop”
}

# Here is the program

function connect_mykro
{

echo -e “\n\r**********************************************************************”
echo -e “***********************RUNNING CONNECT_MYKRO $now ************************”

# start_bluetoothmodem
echo -e “\n Call start_rdc”
echo -e “\n Call start_dyn_dns”
# start_dyn_dns
echo -e “\n Call start_vpn”
start_vpn
echo -e “\n Call start_bluetoothmodem”
start_rdc

status_ping_internet
pinginternetstatus=$?
echo “pinginternetstatus: $pinginternetstatus”

status_ping_vpn
vpnstatus=$?
echo “vpnstatus: $vpnstatus”

status_hcid
hcidstatus=$?
echo “hcidstatus: $hcidstatus”

status_rdc
rdcstatus=$?
echo “rdcstatus: $rdcstatus”

status_dyn_dns
dyndnsstatus=$?
echo “dyndnsstatus: $dyndnsstatus”

status_openvpn_tun
tunstatus=$?
echo “tunstatus: $tunstatus”

}
export DISPLAY=:0.0
rxvt -bg “light blue” -geometry 134×20 -title “RDC LOG” -e tail -n 20 -f /var/log/rdc.log &
rxvt -bg “red” -geometry 134×20 -title “PING REMOTE HOST” -e ping 10.3.0.6 &
# /etc/rc.d/KillAllMykrodot &
connect_mykro
exit
#End!



Looks like the code tags mess up the quotes. Here it is in plain text...


#!/bin/sh
#
# startrdc
# Startup script for RDC
#

exec 1>>/var/log/rdc.log 2>&1
now=`date ‘+%d%m%y-%H:%M’`
echo -e “RUNNING STARTRDC $now ”
echo -e

# Status Functions

function status_xwin
{
echo -e “function status_xwin”
local rv=
rv=`grep true /etc/.XLOADED | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function wait_for_xwin
{
echo -e “function wait_for_xwin”
local rv=
rv=`grep true /etc/.XLOADED | wc | awk ‘{print $1}’`
while [ ! "$rv" != "0" ] # loop until X is up
do
echo -n ” XWIN true should be 0: $rv”
rv=`grep true /etc/.XLOADED | wc | awk ‘{print $1}’`
echo -e “Waiting for X to start = $rv”
sleep 1
continue
done
echo -e “Return Value = $rv”
return $rv
}

function wait_for_vpn
{
echo -e “function wait_for_vpn”
local rv=
rv=`ping -c 1 10.3.0.6 | grep from | wc | awk ‘{print $1}’`
while [ ! "$rv" != "0" ] # loop until X is up
do
echo -n “wait_for_vpn = $rv”
rv=`ping -c 1 10.3.0.6 | grep from | wc | awk ‘{print $1}’`
echo -e “Waiting for VPN to start = $rv”
sleep 1
continue
done
echo -e “Return Value = $rv”
return $rv
}

function status_pppd
{
echo -e “function status_pppd”
local rv=
rv=`ps | grep pppd | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_hcid
{
echo -e “function status_hcid”
local rv=
rv=`ps | grep hcid | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_rfcomm
{
echo -e “function status_rfcomm”
local rv=
rv=`ps | grep rfcomm | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_internet
{
echo -e “function status_internet”
local rv=
#rv=`ps | grep pppd | wc | awk ‘{print $1}’`
rv=`netstat -i | grep ppp | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_ping_internet
{
echo -e “function status_ping_internet”
local rv=
rv=`ping -c 1 4.2.2.1 | grep from | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_dns
{
echo -e “function status_ping_yahoo”
local rv=
rv=`ping -c 1 yahoo.com | grep from | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_dyn_dns
{
echo -e “function status_dyn_dns”
local rv=
rv=`ps | grep inadyn | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_openvpn_daemon
{
echo -e “function status_openvpn”
local rv=
rv=`ps | grep openvpn | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_openvpn_tun
{
echo -e “function status_openvpn”
local rv=
# rv=`ps | grep openvpn | wc | awk ‘{print $1}’`
rv=`netstat -i | grep tun | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_ping_vpn
{
echo -e “function status_ping_vpn”
local rv=
# rv=`netstat -i | grep tun | wc | awk ‘{print $1}’`

#10.3.0.6 is your servers TUN adapter address

rv=`ping -c 1 10.3.0.6 | grep from | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

function status_rdc
{
echo -e “function status_rdesktop”
local rv=
rv=`ps | grep rdesktop | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}

# Start Functions

function start_dyn_dns
{
echo -e “\n Function start_dyn_dns”
echo -e “\n call status_dyn_dns”
status_dyn_dns
rv=$?
echo -e “status_dyn_dns: Returned value: $rv”
if [ ! "$rv" != "0" ]; then
echo -e “\n Starting inadyn dynamic DNS”
/usr/local/inadyn/inadyn.sh &
echo -e “\n start_dyn_dns to Test to see if inadyn started”
sleep 2
start_dyn_dns
elif [ ! "$rv" != "1" ]; then
echo -e “\n Starting inadyn dynamic DNS”
/usr/local/inadyn/inadyn.sh &
echo -e “\n start_dyn_dns to Test to see if inadyn started”
sleep 2
start_dyn_dns
fi
}

function start_bluetoothmodem
{
echo -e “\n function start_bluetoothmodem”
echo -e “\n ping the internet to see if we are connected”
status_ping_internet
rv=$?
echo -e “\n status_ping_internet: Returned value: $rv”
if [ ! "$rv" != "0" ]; then
echo -e “\n calling status_hcid from start_bluetoothmodem”
status_hcid
rv=$?
echo -e “\n status_hcid: Returned value: $rv”
if [ ! "$rv" != "0" ]; then
echo -e “\n Running /etc/rc.d/bluetoothmodem”
/etc/rc.d/bluetoothmodem >> /var/log/gprs.log &
elif [ ! "$rv" != "1" ]; then
echo -e “\n Running /etc/rc.d/bluetoothmodem”
/etc/rc.d/bluetoothmodem >> /var/log/gprs.log
fi

fi
}

function fix_dns
{
echo -en
}
function start_vpn
{
echo -e “function start_vpn”
/etc/openvpn/openvpn –config /etc/openvpn/mikro1.ovpn > /var/log/openvpn.log &
}

function start_rdc
{
echo -e “\n Test VPN then START RDC”
wait_for_xwin
status_ping_internet
wait_for_vpn
/usr/bin/rdesktop -a 16 -f -z -x m -E -P -N 10.3.0.6 &
echo -e “Started rdesktop”
}

# Here is the program

function connect_mykro
{

echo -e “\n\r**********************************************************************”
echo -e “***********************RUNNING CONNECT_MYKRO $now ************************”

# start_bluetoothmodem
echo -e “\n Call start_rdc”
echo -e “\n Call start_dyn_dns”
# start_dyn_dns
echo -e “\n Call start_vpn”
start_vpn
echo -e “\n Call start_bluetoothmodem”
start_rdc

status_ping_internet
pinginternetstatus=$?
echo “pinginternetstatus: $pinginternetstatus”

status_ping_vpn
vpnstatus=$?
echo “vpnstatus: $vpnstatus”

status_hcid
hcidstatus=$?
echo “hcidstatus: $hcidstatus”

status_rdc
rdcstatus=$?
echo “rdcstatus: $rdcstatus”

status_dyn_dns
dyndnsstatus=$?
echo “dyndnsstatus: $dyndnsstatus”

status_openvpn_tun
tunstatus=$?
echo “tunstatus: $tunstatus”

}
export DISPLAY=:0.0
rxvt -bg “light blue” -geometry 134×20 -title “RDC LOG” -e tail -n 20 -f /var/log/rdc.log &
rxvt -bg “red” -geometry 134×20 -title “PING REMOTE HOST” -e ping 10.3.0.6 &
# /etc/rc.d/KillAllMykrodot &
connect_mykro
exit
#End!


Mikrodots
Back to top
View user's profile Send private message Visit poster's website 
sodes

Joined: 22 Jan 2009
Posts: 7
Location: Chi-town

PostPosted: Fri 23 Jan 2009, 16:51    Post subject: rdesktop startup
Subject description: automatic
 

Thanks Pizzasgood and Mikrodots for your help.

I'm currently using Pizzas implementation. It works well, but occasionally it causes xorg to lock up completely requiring a hard restart..... Not sure if that is the loop or something else entirely. Xvesa doesn't seem to have the problem though, so i may just stick with that.

Mikro, I like the looks of the script and i think i am going to adapt what i can to meet the needs of my system and setup. It is one helluva piece of work though.

I believe at this point I have a good idea of how i will get the rdesktop to autostart. Do either of you have any thoughts regarding restarting the process after the user closes it? At this point, if a user logs out of the terminal screen, they are dropped back down to the desktop. I'm looking for something that will monitor when the rdesktop process ends and restart a new process automatically. In effect, the user should never see the desktop. In the interim, i have created a link on the desktop labled "Click Me" to give the users something to restart rdesktop once the initial instance of rdesktop ends.

Thanks again!
Back to top
View user's profile Send private message 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Sat 24 Jan 2009, 16:47    Post subject:  

Not sure why it would cause X to hang.

For making it restart rdesktop, put the rdesktop command inside an infinite while loop, like this:
Code:
while [ 1 ]; do
  rdesktop
done


So, overall it would be something like this:
Code:
#!/bin/sh
NOCONNECTION=1
while [ ! $NOCONNECTION = 0 ]; do
  ping -c 2 google.com
  NOCONNECTION=$?
  [ ! $NOCONNECTION = 0 ] && sleep 10
done
while [ 1 ]; do
  rdesktop
done

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
sodes

Joined: 22 Jan 2009
Posts: 7
Location: Chi-town

PostPosted: Sat 24 Jan 2009, 17:17    Post subject: rdesktop  

Thanks for the quick reply Pizza! I will give it a try and let you know how it works out. Once i am finished, my goal it to continue working on the Thin Puppy and offer it as a new distro.
Back to top
View user's profile Send private message 
sodes

Joined: 22 Jan 2009
Posts: 7
Location: Chi-town

PostPosted: Sat 24 Jan 2009, 17:17    Post subject: rdesktop  

.
Back to top
View user's profile Send private message 
sodes

Joined: 22 Jan 2009
Posts: 7
Location: Chi-town

PostPosted: Mon 16 Feb 2009, 18:08    Post subject: rdesktop.... again....
Subject description: Keeping it alive
 

Thank you for all the help up to this point. I am looking for your assistance once again....

The Puppy Thin Client works very well. Upon booting up, the terminal login screen is presented just the way i wanted it to be. When you logout, it restarts rdesktop just the way it is supposed to.

One thing i am noticing though is that after a certain amount of time, if rdesktop isn't logged in, the process will die and have to be restarted. I'm guessing that there is some type of inactivity monitor that kills the process if it doesn't actually log in.

So my question is..... Is there a way to prevent the process from being killed due to inactivity, OR increase the amount of time a process can be inactive before it is killed?

Thanks for your help.
Back to top
View user's profile Send private message 
Bruce B


Joined: 18 May 2005
Posts: 11080
Location: The Peoples Republic of California

PostPosted: Mon 16 Feb 2009, 19:18    Post subject:  

The problem is things that were true may not be true now.

rc.network may have ran sequentially then, I don't remember, but it runs in the background now.

It is a little hard to tell when rc.network is finished without a method. It could still be running after rc.local, after profile and even after X boots.

rc.network is designed for a wide range of networking possibilities. Then there is the time delay inherent with DHCP.

I don't have a wide range of possibilities, so I don't need rc.network to check all these things. For this reason I wrote my own script, which brings the network up in less than a second. There is no backgrounding or guessing. I know when my network is up, that is the instant the script commands return.

This concludes an overview of the problem.

==================

As for what you can do.

Like I do?

Don't let rc.network background, this way by the time you get to /etc/profile it has finished and you can start the service in profile.local or rc.local (the booting would take longer)

If you have a cabled network and can make a static IP address because you are behind a router, I could tell you the commands to run.

_________________
New! Puppy Linux Links Page
Back to top
View user's profile Send private message 
sodes

Joined: 22 Jan 2009
Posts: 7
Location: Chi-town

PostPosted: Mon 16 Feb 2009, 20:11    Post subject:  

Actually Bruce, the network comes up on time before rdesktop even attempts to run for the first time. I'm using Pizza's script to check for a ping before continuing with bringing up rdesktop.

The problem revolves around rdesktop itself....

after the PC boots up..

rdesktop starts, The Windows Server 2003 Terminal Services login screen is displayed fullscreen. If a user doesn't log in, the login screen sits there waiting....... For about 10 minutes or so when the rdesktop instance closes. It appears that if it is inactive for a period of time (10 minutes), the process just dies on it's own.

what I am trying to figure out is how to get it to stay alive indefinitely, or if I can't keep it alive indefinitely, to increase the inactive time for as long as possible. I want the rdesktop process to stay running forever, until a user is able to login.


Any ideas?
Back to top
View user's profile Send private message 
Mikrodots

Joined: 31 Mar 2006
Posts: 30
Location: Boston, MA USA

PostPosted: Fri 31 Jul 2009, 11:12    Post subject:  

Sorry for the delay.

Windows Terminal Service will kill the connection after a login timeout period.

The default session timeout (not to be confused with login timeout) is two hours.

You will have to detect the connection is dropped and then restart RDC. I don't know if the login timeout can be set to infinity on the terminal server.

You could try the AutoLogon feature of TS - big security problem there - but if you don't care about that...

Mikrodots
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 2 of 2 [25 Posts]   Goto page: Previous 1, 2
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Beginners Help ( Start Here)
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1046s ][ Queries: 12 (0.0047s) ][ GZIP on ]