Debian Codegraph @

docs/example_hook

raw
1 #!/bin/sh
2 #
3 #
4 # This is an example hook script. It will be run by 'mkinitramfs'
5 # when it creates the image. It's job is to decide which files to
6 # install, then install them into the staging area, where the
7 # initramfs is being created. This happens when a new 'linux-image'
8 # package is installed, or when the administrator runs 'mkinitramfs'
9 # by hand to update an initramfs image.
10 #
11 # CONFDIR -- usually /etc/initramfs-tools, can be set on mkinitramfs
12 # command line.
13 #
14 # DESTDIR -- The staging directory where we are building the image.
15 #
16 # see initramfs-tools(7)
17
18 #
19 # List the soft prerequisites here. This is a space separated list of
20 # names, of scripts that are in the same directory as this one, that
21 # must be run before this one can be.
22 #
23 PREREQ=""
24
25 prereqs()
26 {
27 echo "$PREREQ"
28 }
29
30 case $1 in
31 # get pre-requisites
32 prereqs)
33 prereqs
34 exit 0
35 ;;
36 esac
37
38
39 # You can do anything you need to from here on.
40 #
41
42 # Source the optional 'hook-functions' scriptlet, if you need the
43 # functions defined within it. Read it to see what is available to
44 # you. It contains functions for copying dynamically linked program
45 # binaries, and kernel modules into the DESTDIR.
46 #
47 . /usr/share/initramfs-tools/hook-functions
48
49
50 # If this hook script is a conffile (and thus stored in
51 # /etc/mkinitramfs/hooks), it must take care to do the right thing
52 # when the package containing it is removed but not purged. There of
53 # course may be other reasons to have custom logic deciding what to
54 # install. The version variable may be useful for this.
55 #
56 if command -v myprog >/dev/null 2>&1; then
57 copy_exec /usr/bin/myprog usr/bin
58 fi
59
60 # To accompany this, there should usually be a script for inside the
61 # initramfs named something like:
62 #
63 # "/etc/mkinitramfs/local-premount/myprog"
64 #
65 # ... and it should do what is necessary to have 'myprog' get run
66 # inside the early runtime environment.
67
68 exit 0