diff options
| author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-05-23 03:49:11 -0400 |
|---|---|---|
| committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-05-23 03:49:11 -0400 |
| commit | f6005265512004afaf72d7e873fb6702af8a453c (patch) | |
| tree | edaf78aba840a0e5368c5efc317b842d766c8876 /bootkernel.grub | |
assorted utilities from the LITMUS project
Diffstat (limited to 'bootkernel.grub')
| -rwxr-xr-x | bootkernel.grub | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/bootkernel.grub b/bootkernel.grub new file mode 100755 index 0000000..8256f62 --- /dev/null +++ b/bootkernel.grub | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # Copyright (c) 2007, Bjoern B. Brandenburg <bbb [at] cs.unc.edu> | ||
| 4 | # All rights reserved. | ||
| 5 | # | ||
| 6 | # Redistribution and use in source and binary forms, with or without | ||
| 7 | # modification, are permitted provided that the following conditions are met: | ||
| 8 | # * Redistributions of source code must retain the above copyright | ||
| 9 | # notice, this list of conditions and the following disclaimer. | ||
| 10 | # * Redistributions in binary form must reproduce the above copyright | ||
| 11 | # notice, this list of conditions and the following disclaimer in the | ||
| 12 | # documentation and/or other materials provided with the distribution. | ||
| 13 | # * Neither the name of the copyright holder nor the | ||
| 14 | # names of its contributors may be used to endorse or promote products | ||
| 15 | # derived from this software without specific prior written permission. | ||
| 16 | # | ||
| 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
| 21 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
| 22 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
| 23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
| 24 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
| 25 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
| 26 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
| 27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 28 | # | ||
| 29 | # | ||
| 30 | |||
| 31 | MENU="/boot/grub/menu.lst" | ||
| 32 | |||
| 33 | |||
| 34 | BACK="(c) 2007 Bjoern Brandenburg" | ||
| 35 | TITLE="GRUB Boot Kernel Selector v0.1" | ||
| 36 | |||
| 37 | TMPFILE=`mktemp` | ||
| 38 | (egrep '^title' $MENU | sed 's/title *//' | awk ' | ||
| 39 | BEGIN {c = 0} \ | ||
| 40 | {print c " \"" $0 "\""; c++ } \ | ||
| 41 | |||
| 42 | ' | xargs dialog --title "$TITLE" --backtitle "$BACK" \ | ||
| 43 | --cancel-label "Keep old default" --ok-label "Select new default" \ | ||
| 44 | --menu "Choose default kernel: " 23 60 16 ) 2> $TMPFILE | ||
| 45 | OK=$? | ||
| 46 | |||
| 47 | clear | ||
| 48 | |||
| 49 | if [[ $OK == 0 ]]; then | ||
| 50 | CHOICE=`cat $TMPFILE` | ||
| 51 | sed -ibak "s/^default *[0123456789]\+$/default $CHOICE/" $MENU | ||
| 52 | echo "New default set to ${CHOICE}." | ||
| 53 | else | ||
| 54 | echo "Keeping old default kernel." | ||
| 55 | fi | ||
| 56 | |||
| 57 | rm $TMPFILE | ||
| 58 | |||
