OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 # | 4 # |
5 # This contains common constants and functions for installer scripts. This must | 5 # This contains common constants and functions for installer scripts. This must |
6 # evaluate properly for both /bin/bash and /bin/sh, since it's used both to | 6 # evaluate properly for both /bin/bash and /bin/sh, since it's used both to |
7 # create the initial image at compile time and to install or upgrade a running | 7 # create the initial image at compile time and to install or upgrade a running |
8 # image. | 8 # image. |
9 | 9 |
10 # Here are the GUIDs we'll be using to identify various partitions. NOTE: The | 10 # Here are the GUIDs we'll be using to identify various partitions. NOTE: The |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 # The scripts that source this file typically want to use the root password as | 503 # The scripts that source this file typically want to use the root password as |
504 # confirmation, unless the --run_as_root flag is given. | 504 # confirmation, unless the --run_as_root flag is given. |
505 dont_run_as_root() { | 505 dont_run_as_root() { |
506 if [ $(id -u) -eq "0" -a "${FLAGS_run_as_root}" -eq "${FLAGS_FALSE}" ] | 506 if [ $(id -u) -eq "0" -a "${FLAGS_run_as_root}" -eq "${FLAGS_FALSE}" ] |
507 then | 507 then |
508 echo "Note: You must be the 'chronos' user to run this script. Unless" | 508 echo "Note: You must be the 'chronos' user to run this script. Unless" |
509 echo "you pass --run_as_root and run as root." | 509 echo "you pass --run_as_root and run as root." |
510 exit 1 | 510 exit 1 |
511 fi | 511 fi |
512 } | 512 } |
| 513 |
| 514 list_usb_disks() { |
| 515 local sd |
| 516 for sd in /sys/block/sd*; do |
| 517 if readlink ${sd}/device | grep -q usb && |
| 518 [ "$(cat ${sd}/removable)" = 1 ]; then |
| 519 echo ${sd##*/} |
| 520 fi |
| 521 done |
| 522 } |
| 523 |
| 524 get_disk_info() { |
| 525 # look for a "given" file somewhere in the path upwards from the device |
| 526 local dev_path=/sys/block/${1}/device |
| 527 while [ -d "${dev_path}" -a "${dev_path}" != "/sys" ]; do |
| 528 if [ -f "${dev_path}/${2}" ]; then |
| 529 cat "${dev_path}/${2}" |
| 530 return |
| 531 fi |
| 532 dev_path=$(readlink -f ${dev_path}/..) |
| 533 done |
| 534 echo '[Unknown]' |
| 535 } |
OLD | NEW |