2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
5 # This file is part of systemd.
7 # Copyright 2013 Harald Hoyer
9 # systemd is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU Lesser General Public License as published by
11 # the Free Software Foundation; either version 2.1 of the License, or
12 # (at your option) any later version.
14 # systemd is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public License
20 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 echo " $0 add <kernel-version> <kernel-image>" >&2
26 echo " $0 remove <kernel-version> <kernel-image>" >&2
31 local suffix=$1; shift
35 readarray -t files < <(
37 for i in "$d/"*"$suffix"; do
38 if [[ -e "$i" ]]; then
45 for f in "${files[@]}"; do
47 if [[ -e "$d/$f" ]]; then
61 if [[ -f /etc/machine-id ]]; then
62 read MACHINE_ID < /etc/machine-id
65 if ! [[ $MACHINE_ID ]]; then
66 echo "Could not determine your machine ID from /etc/machine-id." >&2
67 echo "Please run 'systemd-machine-id-setup' as root. See man:machine-id(5)" >&2
71 if [[ ! $COMMAND ]] || [[ ! $KERNEL_VERSION ]]; then
76 BOOT_DIR_ABS="/boot/$MACHINE_ID/$KERNEL_VERSION"
79 readarray -t PLUGINS < <(
80 dropindirs_sort ".install" \
81 "/etc/kernel/install.d" \
82 "/usr/lib/kernel/install.d"
87 if [[ ! $KERNEL_IMAGE ]]; then
92 mkdir -p "$BOOT_DIR_ABS" || {
93 echo "Could not create boot directory '$BOOT_DIR_ABS'." >&2
97 for f in "${PLUGINS[@]}"; do
99 "$f" add "$KERNEL_VERSION" "$BOOT_DIR_ABS" "$KERNEL_IMAGE"
106 for f in "${PLUGINS[@]}"; do
108 "$f" remove "$KERNEL_VERSION" "$BOOT_DIR_ABS"
113 rm -rf "$BOOT_DIR_ABS"