initramfs-tools/docs/example_script
Jeff Bailey 2c72958bfc * Use detailed logging now for debian/changelog. We have at least
three people hacking now, and details would probably be useful.

  * debian/TODO: Update

  * debian/dirs: Sort and add usr/share/initramfs-tools/hooks

  * debian/initramfs-tools.examples: Add docs/example_hook and
    docs/example_hook_cpiogz

  * debian/initramfs-tools.install: Pretty Print.

  * debian/rules: Ensure that mkinitramfs is executable

  * docs/example_script: New file

  * init: Add concept of 'quiet', be verbose if not specified

  * mkinitramfs: Do not load script functions until needed
    Clear up comments / documentation
    Use DESTDIR instead of TMPDIR
    Add ability to link in extra hunks into the cpio file
    Cosmetic cleanups

  * scripts/functions: Add lsb stype log_FOO_msg functions

  * scripts/local: Add logging

  * scripts/nfs: Add logging
2005-06-30 00:05:01 +00:00

91 lines
2.6 KiB
Bash

#!/bin/sh
#
# This script is run inside of the initramfs environment during the
# system boot process. It is installed there by 'mkinitramfs'. The
# package that owns it may opt to install it in either an appropriate
# location under "/usr/share/initramfs-tools/scripts/", or a similar
# location under "/etc/mkinitramfs/scripts/", depending upon whether
# it should be considered to be a user modifiable conffile or not.
#
# TODO: How do we deal with the case where the package that installed
# this has been removed but not purged, if we always arbitrarily
# copy all of these scripts into the initramfs?
#
# * The available toolset is limited inside this environment...
#
# TODO: document that toolset in the man page.
#
# * /dev, /proc, and /sys are already mounted. / is a ?? ro/rw
# filesystem... etc. more documentation.
#
# * It is expected that /proc and /sys will be umounted before
# changing over to the real root file system, so you must not keep
# any files open on them beyond these scripts.
#
# * You may like to strip these documentation comments from this
# example if you take it for a template, to save a little space in
# the initramfs, since nobody will ever read it from inside of
# there anyhow.
#
#
# The environment contains at least the following variables:
#
# TODO: Decide what environment variables are meaningful and defined
# in this context, then document them as part of the interface.
#
# Because this script will be run as a full separate process, rather
# than sourced inside the context of the driver script, if it needs to
# pass information to another script that may run after it, it must do
# so by writing data to a file location known to both scripts. Simply
# setting an environment variable will not work.
#
#
# List the soft prerequisites here. This is a space separated list of
# names, of scripts that are in the same directory as this one, that
# must be run before this one can be.
#
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
# Do the work here.
echo "Got here!"
# Handle an error:
if [ -n "$an_error_occured" ];
then
#
# TODO: Do we need 'warn()', 'error()', and/or 'fatal()' for this?
# I think we ultimately do, and that they need to be in their own
# well-documented location so that an overlay can override them.
# Think 'usplash' progress updates.
#
echo "An error occured in $0: $an_error_occured" >&2
exit 1
#
# TODO: Decide if different error codes are meaningful, what they
# mean, and what the semantics of them are wrt 'init' pass
# or panic. Consider naming the error values with mnemonic
# symbols rather than magic numbers.
#
fi
exit 0