From bae1d7a8948b223c31c4cc149a5e1643db1f874a Mon Sep 17 00:00:00 2001 From: Tim Gunter Date: Fri, 9 Apr 2021 20:01:12 -0700 Subject: [PATCH 1/2] Default interpreter to "python" if "python3" doesn't exist --- bin/device-install.sh | 2 +- bin/device-update.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/device-install.sh b/bin/device-install.sh index 3b1bd50f2..37a6f781d 100755 --- a/bin/device-install.sh +++ b/bin/device-install.sh @@ -1,6 +1,6 @@ #!/bin/sh -PYTHON=${PYTHON:-python3} +PYTHON=${PYTHON:-$(which python3 python|head -n 1)} set -e diff --git a/bin/device-update.sh b/bin/device-update.sh index 98eff9d10..6f8aa0a62 100755 --- a/bin/device-update.sh +++ b/bin/device-update.sh @@ -1,6 +1,6 @@ #!/bin/sh -PYTHON=${PYTHON:-python3} +PYTHON=${PYTHON:-$(which python3 python|head -n 1)} # Usage info show_help() { From ce5d57d25046370844ef33d0160f022087066c45 Mon Sep 17 00:00:00 2001 From: Tim Gunter Date: Fri, 9 Apr 2021 20:02:25 -0700 Subject: [PATCH 2/2] Allow device-*.sh file to flash to be specified without '-f' --- bin/device-install.sh | 7 ++++++- bin/device-update.sh | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/device-install.sh b/bin/device-install.sh index 37a6f781d..85e39892e 100755 --- a/bin/device-install.sh +++ b/bin/device-install.sh @@ -7,7 +7,7 @@ set -e # Usage info show_help() { cat << EOF -Usage: ${0##*/} [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME] +Usage: $(basename $0) [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME|FILENAME] Flash image file to device, but first erasing and writing system information" -h Display this help and exit @@ -39,6 +39,11 @@ while getopts ":hp:P:f:" opt; do done shift "$((OPTIND-1))" +[ -z "$FILENAME" -a -n "$1" ] && { + FILENAME=$1 + shift +} + if [ -f "${FILENAME}" ]; then echo "Trying to flash ${FILENAME}, but first erasing and writing system information" $PYTHON -m esptool --baud 921600 erase_flash diff --git a/bin/device-update.sh b/bin/device-update.sh index 6f8aa0a62..dda05f005 100755 --- a/bin/device-update.sh +++ b/bin/device-update.sh @@ -5,7 +5,7 @@ PYTHON=${PYTHON:-$(which python3 python|head -n 1)} # Usage info show_help() { cat << EOF -Usage: ${0##*/} [-h] [-p ESPTOOL_PORT] [-P PYTHON] -f FILENAME +Usage: $(basename $0) [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME|FILENAME] Flash image file to device, leave existing system intact." -h Display this help and exit @@ -37,6 +37,11 @@ while getopts ":hp:P:f:" opt; do done shift "$((OPTIND-1))" +[ -z "$FILENAME" -a -n "$1" ] && { + FILENAME=$1 + shift +} + if [ -f "${FILENAME}" ]; then echo "Trying to flash update ${FILENAME}." $PYTHON -m esptool --baud 921600 write_flash 0x10000 ${FILENAME}