diff options
author | Jeff Bailey <jbailey@ubuntu.com> | 2005-06-30 00:07:32 +0000 |
---|---|---|
committer | Jeff Bailey <jbailey@ubuntu.com> | 2005-06-30 00:07:32 +0000 |
commit | 2777a4e8f7b7e7b14cbba813d3b1e30b1acb4a53 (patch) | |
tree | 1dfdf5411183912297af082910e734a2b7e8fe24 /docs/example_hook | |
parent | 2c72958bfc090b046e21e9eaad9134235095ad30 (diff) |
* 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
Diffstat (limited to 'docs/example_hook')
-rw-r--r-- | docs/example_hook | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/docs/example_hook b/docs/example_hook new file mode 100644 index 0000000..27582a7 --- /dev/null +++ b/docs/example_hook @@ -0,0 +1,111 @@ +#!/bin/sh + +# +# This is an example hook script. It will be run by 'mkinitramfs' +# when it creates the image. It's job is to decide which files to +# install, then install them into the staging area, where the +# initramfs is being created. This happens when a new 'linux-image' +# package is installed, or when the administrator runs 'mkinitramfs' +# by hand to update an initramfs image. +# +# TODO: What about the case where you install something that should be +# added to the initramfs, but the linux-image it relates to has +# already been installed previously? Does this happen often +# enough that it needs to be handled? How can it be handled? +# +# * Think about the 'usplash'. The initramfs will need to be +# updated if a theme change or update is desired. Maybe it +# should not be totally automatic, but offered on upgrade +# predicated on a user response to a debconf question? That +# issue needs to be explored and a solution specified. +# +# * Do not assume that any needed subdirectories have been created +# yet, but don't bail out if they are already there. +# +# * All of the standard system tools are available, of course, since +# this hook is running in the real system, not the initramfs. +# +# * TODO: ... ? Anything else to tell them in this bullet-list? +# + +# +# The environment contains at least: +# +# CONFDIR -- usually /etc/mkinitramfs, can be set on mkinitramfs +# command line. +# +# DESTDIR -- The staging directory where we are building the image. +# +# TODO: Decide what environment variables are meaningful and defined +# in this context, then document them as part of the interface. +# + + +# +# 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 + + +# You can do anything you need to from here on. +# + +# Source the optional 'hook-functions' scriptlet, if you need the +# functions defined within it: +# +# . /usr/share/initramfs-tools/hook-functions + + +# If this is a conffile, it must take care to do the right thing when +# the package containing it is removed but not purged. There of +# course may be other reasons to have custom logic deciding what to +# install. +# +if [ -x /usr/bin/myprog ]; then + install -D /usr/bin/myprog ${DESTDIR}/usr/bin +fi + +# To accompany this, there should usually be a script for inside the +# initramfs named something like: +# +# "/etc/mkinitramfs/local-premount/myprog" +# +# ... and it should do what is necessary to have 'myprog' get run +# inside the early runtime environment. + +# Handle an error: +# +if [ -n "$an_error_occured" ]; +then + # + # TODO: Do we need 'warn()', 'error()', and/or 'fatal()' for this? + # + 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 'mkinitramfs' + # pass or fail. Consider naming the error values with + # mnemonic symbols rather than magic numbers. They may or + # may not be the same set of errors as the set for + # in-initramfs scripts. + # +fi + +exit 0 + |