summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Kenna <cjk@cs.unc.edu>2012-10-02 17:20:55 -0400
committerChristopher Kenna <cjk@cs.unc.edu>2012-10-02 17:20:55 -0400
commit5a93f97a326c150fe7980fd98f5c99a0a54aec9b (patch)
treed895a738e2c2065fb594d0e48933303fafca83e4
parent9b87a0798fab4390add9eedc04cf3a8df99272e3 (diff)
Add kernel installer script for Pound.
-rwxr-xr-xpound-install-kernel.sh101
1 files changed, 101 insertions, 0 deletions
diff --git a/pound-install-kernel.sh b/pound-install-kernel.sh
new file mode 100755
index 0000000..3da43ec
--- /dev/null
+++ b/pound-install-kernel.sh
@@ -0,0 +1,101 @@
1#!/bin/bash
2
3set -e
4set -u
5
6GRUBCFG=/etc/grub.d/40_custom
7
8# initramfs state directory (Debian/Ubuntu)
9INITRAMFS_STATEDIR="/var/lib/initramfs-tools"
10
11error() {
12 echo "$@" >&2
13 exit 1
14}
15
16if [ $# -ne 1 ] ; then
17 error "Usage: `basename $0` <KDIR>"
18fi
19
20KERN_DIR=$1
21
22if [ ! -d "$KERN_DIR" ] ; then
23 error "Bad kernel directory."
24fi
25
26getversion() {
27 local version
28 version=$(cat $KERN_DIR/include/config/kernel.release)
29 if [ "x" = "x$version" ] ; then
30 error "Could not determine version"
31 fi
32 echo "$version"
33}
34
35moveconfig() {
36 echo "Moving config file to /boot ..." >&2
37 sudo cp .config /boot/config-$KVERSION
38 echo "done." >&2
39}
40
41copyvmlinuz() {
42 echo "Copying vmlinuz to /boot ..." >&2
43 sudo cp "$KERN_DIR/arch/x86/boot/bzImage" /boot/vmlinuz-$KVERSION
44 echo "done." >&2
45}
46
47doinitramfs() {
48 local initrdimage
49 initrdimage="/boot/initrd.img-$KVERSION"
50
51 if [ -e "$INITRAMFS_STATEDIR/$KVERSION" -o -e "$initrdimage" ] ; then
52 echo "Removing old initramfs ... " >&2
53 sudo update-initramfs -k $KVERSION -d
54 echo "done." >&2
55 fi
56
57 echo "Creating initramfs (ignore module errors) ... " >&2
58 sudo update-initramfs -k $KVERSION -c
59 echo "done." >&2
60}
61
62installgrubmenuentry() {
63 local entryname
64 entryname=$1
65 sudo tee -a "$GRUBCFG" > /dev/null <<EOF
66menuentry '$entryname' --class gnu-linux --class gnu --class os {
67 recordfail
68 gfxmode \$linux_gfx_mode
69 insmod gzio
70 insmod part_gpt
71 insmod ext2
72 set root='(hd0,gpt2)'
73 search --no-floppy --fs-uuid --set=root 1550ea21-685f-4e70-922c-e1749db48e24
74 linux /boot/vmlinuz-$KVERSION root=UUID=1550ea21-685f-4e70-922c-e1749db48e24 ro
75 initrd /boot/initrd.img-$KVERSION
76}
77EOF
78}
79
80KVERSION=$(getversion)
81
82moveconfig
83copyvmlinuz
84doinitramfs
85
86entryname="LITMUS $KVERSION"
87set +e
88_unused=$(grep "$entryname" "$GRUBCFG")
89retval=$?
90set -e
91if [ $retval -ne 0 ] ; then
92 echo "Installing grub menuentry ..." >&2
93 installgrubmenuentry "$entryname"
94 echo "done."
95else
96 echo "Grub menuentry seems to exist already." >&2
97fi
98
99sudo update-grub
100
101echo "You need to grub-set-default manually." >&2