| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 # | 2 # |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 # | 6 # |
| 7 # This attempts to guide linux users through the process of putting a recovery | 7 # This attempts to guide linux users through the process of putting a recovery |
| 8 # image onto a removeable USB drive. | 8 # image onto a removeable USB drive. |
| 9 # | 9 # |
| 10 # We may not need root privileges if we have the right permissions. | 10 # We may not need root privileges if we have the right permissions. |
| 11 # | 11 # |
| 12 set -eu | 12 set -eu |
| 13 | 13 |
| 14 ############################################################################## | 14 ############################################################################## |
| 15 # Configuration goes here | 15 # Configuration goes here |
| 16 | 16 |
| 17 # Where should we do our work? Use 'WORKDIR=' to make a temporary directory, | 17 # Where should we do our work? Use 'WORKDIR=' to make a temporary directory, |
| 18 # but using a persistent location may let us resume interrupted downloads or | 18 # but using a persistent location may let us resume interrupted downloads or |
| 19 # run again without needing to download a second time. | 19 # run again without needing to download a second time. |
| 20 WORKDIR=${WORKDIR:-/tmp/tmp.crosrec} | 20 WORKDIR=${WORKDIR:-/tmp/tmp.crosrec} |
| 21 | 21 |
| 22 # Where do we look for the config file? Note that we can override this by just | 22 # Where do we look for the config file? We can override this for debugging by |
| 23 # specifying the config file URL on the command line. | 23 # specifying "--config URL" on the command line, but curl and wget may handle |
| 24 CONFIGURL="${1:-https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.conf}
" | 24 # file URLs differently. |
| 25 CONFIGURL="${2:-https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.conf}
" |
| 25 | 26 |
| 26 # Device to put this stuff on, perhaps the user knows best? | 27 # Device to put this stuff on, perhaps the user knows best? |
| 27 DEVICE="${DEVICE:-}" | 28 DEVICE="${DEVICE:-}" |
| 28 | 29 |
| 29 # What version is this script? It must match the 'recovery_tool_version=' value | 30 # What version is this script? It must match the 'recovery_tool_version=' value |
| 30 # in the config file that we'll download. | 31 # in the config file that we'll download. |
| 31 MYVERSION='0.9.2' | 32 MYVERSION='0.9.2' |
| 32 | 33 |
| 33 | 34 |
| 34 ############################################################################## | 35 ############################################################################## |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 if [ -n "$DISKUTIL" ]; then | 781 if [ -n "$DISKUTIL" ]; then |
| 781 diskutil unmountDisk "$1" || ufatal "Unable to unmount $1." | 782 diskutil unmountDisk "$1" || ufatal "Unable to unmount $1." |
| 782 else | 783 else |
| 783 umount "$1" || ufatal "Unable to unmount $1." | 784 umount "$1" || ufatal "Unable to unmount $1." |
| 784 fi | 785 fi |
| 785 } | 786 } |
| 786 | 787 |
| 787 ############################################################################## | 788 ############################################################################## |
| 788 # Okay, do something... | 789 # Okay, do something... |
| 789 | 790 |
| 791 # Warn about usage |
| 792 if [ -n "${1:-}" ] && [ "$1" != "--config" ]; then |
| 793 echo "This program takes no arguments. Just run it." |
| 794 # That's not really true. For debugging you can specify "--config URL". |
| 795 exit 1 |
| 796 fi |
| 797 |
| 790 # Make sure we have the tools we need | 798 # Make sure we have the tools we need |
| 791 require_utils | 799 require_utils |
| 792 | 800 |
| 793 # Need a place to work. We prefer a fixed location so we can try to resume any | 801 # Need a place to work. We prefer a fixed location so we can try to resume any |
| 794 # interrupted downloads. | 802 # interrupted downloads. |
| 795 if [ -n "$WORKDIR" ]; then | 803 if [ -n "$WORKDIR" ]; then |
| 796 if [ ! -d "$WORKDIR" ] && ! mkdir "$WORKDIR" ; then | 804 if [ ! -d "$WORKDIR" ] && ! mkdir "$WORKDIR" ; then |
| 797 warn "Using temporary directory" | 805 warn "Using temporary directory" |
| 798 WORKDIR= | 806 WORKDIR= |
| 799 fi | 807 fi |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 prompt "Shall I remove the temporary files now? [y/n] " | 929 prompt "Shall I remove the temporary files now? [y/n] " |
| 922 read tmp | 930 read tmp |
| 923 case $tmp in | 931 case $tmp in |
| 924 [Yy]*) | 932 [Yy]*) |
| 925 cd | 933 cd |
| 926 \rm -rf ${WORKDIR} | 934 \rm -rf ${WORKDIR} |
| 927 ;; | 935 ;; |
| 928 esac | 936 esac |
| 929 | 937 |
| 930 exit 0 | 938 exit 0 |
| OLD | NEW |