By stuart237289
Is there some event I can hook into / listen for, like an Upstart event for ACPI poweroff, to broadcast a wall when the system is going down for restore?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Callbacks can be done a number of ways, but it is very trivial to add a script to fire on a specific runlevel. For instance, in Ubuntu, you have the following http://en.wikipedia.org/wiki/Runlevel#Ubuntu
A simple solution, would be to install / configure “postfix” and have a bash script run the ‘mail’ command found in the mail-utils package. If you’re going to power off the machine, you can place the script in /etc/rc0.d/ This of course, is run-level 0 or “halt”. If you do an ‘ls -lt’ in that directory, you’ll notice that there are symlinks:
ls -lt
total 4.0K
lrwxrwxrwx 1 root root 17 Aug 26 13:28 K09apache2 -> ../init.d/apache2*
lrwxrwxrwx 1 root root 18 Aug 5 16:54 K79quotarpc -> ../init.d/quotarpc*
lrwxrwxrwx 1 root root 15 Aug 5 16:54 K85quota -> ../init.d/quota*
lrwxrwxrwx 1 root root 17 Jul 9 13:42 K08tomcat7 -> ../init.d/tomcat7*
lrwxrwxrwx 1 root root 20 May 20 12:39 K20virtualbox -> ../init.d/virtualbox*
lrwxrwxrwx 1 root root 29 May 20 12:31 K10unattended-upgrades -> ../init.d/unattended-upgrades*
lrwxrwxrwx 1 root root 20 May 20 12:23 S35networking -> ../init.d/networking*
lrwxrwxrwx 1 root root 18 May 20 12:23 S20sendsigs -> ../init.d/sendsigs*
lrwxrwxrwx 1 root root 22 May 20 12:23 S31umountnfs.sh -> ../init.d/umountnfs.sh*
lrwxrwxrwx 1 root root 18 May 20 12:23 S40umountfs -> ../init.d/umountfs*
lrwxrwxrwx 1 root root 20 May 20 12:23 S60umountroot -> ../init.d/umountroot*
lrwxrwxrwx 1 root root 14 May 20 12:23 S90halt -> ../init.d/halt*
lrwxrwxrwx 1 root root 17 May 20 12:23 S30urandom -> ../init.d/urandom*
-rw-r--r-- 1 root root 353 Jul 26 2012 README
What I would do, is find a logical place to store your callback script and symlink it here.
-Johnny Starr www.thestarrlab.com
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.