]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/kernel-install/kernel-install
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/>.
27 echo " $0 add KERNEL-VERSION KERNEL-IMAGE"
28 echo " $0 remove KERNEL-VERSION"
33 local suffix
=$1; shift
37 readarray
-t files
<<<"$(
39 for i in "$d/"*"$suffix"; do
40 if [[ -e "$i" ]]; then
47 for f
in "${files[@]}"; do
49 if [[ -e "$d/$f" ]]; then
60 if [ "$i" == "--help" -o "$i" == "-h" ]; then
66 if [[ "${0##*/}" == 'installkernel' ]]; then
76 if [[ -f /etc
/machine-id
]]; then
77 read MACHINE_ID
< /etc
/machine-id
80 if ! [[ $MACHINE_ID ]]; then
81 echo "Could not determine your machine ID from /etc/machine-id." >&2
82 echo "Please run 'systemd-machine-id-setup' as root. See man:machine-id(5)" >&2
86 if [[ ! $COMMAND ]] ||
[[ ! $KERNEL_VERSION ]]; then
87 echo "Not enough arguments" >&2
91 if [[ -d /efi
/loader
/entries
]] ||
[[ -d /efi
/$MACHINE_ID ]]; then
92 BOOT_DIR_ABS
="/efi/$MACHINE_ID/$KERNEL_VERSION"
93 elif [[ -d /boot
/loader
/entries
]] ||
[[ -d /boot
/$MACHINE_ID ]]; then
94 BOOT_DIR_ABS
="/boot/$MACHINE_ID/$KERNEL_VERSION"
95 elif [[ -d /boot
/efi
/loader
/entries
]] ||
[[ -d /boot
/efi
/$MACHINE_ID ]]; then
96 BOOT_DIR_ABS
="/boot/efi/$MACHINE_ID/$KERNEL_VERSION"
97 elif mountpoint
-q /efi
; then
98 BOOT_DIR_ABS
="/efi/$MACHINE_ID/$KERNEL_VERSION"
99 elif mountpoint
-q /boot
/efi
; then
100 BOOT_DIR_ABS
="/boot/efi/$MACHINE_ID/$KERNEL_VERSION"
102 BOOT_DIR_ABS
="/boot/$MACHINE_ID/$KERNEL_VERSION"
107 readarray
-t PLUGINS
<<<"$(
108 dropindirs_sort ".
install" \
109 "/etc
/kernel
/install.d
" \
110 "/usr
/lib
/kernel
/install.d
"
115 if [[ ! "$KERNEL_IMAGE" ]]; then
116 echo "Command 'add' requires an argument" >&2
120 mkdir
-p "$BOOT_DIR_ABS" ||
{
121 echo "Could not create boot directory '$BOOT_DIR_ABS'." >&2
125 for f
in "${PLUGINS[@]}"; do
127 "$f" add
"$KERNEL_VERSION" "$BOOT_DIR_ABS" "$KERNEL_IMAGE"
129 if [[ $x == $SKIP_REMAINING ]]; then
138 for f
in "${PLUGINS[@]}"; do
140 "$f" remove
"$KERNEL_VERSION" "$BOOT_DIR_ABS"
142 if [[ $x == $SKIP_REMAINING ]]; then
149 rm -rf "$BOOT_DIR_ABS"
154 echo "Unknown command '$COMMAND'" >&2