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"
26 echo " $0 remove KERNEL-VERSION"
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
58 if [ "$i" == "--help" -o "$i" == "-h" ]; then
64 if [[ "${0##*/}" == 'installkernel' ]]; then
74 if [[ -f /etc/machine-id ]]; then
75 read MACHINE_ID < /etc/machine-id
78 if ! [[ $MACHINE_ID ]]; then
79 echo "Could not determine your machine ID from /etc/machine-id." >&2
80 echo "Please run 'systemd-machine-id-setup' as root. See man:machine-id(5)" >&2
84 if [[ ! $COMMAND ]] || [[ ! $KERNEL_VERSION ]]; then
85 echo "Not enough arguments" >&2
89 BOOT_DIR_ABS="/boot/$MACHINE_ID/$KERNEL_VERSION"
92 readarray -t PLUGINS < <(
93 dropindirs_sort ".install" \
94 "/etc/kernel/install.d" \
95 "/usr/lib/kernel/install.d"
100 if [[ ! "$KERNEL_IMAGE" ]]; then
101 echo "Command 'add' requires an argument" >&2
105 mkdir -p "$BOOT_DIR_ABS" || {
106 echo "Could not create boot directory '$BOOT_DIR_ABS'." >&2
110 for f in "${PLUGINS[@]}"; do
112 "$f" add "$KERNEL_VERSION" "$BOOT_DIR_ABS" "$KERNEL_IMAGE"
119 for f in "${PLUGINS[@]}"; do
121 "$f" remove "$KERNEL_VERSION" "$BOOT_DIR_ABS"
126 rm -rf "$BOOT_DIR_ABS"
131 echo "Unknown command '$COMMAND'" >&2