diff --git a/01_download_factorytest.sh b/01_download_factorytest.sh index 3257668..367061c 100755 --- a/01_download_factorytest.sh +++ b/01_download_factorytest.sh @@ -1,5 +1,8 @@ #!/bin/bash +# lib.sh を読み込んで curl オプション設定を利用 +source lib.sh + bindir=FactoryTest/build/esp32.esp32.m5stack_stickc_plus2 mkdir -p "$bindir" baseurl="https://cit.istlab.info/f/plus2/FactoryTest.ino." @@ -8,7 +11,7 @@ for ext in bin bootloader.bin partitions.bin; do url="${baseurl}${ext}" echo "Downloading $url ..." - curl --ssl-no-revoke -L -o "$bindir/FactoryTest.ino.${ext}" "$url" + curl $(lib_get_curl_options) -L -o "$bindir/FactoryTest.ino.${ext}" "$url" if [ $? -ne 0 ]; then echo "Failed to download $url" exit 1 diff --git a/34_write_byhash.sh b/34_write_byhash.sh index 3ec995e..3ab0db7 100755 --- a/34_write_byhash.sh +++ b/34_write_byhash.sh @@ -1,5 +1,8 @@ #!/bin/bash +# lib.sh を読み込んで curl オプション設定を利用 +source lib.sh + if [ -z "$1" ]; then echo "Usage: $0 " @@ -15,14 +18,14 @@ # ダウンロードURL URL="https://lattr.istlab.info/inobin/dl/${hash}" -RESPONCE_CODE=$(curl -s -o byhash.bin -w "%{http_code}" $URL) +RESPONCE_CODE=$(curl $(lib_get_curl_options) -s -o byhash.bin -w "%{http_code}" $URL) if [ $RESPONCE_CODE -ne 200 ]; then echo "Error: $RESPONCE_CODE" exit 1 fi -curl -o byhash.partitions.bin -s ${URL}/partitions -curl -o byhash.bootloader.bin -s ${URL}/bootloader +curl $(lib_get_curl_options) -o byhash.partitions.bin -s ${URL}/partitions +curl $(lib_get_curl_options) -o byhash.bootloader.bin -s ${URL}/bootloader echo "Downloaded ${hash} as [byhash.bin], [byhash.partitions.bin], [byhash.bootloader.bin]" # もし、hashがp1ではじまっていたら、注意喚起する diff --git a/44_write_latest.sh b/44_write_latest.sh index daf42c8..aa5e810 100755 --- a/44_write_latest.sh +++ b/44_write_latest.sh @@ -51,7 +51,7 @@ # echo connecting to ${URL} -info=`curl -s -o /dev/null -X POST -d "uid=${MYUID}&login=${LOGIN}" ${URL_SHOW}` +info=`curl $(lib_get_curl_options) -s -o /dev/null -X POST -d "uid=${MYUID}&login=${LOGIN}" ${URL_SHOW}` echo "------------------------------" echo ${info} # もし、infoにhash:p1 が含まれていたら、注意喚起する @@ -64,7 +64,7 @@ echo "------------------------------" # POSTリクエストを送信し、レスポンスコードを取得 -RESPONSE_CODE=$(curl -o latest.bin -s -w "%{http_code}" -X POST -d "uid=${MYUID}&login=${LOGIN}" ${URL}) +RESPONSE_CODE=$(curl $(lib_get_curl_options) -o latest.bin -s -w "%{http_code}" -X POST -d "uid=${MYUID}&login=${LOGIN}" ${URL}) if [ "$RESPONSE_CODE" -ne 200 ]; then echo "エラー: レスポンスコード $RESPONSE_CODE が返されました。" @@ -79,7 +79,7 @@ if [ "$1" == "y" ]; then while true ; do sleep 5 - RESPONSE_CODE=$(curl -o latest.bin -s -w "%{http_code}" -X POST -d "uid=${MYUID}&login=${LOGIN}" ${URL}) + RESPONSE_CODE=$(curl $(lib_get_curl_options) -o latest.bin -s -w "%{http_code}" -X POST -d "uid=${MYUID}&login=${LOGIN}" ${URL}) if [ "$RESPONSE_CODE" -eq 200 ]; then break fi @@ -89,8 +89,8 @@ fi if [ "$RESPONSE_CODE" -eq 200 ]; then echo "ダウンロード成功: (レスポンスコード $RESPONSE_CODE)" - curl -o latest.partitions.bin -s -X POST -d "uid=${MYUID}&login=${LOGIN}&type=partitions" ${URL} - curl -o latest.bootloader.bin -s -X POST -d "uid=${MYUID}&login=${LOGIN}&type=bootloader" ${URL} + curl $(lib_get_curl_options) -o latest.partitions.bin -s -X POST -d "uid=${MYUID}&login=${LOGIN}&type=partitions" ${URL} + curl $(lib_get_curl_options) -o latest.bootloader.bin -s -X POST -d "uid=${MYUID}&login=${LOGIN}&type=bootloader" ${URL} # 書き込みを行う if [ "$1" == "y" ]; then yn='y' diff --git a/91_install_cli.sh b/91_install_cli.sh index 2b84553..2438cda 100755 --- a/91_install_cli.sh +++ b/91_install_cli.sh @@ -1,5 +1,8 @@ #!/bin/bash +# lib.sh を読み込んで curl オプション設定を利用 +source lib.sh + cd # git update-git-for-windows @@ -9,7 +12,7 @@ sleep 1 else # install (or upgrade) arduino-cli - curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh + curl $(lib_get_curl_options) -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh fi if type -p arduino-cli >/dev/null; then diff --git a/__admin/plus1_download.sh b/__admin/plus1_download.sh index 82724f1..d92e739 100755 --- a/__admin/plus1_download.sh +++ b/__admin/plus1_download.sh @@ -1,6 +1,10 @@ #!/bin/bash cd .. + +# lib.sh を読み込んで curl オプション設定を利用 +source lib.sh + bindir=FactoryTest/build/esp32.esp32.m5stack_stickc_plus mkdir -p "$bindir" baseurl="https://cit.istlab.info/f/plus1/FactoryTest.ino." @@ -9,7 +13,7 @@ for ext in bin bootloader.bin partitions.bin; do url="${baseurl}${ext}" echo "Downloading $url ..." - curl -L -o "$bindir/FactoryTest.ino.${ext}" "$url" + curl $(lib_get_curl_options) -L -o "$bindir/FactoryTest.ino.${ext}" "$url" if [ $? -ne 0 ]; then echo "Failed to download $url" exit 1 diff --git a/lib.sh b/lib.sh index ddd243f..127101a 100644 --- a/lib.sh +++ b/lib.sh @@ -1,5 +1,18 @@ #!/usr/bin/env bash +# curl オプション設定 +# true に設定すると --ssl-no-revoke オプションが追加されます +CURL_SSL_NO_REVOKE=true + +# curl の共通オプションを取得する関数 +lib_get_curl_options() { + local options="" + if [ "$CURL_SSL_NO_REVOKE" = "true" ]; then + options="--ssl-no-revoke" + fi + echo "$options" +} + # lib_get_esptool_command() { PYTHON="python" diff --git a/m5latest.sh b/m5latest.sh index daf42c8..aa5e810 100755 --- a/m5latest.sh +++ b/m5latest.sh @@ -51,7 +51,7 @@ # echo connecting to ${URL} -info=`curl -s -o /dev/null -X POST -d "uid=${MYUID}&login=${LOGIN}" ${URL_SHOW}` +info=`curl $(lib_get_curl_options) -s -o /dev/null -X POST -d "uid=${MYUID}&login=${LOGIN}" ${URL_SHOW}` echo "------------------------------" echo ${info} # もし、infoにhash:p1 が含まれていたら、注意喚起する @@ -64,7 +64,7 @@ echo "------------------------------" # POSTリクエストを送信し、レスポンスコードを取得 -RESPONSE_CODE=$(curl -o latest.bin -s -w "%{http_code}" -X POST -d "uid=${MYUID}&login=${LOGIN}" ${URL}) +RESPONSE_CODE=$(curl $(lib_get_curl_options) -o latest.bin -s -w "%{http_code}" -X POST -d "uid=${MYUID}&login=${LOGIN}" ${URL}) if [ "$RESPONSE_CODE" -ne 200 ]; then echo "エラー: レスポンスコード $RESPONSE_CODE が返されました。" @@ -79,7 +79,7 @@ if [ "$1" == "y" ]; then while true ; do sleep 5 - RESPONSE_CODE=$(curl -o latest.bin -s -w "%{http_code}" -X POST -d "uid=${MYUID}&login=${LOGIN}" ${URL}) + RESPONSE_CODE=$(curl $(lib_get_curl_options) -o latest.bin -s -w "%{http_code}" -X POST -d "uid=${MYUID}&login=${LOGIN}" ${URL}) if [ "$RESPONSE_CODE" -eq 200 ]; then break fi @@ -89,8 +89,8 @@ fi if [ "$RESPONSE_CODE" -eq 200 ]; then echo "ダウンロード成功: (レスポンスコード $RESPONSE_CODE)" - curl -o latest.partitions.bin -s -X POST -d "uid=${MYUID}&login=${LOGIN}&type=partitions" ${URL} - curl -o latest.bootloader.bin -s -X POST -d "uid=${MYUID}&login=${LOGIN}&type=bootloader" ${URL} + curl $(lib_get_curl_options) -o latest.partitions.bin -s -X POST -d "uid=${MYUID}&login=${LOGIN}&type=partitions" ${URL} + curl $(lib_get_curl_options) -o latest.bootloader.bin -s -X POST -d "uid=${MYUID}&login=${LOGIN}&type=bootloader" ${URL} # 書き込みを行う if [ "$1" == "y" ]; then yn='y' diff --git a/upload_by_hash.sh b/upload_by_hash.sh index 99d1a78..5d1a31d 100755 --- a/upload_by_hash.sh +++ b/upload_by_hash.sh @@ -17,14 +17,14 @@ # ダウンロードURL URL="https://lattr.istlab.info/inobin/dl/${hash}" -RESPONCE_CODE=$(curl -s -o byhash.bin -w "%{http_code}" $URL) +RESPONCE_CODE=$(curl $(lib_get_curl_options) -s -o byhash.bin -w "%{http_code}" $URL) if [ $RESPONCE_CODE -ne 200 ]; then echo "Error: $RESPONCE_CODE" exit 1 fi -curl -o byhash.partitions.bin -s ${URL}/partitions -curl -o byhash.bootloader.bin -s ${URL}/bootloader +curl $(lib_get_curl_options) -o byhash.partitions.bin -s ${URL}/partitions +curl $(lib_get_curl_options) -o byhash.bootloader.bin -s ${URL}/bootloader echo "Downloaded ${hash} as [byhash.bin], [byhash.partitions.bin], [byhash.bootloader.bin]" # もし、hashがp1ではじまっていたら、注意喚起する