Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a small internet cafe with 7-9 Ubuntu 12.04 workstations. Unfortunately, I can't be there every week.

I've seen a Java solution to upgrade the system, after a normal (non-sudo/admin) user requests a shut down (but not restart!) the system upgrades itself - the base system is Ubuntu 10.04 as I remember, but the programs, and the desktop manager is fully customized, with custom softwares (eg. to check the printers' ink level...)

That's why I thought, that if I could set up something similar in our environment, it would be very useful. I've already scripted in Bash, and used Zenity, so I only want to know:

  1. how can I call/run my script?
  2. how can I run root commands(sudo required) inside that script? (eg. sudo poweroff or halt)
share|improve this question

Here is an overview of what you can do.

If you want to check for an upgrade every time the machine is going down you can turn your script into a system v init-script that will run on level 0 (shutdown).

To do this:

  1. change your script to be an init script. Quick example -
  2. put it in /etc/init.d/
  3. create a symlink like: /etc/rc0.d/K01myscipt -> /etc/init.d/myscript

This will send a stop command (K 01myscript) to your script at the beginning of shutdown process (K 01 myscript - meaning, before others). I'm not sure, but maybe you'll have to cancel shutdown at the beginning of the script - shutdown -c now and issue it again at the end - shutdown -h now.

The script will be executed already as root so you don't need any sudo commands. You just need to have permissions create the mentioned files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.