summarylogtreecommitdiffstats
path: root/kernel-install.sh
blob: 597108f6b43a9dc541a49aedc15731832c97b375 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash

set -euo pipefail
# Inherit set -e down to command substitutions
shopt -s inherit_errexit

extract_kernel_version() {
	local heads
	heads="${1%/vmlinuz}"
	echo "${heads##*/}"
}

kernel_images=()

while read -r path; do
	case "$path" in
	usr/lib/modules/*/vmlinuz)
		kernel_images+=("/$path")
		;;
	*)
		kernel_images+=(/usr/lib/modules/*/vmlinuz)
		break
		;;
	esac
done

add=0
for o; do
	case "$o" in
	add)
		add=1
		;;
	esac
done

for kernel_image in "${kernel_images[@]}"; do
	echo +kernel-install "$@" "$(extract_kernel_version "$kernel_image")" "$kernel_image"
	kernel-install "$@" "$(extract_kernel_version "$kernel_image")" "$kernel_image" || true
done