MyComputingArt

Articles about computing. What are you interested in?

.htaccess, android, apache, bloxsom, bluetooth, broadcast, case, chat, client-server, command-line, configuration, cool'n'quiet, cooling, cpu, disk suspension, dsl, error, fan, fan controller, file management, firefox, firewall, freeware, google, google earth, gpg, gps, grub, hardware, heatsink, howto, images, internet, jabber, lapping, linux, measurement, messaging, motherboard, mp3, mysql, network, password, pda, perl, phone, programming, programming , qemu, rdp, regex, router, screen recording, script, security, shell, silencing, software, spreadsheet, spyware, system recover, tools, ubuntu, virtualization, visual basic, VMWare, vnc, vpn, web, windows, wireless, xen, xmpp, xp



Execute a command at shutdown

To dismount TrueCrypt volumes at shutdown and reboot time, I created a script, put it in/etc/init.d/ and symlinked it into the needed /etc/rc?.d/ directories using update-rc.d.
Here is the detail:

/etc/init.d/truecrypt:
#!/bin/bash

case "$1" in
  start)
	#do nothing; I will mount the volume I need when I need it
	;;
  stop)
	#dismount all volumes
	truecrypt -d
	;;
  *)
	echo $"Usage: $0 -d"
	exit 1
esac

exit $?
Then I launched this command:
update-rc.d truecrypt stop 25 0 1 6 .
that created these symbolic links:
/etc/rc0.d/K25truecrypt -> ../init.d/truecrypt
/etc/rc1.d/K25truecrypt -> ../init.d/truecrypt
/etc/rc6.d/K25truecrypt -> ../init.d/truecrypt
It means that at runlevel 0, 1 and 6 (halt, single-user and reboot) /etc/init.d/truecrypt stop will be executed after all the scripts with the name starting in K, for kill, and coming before it in alphabetical order.
If I wanted to run a script at start too I would symlink the script like this:
update-rc.d myscript start 25 2 3 4 5 . stop 25 0 1 6 .
It means that at runlevel 2, 3, 4 and 5 (multiuser runlevels) /etc/init.d/myscript start would be executed after all the scripts with the name starting in S, for start, in alphabetical order, and at runlevel 0, 1 and 6 /etc/init.d/myscript stop will be executed.
man init or debian.org for more info about runlevel.

   PDF

Posted by: Z24 | Wed, May 04 2011 | Category: /linux | Permanent link | home
Tagged as: , , , ,


About
About
RSS
rss
Donate
Did I save you time or trouble?

Thanks ;-)
Skin
Categories
Archives
Search
Search MyComputingArt

word word = any word
+word +word = all the words
regexp pattern


Search hardware reviews

Visitors

since August 2006

free counters
since September 2009


Powered by Blosxom
FlagCounter Locations of mycomputingart.com visitors Map

Valid HTML 4.01 Strict    Valid CSS!

http://www.mycomputingart.com/

To contact the webmaster and author write to: info<at>mycomputingart<dot>com
© mycomputingart.com, year(today()).