diskimage-builder/elements/dracut-ramdisk/post-install.d/01-ensure-drivers
Ben Nemec 6377c723aa Allow elements to add drivers to dracut
It is reasonable that elements may need to include additional
kernel modules in a dracut ramdisk.  This is done with the
--add-drivers option to dracut, but previously the value passed
was hard-coded.

This change allows an element to put a file containing its desired
drivers in a dracut-drivers.d directory, and the list there will
be added to the list of drivers added.  This functions in
essentially the same way as the binary-deps.d directory that
already exists for including additional executables in a ramdisk.

Change-Id: Ie892b908d36c175a469f7cde7dd803ad4b1942b6
2015-03-18 11:40:20 -05:00

30 lines
625 B
Bash
Executable File

#!/bin/bash
set -eu
set -o pipefail
if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then
set -x
fi
TARGET_DIR="/tmp/in_target.d/"
EXTRA_DRIVERS=
for _FILE in $(ls ${TARGET_DIR}/dracut-drivers.d/) ; do
_FILE="${TARGET_DIR}/dracut-drivers.d/${_FILE}"
if [ -s $_FILE ]; then
for _LINE in $(cat $_FILE) ; do
EXTRA_DRIVERS="${EXTRA_DRIVERS} $_LINE"
done
fi
done
if [ "$EXTRA_DRIVERS" = "" ]; then
echo "No extra drivers found"
else
DRIVERS_OUTPUT="/etc/dib_dracut_drivers"
echo "Creating extra drivers record at: ${DRIVERS_OUTPUT}"
echo "$EXTRA_DRIVERS" >${DRIVERS_OUTPUT}
fi