home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / initramfs-tools / examples / example_script < prev    next >
Encoding:
Text File  |  2005-08-16  |  2.6 KB  |  91 lines

  1. #!/bin/sh
  2.  
  3. #
  4. # This script is run inside of the initramfs environment during the
  5. # system boot process.  It is installed there by 'mkinitramfs'.  The
  6. # package that owns it may opt to install it in either an appropriate
  7. # location under "/usr/share/initramfs-tools/scripts/", or a similar
  8. # location under "/etc/mkinitramfs/scripts/", depending upon whether
  9. # it should be considered to be a user modifiable conffile or not.
  10. #
  11. # TODO: How do we deal with the case where the package that installed
  12. #    this has been removed but not purged, if we always arbitrarily
  13. #    copy all of these scripts into the initramfs?
  14. #
  15. #  * The available toolset is limited inside this environment...
  16. #
  17. #    TODO: document that toolset in the man page.
  18. #
  19. #  * /dev, /proc, and /sys are already mounted.  / is a ?? ro/rw
  20. #    filesystem... etc. more documentation.
  21. #
  22. #  * It is expected that /proc and /sys will be umounted before
  23. #    changing over to the real root file system, so you must not keep
  24. #    any files open on them beyond these scripts.
  25. #
  26. #  * You may like to strip these documentation comments from this
  27. #    example if you take it for a template, to save a little space in
  28. #    the initramfs, since nobody will ever read it from inside of
  29. #    there anyhow.
  30. #
  31.  
  32. #
  33. # The environment contains at least the following variables:
  34. #
  35. # TODO: Decide what environment variables are meaningful and defined
  36. #    in this context, then document them as part of the interface.
  37. #
  38. # Because this script will be run as a full separate process, rather
  39. # than sourced inside the context of the driver script, if it needs to
  40. # pass information to another script that may run after it, it must do
  41. # so by writing data to a file location known to both scripts.  Simply
  42. # setting an environment variable will not work.
  43. #
  44.  
  45. #
  46. # List the soft prerequisites here.  This is a space separated list of
  47. # names, of scripts that are in the same directory as this one, that
  48. # must be run before this one can be.
  49. #
  50. PREREQ=""
  51.  
  52. prereqs()
  53. {
  54.     echo "$PREREQ"
  55. }
  56.  
  57. case $1 in
  58. # get pre-requisites
  59. prereqs)
  60.     prereqs
  61.     exit 0
  62.     ;;
  63. esac
  64.  
  65. # Do the work here.
  66.  
  67. echo "Got here!"
  68.  
  69. # Handle an error:
  70.  
  71. if [ -n "$an_error_occured" ];
  72. then
  73.     # 
  74.     # TODO: Do we need 'warn()', 'error()', and/or 'fatal()' for this?
  75.     # I think we ultimately do, and that they need to be in their own
  76.     # well-documented location so that an overlay can override them.
  77.     # Think 'usplash' progress updates.
  78.     # 
  79.     echo "An error occured in $0: $an_error_occured" >&2
  80.     exit 1
  81.     #
  82.     # TODO: Decide if different error codes are meaningful, what they
  83.     #    mean, and what the semantics of them are wrt 'init' pass
  84.     #    or panic.  Consider naming the error values with mnemonic
  85.     #    symbols rather than magic numbers.
  86.     #
  87. fi
  88.  
  89. exit 0
  90.  
  91.