rusefi/firmware/tunerstudio/upload_ini.sh

64 lines
1.5 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
fileName="rusefi_$SHORT_BOARD_NAME.ini"
# user=$1
# pass=$2
# host=$3
if [ ! "$SHORT_BOARD_NAME" ]; then
echo "No SHORT_BOARD_NAME"
2022-08-17 15:29:07 -07:00
exit 1
fi
if [ ! "$1" ] || [ ! "$2" ] || [ ! "$3" ]; then
echo "upload_ini.sh says No Secrets, exiting"
exit 0
fi
pwd
2023-12-01 19:19:46 -08:00
echo -e "\nUploading all .ini files"
ls -l .
2022-11-01 18:35:47 -07:00
if [ "$fileName" == "no" ]; then
echo "[upload_ini] signature file not needed"
exit 0
fi
echo "[upload_ini] Looking for signature in [$fileName]..."
sig=$(grep "^\s*signature\s*=" $fileName | cut -f2 -d "=")
2022-08-17 15:29:07 -07:00
if [ ! -z "$sig" -a "$sig" != " " ]; then
echo "* found signature: $sig"
if [[ "$sig" =~ rusEFI\ ([a-zA-Z0-9_-]+)\.([0-9]{4})\.([0-9]{2})\.([0-9]{2})\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+) ]]; then
branch=${BASH_REMATCH[1]}
year=${BASH_REMATCH[2]}
month=${BASH_REMATCH[3]}
day=${BASH_REMATCH[4]}
board=${BASH_REMATCH[5]}
hash=${BASH_REMATCH[6]}
path="$branch/$year/$month/$day/$board/$hash.ini"
2022-08-17 15:29:07 -07:00
echo "* found path: $path"
# we do not have ssh for this user
# sftp does not support -p flag on mkdir :(
sshpass -p $2 sftp -o StrictHostKeyChecking=no $1@$3 <<SSHCMD
cd rusefi
mkdir $branch
mkdir $branch/$year
mkdir $branch/$year/$month
mkdir $branch/$year/$month/$day
mkdir $branch/$year/$month/$day/$board
2022-08-18 07:19:09 -07:00
put $fileName $path
SSHCMD
2022-08-17 15:29:07 -07:00
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Upload failed"
exit 1
fi
2022-08-17 15:29:07 -07:00
echo "* upload done!"
else
echo "[upload_ini] Unexpected Signature: [$sig]"
fi
else
echo "Signature not found in $fileName"
exit 1
2022-08-17 15:29:07 -07:00
fi