WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: reboot local machine when rdesktop logs off  (Read 4611 times)

Offline get2guy

  • Newbie
  • *
  • Posts: 12
reboot local machine when rdesktop logs off
« on: November 26, 2014, 05:04:21 AM »
Hi All

I configure a machine to dual boot win7+tiny core

Tiny core is starting rdesktop with credentials to specific IP (works well since user & pass are per computer not user)
I don't know how I can make tiny core to reboot the local machine when the session ends. the goal is to go back to the bootloader menu.

Can someone help?

changes i made:
Created the file /home/tc/myrdesktop
-------------------------------------------------
#!/bin/sh
# myrdesktop
while true
do
rdesktop -f -u XXXX -p XXXX 10.10.10.10
done
-------------------------------------------------
Edited the file /home/tc/.xsession (added the last 2 lines)
-------------------------------------------------
Xvesa -br -screen 1024x768x32 -shadow -2button -mouse /dev/input/mice,5 -nolisten tcp -I>/dev/null 2>&1 & export XPID=$!
waitforX || ! echo faild in waitforX || exit
"$DESKTOP" 2>/tmp/wm_errors &
export WM_PID=$!
[ -x $HOME/.setbackground ] && $HOME/.setbackground
[ -x $HOME/.mouse_config ] && $HOME/.mouse_config &
[ $(which "$ICONS".sh) ] && ${ICONS}.sh &
[ -d "$HOME/.X.d" ] && find "$HOME/.X.d" -type f -print l while read F; do . "$F"; &
$HOME/autostart &
done
-------------------------------------------------------
Created the file /home/tc/.X.d/myrdesktop.sh
-------------------------------------------------------
#!/bin/sh
# myrdesktop
while true
do
rdesktop -f -u XXXX -p XXXX 10.10.10.10
done
-------------------------------------------------------
Gave the user poweroff and reboot privilege
-------------------------------------------------------
chmod u+s /sbin/poweroff
chmod u+s /sbin/reboot
-------------------------------------------------------

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: reboot local machine when rdesktop logs off
« Reply #1 on: November 26, 2014, 06:23:21 AM »
Déjà vu...
Im not too sure but your  ~/.xsession  looks kinda bad. I think it will execute  $HOME/autostart  as many times as there is a file found in  $HOME/.X.d  and won't execute  $HOME/autostart  at all if there is nothing in  $HOME/.X.d .

I'd suggest you either change it to this...
Code: [Select]
Xvesa -br -screen 1024x768x32 -shadow -2button -mouse /dev/input/mice,5 -nolisten tcp -I>/dev/null 2>&1 & export XPID=$!
waitforX || ! echo faild in waitforX || exit
"$DESKTOP" 2>/tmp/wm_errors &
export WM_PID=$!
[ -x $HOME/.setbackground ] && $HOME/.setbackground
[ -x $HOME/.mouse_config ] && $HOME/.mouse_config &
[ $(which "$ICONS".sh) ] && ${ICONS}.sh &
[ -d "$HOME/.X.d" ] && find "$HOME/.X.d" -type f -print l while read F; do . "$F"; done
[ -x $HOME/autostart ] && $HOME/autostart

... or save your  autostart  script in  ~/.local/bin  and let it be run from  ~/.X.d  by placing a file there (any file name; non-executable) that has only this content:
Code: [Select]
autostart
Download a copy and keep it handy: Core book ;)

Offline get2guy

  • Newbie
  • *
  • Posts: 12
Re: reboot local machine when rdesktop logs off
« Reply #2 on: November 26, 2014, 09:38:06 AM »
Hi Misalf and thanks for your reply.

I thinks you got my question wrong.

The scripts works well, it start automatically on startup and logs me in 10.10.10.10. the issue is at the logoff from the terminal server.
Currently when i logoff the script runs again.
I wish it will reboot tiny core in order to get the bootloader screnn (win 7 or the default tiny core OS)

maybe .bash_logout script should do the trick but i cant find such file in tiny core.
Can someone refer me to the location? or replacement file in tiny core OS?
« Last Edit: November 26, 2014, 09:45:13 AM by get2guy »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: reboot local machine when rdesktop logs off
« Reply #3 on: November 26, 2014, 10:35:20 AM »
Hi get2guy
I think what you are looking for is something similar to this:
Code: [Select]
exitcheck.sh
sudo reboot

Offline Lee

  • Hero Member
  • *****
  • Posts: 645
    • My Core wiki user page
Re: reboot local machine when rdesktop logs off
« Reply #4 on: November 26, 2014, 10:48:57 AM »
Quote
Code: [Select]
#!/bin/sh
# myrdesktop
while true
do
rdesktop -f -u XXXX -p XXXX 10.10.10.10
done
...
Currently when i logoff the script runs again.
I wish it will reboot tiny core in order to get the bootloader screnn (win 7 or the default tiny core OS)

Do you mean that, when you log out of the rdesktop session, rdesktop starts over again?

If so, you might change the script to something like this:
Code: [Select]
#!/bin/sh
# myrdesktop
rdesktop -f -u XXXX -p XXXX 10.10.10.10 ; sudo reboot
32 bit core4.7.7, Xprogs, Xorg-7.6, wbar, jwm  |  - Testing -
PPR, data persistence through filetool.sh          |  32 bit core 8.0 alpha 1
USB Flash drive, one partition, ext2, grub4dos  | Otherwise similar

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: reboot local machine when rdesktop logs off
« Reply #5 on: November 26, 2014, 10:56:29 AM »
I was about to suggest the same and tested it with
Code: [Select]
conky ; sudo reboot
in a file from my  ~/.X.d  folder but it rebooted right after starting X.
Was kinda messy to set it back to normal. (:
Download a copy and keep it handy: Core book ;)

Offline Lee

  • Hero Member
  • *****
  • Posts: 645
    • My Core wiki user page
Re: reboot local machine when rdesktop logs off
« Reply #6 on: November 26, 2014, 08:42:34 PM »
Quote
I was about to suggest the same and tested it with

conky ; sudo reboot

in a file from my  ~/.X.d  folder but it rebooted right after starting X.
Was kinda messy to set it back to normal. (:

Testing is for sissies.     :)

I'll admit I didn't test that, as it seemed so simple.  Could it be that conky failed to run, or ran in the background?  Perhaps using " && " instead of " ; " to ensure that the reboot only happens if the previous command succeeds... or, failing that, some actual testing on my part would be inorder.  Unfortunately, I'm sitting at my wife's PC right at the moment and it would be bad form to chance inadvertently rebooting it... -she- can actually reach me.
32 bit core4.7.7, Xprogs, Xorg-7.6, wbar, jwm  |  - Testing -
PPR, data persistence through filetool.sh          |  32 bit core 8.0 alpha 1
USB Flash drive, one partition, ext2, grub4dos  | Otherwise similar

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: reboot local machine when rdesktop logs off
« Reply #7 on: November 26, 2014, 09:51:49 PM »
Maybe conky behaves differently or I just lied about the exact command.. unknowingly. q:
My shell script knowledge is low but I get what  ;  usually means, however  &&  would only executes the following command if the previous command has ended successfully (returns true or zero), right?
Might those sybols be treated in another way when "sourced" as when executed "directly" (not sure if that makes any sense)?
Download a copy and keep it handy: Core book ;)

Offline core-user

  • Full Member
  • ***
  • Posts: 191
  • Linux since 1999
Re: reboot local machine when rdesktop logs off
« Reply #8 on: November 27, 2014, 05:03:16 AM »
Would this work?
Code: [Select]
#!/bin/sh
# myrdesktop
while true
do
rdesktop -f -u XXXX -p XXXX 10.10.10.10
done
reboot
AMD, ARM, & Intel.

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: reboot local machine when rdesktop logs off
« Reply #9 on: November 27, 2014, 07:50:14 AM »
No. That while loop runs forever and anything after "done" has no chance to get executed.
I suggest you try what Lee said.
Download a copy and keep it handy: Core book ;)

Offline core-user

  • Full Member
  • ***
  • Posts: 191
  • Linux since 1999
Re: reboot local machine when rdesktop logs off
« Reply #10 on: November 27, 2014, 01:16:03 PM »
Then maybe something like this example,
http://www.freeos.com/guides/lsst/ch03sec07.html
but use
Code: [Select]
while [ $i -le 2 ] Once it finishes the loop would it not go onto the next command in the script, which could then be reboot(?).
« Last Edit: November 27, 2014, 01:18:38 PM by core-user »
AMD, ARM, & Intel.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: reboot local machine when rdesktop logs off
« Reply #11 on: November 27, 2014, 01:28:44 PM »
What is the point? He doesn't want it to loop, and without some manipulation of i, that loop won't terminate either.