diff options
Diffstat (limited to 'automated/android/dd-wr-speed/device-script.sh')
-rwxr-xr-x | automated/android/dd-wr-speed/device-script.sh | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/automated/android/dd-wr-speed/device-script.sh b/automated/android/dd-wr-speed/device-script.sh index 66ce843..86f3643 100755 --- a/automated/android/dd-wr-speed/device-script.sh +++ b/automated/android/dd-wr-speed/device-script.sh @@ -1,39 +1,38 @@ -#!/system/bin/sh +#!/system/bin/sh -ex ITERATION="$1" -PARTITION="$2" -OUTPUT="$3" +OUTPUT="$2" +PARTITION="$3" +export PATH="/data/local/tmp/bin:${PATH}" -if [ "$#" -ne 3 ]; then - echo "ERROR: Usage: $0 ITERATION PARTITION OUTPUT" +if [ "$#" -lt 2 ]; then + echo "ERROR: Usage: $0 <iteration> <output> <partition>" exit 1 fi -[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}-$(date +%Y%m%d%H%M%S)" +[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date -r "${OUTPUT}" +%Y%m%d%H%M%S)" mkdir -p "${OUTPUT}" && cd "${OUTPUT}" # If partition specified, format it to vfat, and mount it to /mnt/dd_test. # Then enter the mount point to do dd test. if [ -n "${PARTITION}" ]; then - partition_name="$(basename "${PARTITION}")" - partition_numbers="$(grep "${partition_name}" /proc/partitions \ - | awk '{print $1","$2}')" + partition_name=$(basename "${PARTITION}") + # shellcheck disable=SC2016 + partition_numbers=$(grep "${partition_name}" /proc/partitions | busybox awk '{print $1","$2}') if [ -z "${partition_numbers}" ]; then echo "ERROR: ${PARTITION} NOT found" && exit 1 else # Attemp to umount it in case it is mounted by Android vold. - umount "/dev/block/vold/public:${partition_numbers}" > /dev/null 2>&1 - umount "${PARTITION}" > /dev/null 2>&1 + umount "/dev/block/vold/public:${partition_numbers}" > /dev/null 2>&1 || true + umount "${PARTITION}" > /dev/null 2>&1 || true echo "INFO: formatting ${PARTITION} to vfat..." busybox mkfs.vfat "${PARTITION}" sync && sleep 10 mkdir -p /mnt/dd_test - mount -t vfat "/dev/block/vold/public:${partition_numbers}" \ - /mnt/dd_test/ - if [ $? -eq 0 ]; then + if mount -t vfat "${PARTITION}" /mnt/dd_test/; then echo "INFO: Mounted ${PARTITION} to /mnt/dd_test" else echo "ERROR: failed to mount ${PARTITION}" && exit 1 @@ -58,5 +57,5 @@ for i in $(seq "${ITERATION}"); do busybox dd if=dd.img of=/dev/null bs=1048576 count=1024 2>&1 \ | tee -a "${OUTPUT}"/dd-read-output.txt - rm dd.img + rm -f dd.img done |