| OLD | NEW | 
|   1 #!/bin/sh -u |   1 #!/bin/sh -u | 
|   2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |   2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 
|   3 # Use of this source code is governed by a BSD-style license that can be |   3 # Use of this source code is governed by a BSD-style license that can be | 
|   4 # found in the LICENSE file. |   4 # found in the LICENSE file. | 
|   5 # |   5 # | 
|   6 # A script to display or change the preferred image |   6 # A script to display or change the preferred image | 
|   7  |   7  | 
|   8 # Load functions and constants for chromeos-install. |   8 # Load functions and constants for chromeos-install. | 
|   9 . "$(dirname "$0")/chromeos-common.sh" || exit 1 |   9 . "$(dirname "$0")/chromeos-common.sh" || exit 1 | 
|  10 . /usr/lib/shflags || exit 1 |  10 . /usr/lib/shflags || exit 1 | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
|  41 # Don't run this as root |  41 # Don't run this as root | 
|  42 dont_run_as_root |  42 dont_run_as_root | 
|  43  |  43  | 
|  44 # Check out the dst device. |  44 # Check out the dst device. | 
|  45 if [ ! -b "$FLAGS_dst" ] |  45 if [ ! -b "$FLAGS_dst" ] | 
|  46 then |  46 then | 
|  47   echo "Error: Unable to find block device: $FLAGS_dst" |  47   echo "Error: Unable to find block device: $FLAGS_dst" | 
|  48   exit 1 |  48   exit 1 | 
|  49 fi |  49 fi | 
|  50  |  50  | 
|  51  |  | 
|  52 # Mount the EFI System Partition |  51 # Mount the EFI System Partition | 
|  53 mountpoint=$(mktemp -d  /tmp/mountesp_XXXXXXXXX) |  52 mountpoint=$(mktemp -d  /tmp/mountesp_XXXXXXXXX) | 
|  54 tempfile=$(mktemp /tmp/grubcfg_XXXXXXXXX) |  53 tempfile=$(mktemp /tmp/grubcfg_XXXXXXXXX) | 
|  55 sudo mount ${FLAGS_dst}12 ${mountpoint} |  54 sudo mount ${FLAGS_dst}12 ${mountpoint} | 
|  56  |  55  | 
|  57 # Make the change |  56 # Make the change | 
|  58 if [ -n "${newimg:-}" ]; then |  57 if [ -n "${newimg:-}" ]; then | 
|  59   sed -e "s/^set default=.*/set default=$newimg/" \ |  58   echo "Update boot default to menu item $newimg" | 
 |  59   sed -e "s/^set default=.*/set default=${newimg}/" \ | 
|  60     ${mountpoint}/efi/boot/grub.cfg > ${tempfile} |  60     ${mountpoint}/efi/boot/grub.cfg > ${tempfile} | 
|  61   sudo cp ${tempfile} ${mountpoint}/efi/boot/grub.cfg |  61   sudo cp ${tempfile} ${mountpoint}/efi/boot/grub.cfg | 
|  62 fi |  62 fi | 
|  63  |  63  | 
 |  64 echo "Current boot default is:" | 
|  64 # Print the [new] default choice |  65 # Print the [new] default choice | 
|  65 grep -qs '^set default=0' ${mountpoint}/efi/boot/grub.cfg && echo "A" |  66 grep -qs '^set default=0' ${mountpoint}/efi/boot/grub.cfg && echo "A" | 
|  66 grep -qs '^set default=1' ${mountpoint}/efi/boot/grub.cfg && echo "B" |  67 grep -qs '^set default=1' ${mountpoint}/efi/boot/grub.cfg && echo "B" | 
|  67  |  68  | 
|  68 # Clean up |  69 # Clean up | 
|  69 sudo umount ${mountpoint} |  70 sudo umount ${mountpoint} | 
|  70 rm -f ${tempfile} |  71 rm -f ${tempfile} | 
|  71 rmdir ${mountpoint} |  72 rmdir ${mountpoint} | 
| OLD | NEW |