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 install from removable media to hard disk. | 6 # A script to install from removable media to hard disk. |
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 13 matching lines...) Expand all Loading... |
24 "Allow root to run this script (Careful, it won't prompt for a password!)" | 24 "Allow root to run this script (Careful, it won't prompt for a password!)" |
25 DEFINE_boolean yes ${FLAGS_FALSE} \ | 25 DEFINE_boolean yes ${FLAGS_FALSE} \ |
26 "Answer yes to everything" | 26 "Answer yes to everything" |
27 | 27 |
28 # Parse command line | 28 # Parse command line |
29 FLAGS "$@" || exit 1 | 29 FLAGS "$@" || exit 1 |
30 eval set -- "${FLAGS_ARGV}" | 30 eval set -- "${FLAGS_ARGV}" |
31 | 31 |
32 set -e | 32 set -e |
33 | 33 |
34 # Unless you pass --run_as_root, you can't be root when you start this, | 34 # Don't run this as root |
35 # because we want to force you to give the root password as confirmation | 35 dont_run_as_root |
36 # that you're allowed to do it. We don't care what other account you're using; | |
37 # you'll still need to sudo before this works. | |
38 if [ $(id -u) -eq "0" -a "${FLAGS_run_as_root}" -eq "${FLAGS_FALSE}" ] | |
39 then | |
40 echo "Note: You must be the 'chronos' user to run this script. Unless" | |
41 echo "you pass --run_as_root and run as root." | |
42 exit 1 | |
43 fi | |
44 | 36 |
45 # First find the root partition that we are installing from and verify it. | 37 # First find the root partition that we are installing from and verify it. |
46 ROOTDEV=$(rootdev) | 38 ROOTDEV=$(rootdev) |
47 # From root partition to root block device. | 39 # From root partition to root block device. |
48 SRC=$(get_block_dev_from_partition_dev ${ROOTDEV}) | 40 SRC=$(get_block_dev_from_partition_dev ${ROOTDEV}) |
49 REMOVABLE=$(cat /sys/block/${SRC#/dev/}/removable) | 41 REMOVABLE=$(cat /sys/block/${SRC#/dev/}/removable) |
50 if [ "$FLAGS_skip_src_removable" -eq "${FLAGS_FALSE}" -a "$REMOVABLE" != "1" ] | 42 if [ "$FLAGS_skip_src_removable" -eq "${FLAGS_FALSE}" -a "$REMOVABLE" != "1" ] |
51 then | 43 then |
52 echo "Error: Source does not look like a removable device: $SRC" | 44 echo "Error: Source does not look like a removable device: $SRC" |
53 exit 1 | 45 exit 1 |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 --set bootcmd="mmc read 0 C0008000 0 1; autoscr C0008000" | 307 --set bootcmd="mmc read 0 C0008000 0 1; autoscr C0008000" |
316 fi | 308 fi |
317 | 309 |
318 # Force data to disk before we declare done. | 310 # Force data to disk before we declare done. |
319 sync | 311 sync |
320 | 312 |
321 echo "------------------------------------------------------------" | 313 echo "------------------------------------------------------------" |
322 echo "" | 314 echo "" |
323 echo "Installation to '$FLAGS_dst' complete." | 315 echo "Installation to '$FLAGS_dst' complete." |
324 echo "Please shutdown, remove the USB device, cross your fingers, and reboot." | 316 echo "Please shutdown, remove the USB device, cross your fingers, and reboot." |
OLD | NEW |