-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpound-install-kernel.sh
executable file
·103 lines (83 loc) · 2.03 KB
/
pound-install-kernel.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
set -e
set -u
GRUBCFG=/etc/grub.d/40_custom
# initramfs state directory (Debian/Ubuntu)
INITRAMFS_STATEDIR="/var/lib/initramfs-tools"
error() {
echo "$@" >&2
exit 1
}
if [ $# -ne 1 ] ; then
error "Usage: `basename $0` <KDIR>"
fi
KERN_DIR=$1
if [ ! -d "$KERN_DIR" ] ; then
error "Bad kernel directory."
fi
getversion() {
local version
version=$(cat $KERN_DIR/include/config/kernel.release)
if [ "x" = "x$version" ] ; then
error "Could not determine version"
fi
echo "$version"
}
moveconfig() {
echo "Moving config file to /boot ..." >&2
sudo cp .config /boot/config-$KVERSION
echo "done." >&2
}
copyvmlinuz() {
echo "Copying vmlinuz to /boot ..." >&2
sudo cp "$KERN_DIR/arch/x86/boot/bzImage" /boot/vmlinuz-$KVERSION
echo "done." >&2
}
doinitramfs() {
local initrdimage
initrdimage="/boot/initrd.img-$KVERSION"
if [ -e "$INITRAMFS_STATEDIR/$KVERSION" -o -e "$initrdimage" ] ; then
echo "Removing old initramfs ... " >&2
sudo update-initramfs -k $KVERSION -d
echo "done." >&2
fi
echo "Creating initramfs (ignore module errors) ... " >&2
sudo update-initramfs -k $KVERSION -c
echo "done." >&2
}
installgrubmenuentry() {
local entryname
entryname=$1
sudo tee -a "$GRUBCFG" > /dev/null <<EOF
menuentry '$entryname' --class gnu-linux --class gnu --class os {
recordfail
gfxmode \$linux_gfx_mode
insmod gzio
insmod part_gpt
insmod ext2
set root='(hd0,gpt2)'
search --no-floppy --fs-uuid --set=root 1550ea21-685f-4e70-922c-e1749db48e24
linux /boot/vmlinuz-$KVERSION root=UUID=1550ea21-685f-4e70-922c-e1749db48e24 ro
initrd /boot/initrd.img-$KVERSION
}
EOF
}
KVERSION=$(getversion)
moveconfig
copyvmlinuz
doinitramfs
entryname="LITMUS $KVERSION"
set +e
_unused=$(grep "$entryname" "$GRUBCFG")
retval=$?
set -e
# Ubuntu detects kernels named vmlinuz-* already.
#if [ $retval -ne 0 ] ; then
# echo "Installing grub menuentry ..." >&2
# installgrubmenuentry "$entryname"
# echo "done."
#else
# echo "Grub menuentry seems to exist already." >&2
#fi
sudo update-grub
echo "You need to grub-set-default manually." >&2