3

Background: I'm looking to put a series of Ubuntu machines into retail locations, they're being used as dumb kiosks to show a series of slides onto large LCD panel TV screens. Once installed, they won't have a keyboard or mouse connected but will have a fixed IP on the local network. Everything is configured to auto-start, no automatic updates, no power saving etc - I think we're pretty-much good to go apart from one thing. I need the retail staff to be able to restart the boxes if a problem arises.

We have VNC running (now that we've turned off desktop enhancements!) so that we can remotely get into the machines if we need to, but that's not something we would allow the retail staff to do. The machines are going to be physically 'out of the way' (probably in the ceiling space) so the power button is not easily accessible!.

I'd like to have some means of allowing the retail staff to restart the Ubuntu machine, from the desktop of one of their Windows terminals. I don't really want to give them some kind of raw terminal access (the command line will frighten them!) and I don't want them to use VNC (as stated above). Ideally there would be an icon on the Windows desktop, they double-click it, reply to a simple 'are you sure?' prompt, and then the Ubuntu box is told to restart. The Windows side of that won't be a problem, we can write something using Delphi, Python & Qt4, whatever - it's the Ubuntu side of it I'm stuck with.

Out of sight/view, could I have a Windows program open a terminal across the network and tell Ubuntu to restart? Is this what SSH could be used for (I have never set that kind of thing up). The Windows programming side isn't really an issue, it's just that I'm a total Ubuntu noob and don't know where to start from the platform point of view.

The other thing we considered is also having the machine automatically restart itself at a set time each day (obviously out of store hours!). To me, that seems a bit unnecessary (though forcing a restart once a week/month might be worthwhile).

Any thoughts or suggestions? Being able to restart the box on demand across the network is my prime requirement.

3 Answers 3

3

Out of sight/view, could I have a Windows program open a terminal across the network and tell Ubuntu to restart? Is this what SSH could be used for[?]

Yes. That's effectively how I'd do it. First step is you'll want to install Putty on the Windows computers. This allows you to SSH in. But don't worry about that for now. Let's do this backwards, starting from the Ubuntu machine.

I would write a script on the Ubuntu machine to do the restarting. If you can ssh in, chances are you don't need to do a full reboot. You could argue that you "might as well" but it often means the reboot takes four or five times longer than it needed to be; it's just a waste of time.

You should be able to get away with just restarting GDM (sudo restart gdm) so I'd write an interactive Python script that prompts the user to make sure they're sure they want to restart GDM and then restart it. After that, it would wait for five seconds, and then ask them if it's working. If not, do a full reboot (sudo reboot).

Edit: There's also a possibility you might just be able to restart the application that these screens are displaying without even restarting GDM. I don't know what you expect to fall over but assume all three and give the user the option to restart each sequentially, starting with the app, then gdm, then the machine.

You can use curses to make this look prettier.

Next up you need to make sure your ubuntu user can do these root-level commands. Run sudoedit /etc/sudoers and add something like this:

Cmnd_Alias REBOOT = /sbin/reboot
Cmnd_Alias RESTART = /sbin/restart

useraccount   ALL=REBOOT
useraccount   ALL=RESTART

Subbing useraccount for the username of the account that would be running this script.

You should be able to log in via SSH and test the script now.

The last piece of the puzzle is hooking up SSH to Ubuntu and running the script automatically. You can use a certificate (it's probably more secure) but for this example I'll just use a plaintext password.

putty.exe [email protected] -pw password -m commands.txt

Obviously sub out useraccount, 1.2.3.4 and password with real values. commands.txt should be a text file on the Windows computer containing something like this:

python my_python_script.py

Note: The path when you login with be /home/useraccount/ so either put your python script in there or alter the path in commands.txt.

Important Note: Putty will close as soon as its command finishes running. That means your Python script MUST be interactive (at least ask "Press Any Key to Continue" before exiting) or the user won't see any output. This is simple enough. You mentioned Python, so I assume you know (or know how to find out) how to do simple prompts. As I said earlier, a simple curses interface would look the most professional.

Important Note 2: Sometimes a machine/software fails to the point where a hard restart is the only option. If you're the computers in a space that is really hard to get to, it's certainly worth considering making sure you have access to their power supply so you can do a "hard off-and-on" as a last resort. Make sure you use a journalling filesystem so the staff don't screw it up if they use this too often and warn the staff that if they don't use it as a last resort, evil circus people will steal their children, etc. There are few things worse than a staffer who smacks the hard-reset button at the smallest hiccough.

2
  • Oli, thanks - that's an /awesome/-looking answer. I'll try it out this evening and report back tomorrow.
    – robsoft
    Aug 23, 2010 at 11:10
  • I didn't get into the aliases etc in the end (though I plan to come back and look at that) - once I'd realised that I could connect to the Ubuntu box and talk to it via SSH from within my Delphi software, I knocked up a little Windows applet that allows them to restart the box. The address, username and password are configuration options and effectively they just have a button with an 'Are You Sure' prompt afterwards. Works a treat - thanks for your invaluable input!
    – robsoft
    Sep 3, 2010 at 9:15
1

If you can configure ssh in the windows machine it should be quite easy. This is what I do right now to execute some remote command from one ubuntu server to another

ssh ip.number.0.28 -i /home/javier/.ssh/id_rsa_web -l javier "cd /home/javier/sincrotod;./sincroniza.py"

The -i part tells ssh to use a certificate instead of using a password login. The command line order to reboot a machine is reboot. You will need to be sure that the user used to log has permission to shut down the machine.

0

http://web.archive.org/web/20100919000947/http://www.lockergnome.com/it/2005/03/11/running-a-program-on-a-remote-server-using-ssh/

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .