GobiTodic
Posts: 3
Joined: Wed May 01, 2013 11:10 am

shutdown with rdp logout

Sun May 05, 2013 11:51 am

Hi,
I wanted a Raspberry Pi as an RDP-Client and managed to create one with ArchLinux, Ratpoison and Remmina. It automatically starts Ratpoison and Remmina after login and I wondered if it was possible to shut the RPi down when the RDP client logs out. Or could I use a ratpoison shortcut to log the client out and automatically execute a shutdown after that?

SimonSmall
Posts: 220
Joined: Tue Oct 09, 2012 8:13 pm

Re: shutdown with rdp logout

Sun May 05, 2013 1:27 pm

You can tell the Pi to shutdown on the RDP client, typing "sudo halt", then close the RDP client before the shutdown is complete. Alternatively, just let the Pi shutdown close the RDP connection (this might be seen as an untidy way to do it). The Pi takes a few seconds to do that shutdown process. If you want longer, use "shutdown -h -t 10" to wait 10 seconds before starting the shutdown

This is not quite what you asked. Is there a reason that you want the RDP exit before the shutdown?

GobiTodic
Posts: 3
Joined: Wed May 01, 2013 11:10 am

Re: shutdown with rdp logout

Sun May 05, 2013 2:28 pm

Thanks for the response.I connect to a Windows Server 2003 and the user (on the Server) should be logged out while not in use. With Ratpoison it is possible to execute a shutdown via shortcut but then the rdp is just closed and not logged out.
If I understood you right, the sudo halt has to be typed in the remote desktop, but it doesn't work on windows.
Edit: I just tried to bind the shutdown to a shortcut and it works even in the rdp, but the logout still has to be done extra.

User avatar
DaveDriesen
Posts: 113
Joined: Sun Mar 31, 2013 8:28 pm
Location: Top of the food chain
Contact: Website

Re: shutdown with rdp logout

Tue May 07, 2013 8:36 am

Depends.. How did you implement the remmina startup?

Let's look at 2 options for controlling ratpoison startup behaviour:
1. Using ~/.xinitrc
2. Using ~/.ratpoisonrc

1. using ~/.xinitrc
If you are using ~/.xinitrc to start ratpoison and remmina during your X initialisation sequence, then just add the shutdown (or halt, whichever..) command to that file:

Code: Select all

#~/.xinitrc

# Fire up ratpoison in the background (note the trailing ampersand).
exec /usr/bin/ratpoison&

# Run the remmina rdp client. No trailing ampersand here,
# meaning the init script will wait until the command completes.
# (i.e. when you close your rdp session).
/usr/bin/remmina -c /path/to/example_config_file

# Flush file system buffers and shut down the system
sudo sync && sudo poweroff
2. Using ~/ratpoisoinrc
Ratpoison's internal startup sequence can be controlled through a set of rc files. This is useful if you're starting ratpoison in a less controlled way, for example as default window manager for your X session. When ratpoisoin starts, it will try to read ~/.ratpoisonrc -- and if that does not exist /etc/ratpoisonrc -- and execute each command therein when starting up.

You can add commands to ~/.ratpoisonrc or /etc/ratpoisoinrc by editing them in a text editor.

Code: Select all

# Run the remmina rdp client. Note we don't use the ampersand here,
# meaning the init script will wait until the command completes.
# (i.e. when you close your rdp session).
/usr/bin/remmina -c /path/to/example_config_file

# Flush file system buffers and shut down the system
sudo sync && sudo poweroff
Both these examples use a remmina config file to auto-connect to a pre-defined remote system.
You may envision this differently, please implement as desired.

In case you're launching remmina in a different way, then please explain (or use the above method instead).

P.S. if all you need is the RDP session, then you can probably do away with ratpoison entirely:

Code: Select all

#~/.xinitrc
/usr/bin/remmina -c /path/to/example_config_file
sudo sync && sudo poweroff
Try that -- good luck and have fun!

Dave Driesen
Linux dev and oldskool elite.

GobiTodic
Posts: 3
Joined: Wed May 01, 2013 11:10 am

Re: shutdown with rdp logout

Fri May 10, 2013 11:37 am

thanks for the large reply. I start the remmina profile in the .ratpoisonrc and also added your line for the shutdown but it the I still have to do it manually. I also tried to start remmina in the .xinitrc with the same result.
When I start remmina directly (without ratpoison) the client starts but the cursor is invisible and after I log out of Windows there's only a black screen without cursor or command line and I have to unplug the Raspberry to shut it down.
Edit: I found a solution: I wrote a script which starts xfreerdp (changed from remmina to it because of the cursor integration) and added a wait command which waits for the process to end and afterwards it executes a shutdown.

jubu950
Posts: 1
Joined: Fri Jan 31, 2014 8:15 am

Re: shutdown with rdp logout

Fri Jan 31, 2014 8:17 am

Hi,
please post the wait command. I have the same problem. Tanks.

ricardoalcg
Posts: 5
Joined: Tue Nov 21, 2017 3:45 pm

Re: shutdown with rdp logout

Tue Nov 21, 2017 3:54 pm

Hi. I am having the same problem.
I have the rdesktop starting automaticly in the startup and I would like that the raspberry also shutdown when the rdesktop close after the rdp logoff.


Thank you

Return to “Beginners”