2020-06-28 11:50:59 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! "$1" ] || [ ! "$2" ] || [ ! "$3" ]; then
|
|
|
|
echo "No Secrets"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2020-07-07 18:48:05 -07:00
|
|
|
pwd
|
2020-06-28 11:50:59 -07:00
|
|
|
echo -e "\nUploading .ini files"
|
2020-07-07 18:48:05 -07:00
|
|
|
ls -l .
|
2020-06-28 11:50:59 -07:00
|
|
|
|
|
|
|
for f in *.ini; do if [[ -f "$f" ]]; then
|
|
|
|
echo "Processing file $f:"
|
|
|
|
sig=$(grep "^ *signature *=" $f | cut -f2 -d "=")
|
|
|
|
if [ ! -z "$sig" -a "$sig" != " " ]; then
|
|
|
|
echo "* found signature: $sig"
|
2021-10-13 19:06:43 -07:00
|
|
|
if [[ "$sig" =~ rusEFI.*([0-9]{4})\.([0-9]{2})\.([0-9]{2})\.([a-zA-Z0-9_-]+)\.([0-9]+) ]]; then
|
2020-06-29 05:47:23 -07:00
|
|
|
year=${BASH_REMATCH[1]}
|
|
|
|
month=${BASH_REMATCH[2]}
|
|
|
|
day=${BASH_REMATCH[3]}
|
|
|
|
board=${BASH_REMATCH[4]}
|
|
|
|
hash=${BASH_REMATCH[5]}
|
|
|
|
path="$year/$month/$day/$board/$hash.ini"
|
2020-06-28 11:50:59 -07:00
|
|
|
echo "* found path: $path"
|
2020-06-28 17:29:28 -07:00
|
|
|
# unbeliveable, ncftpput does not work with special characters in password?!
|
|
|
|
# ncftpput -m -R -v -u "$1" -p "$2" "$3" $path $f
|
2020-06-28 17:50:20 -07:00
|
|
|
# we do not have ssh for this user
|
|
|
|
# sftp does not support -p flag on mkdir :(
|
2020-06-28 18:48:53 -07:00
|
|
|
echo cd rusefi > cmd
|
2020-06-29 05:47:23 -07:00
|
|
|
echo mkdir $year >> cmd
|
|
|
|
echo mkdir $year/$month >> cmd
|
|
|
|
echo mkdir $year/$month/$day >> cmd
|
|
|
|
echo mkdir $year/$month/$day/$board >> cmd
|
|
|
|
echo put $f $path >> cmd
|
2020-06-28 18:48:53 -07:00
|
|
|
cat cmd
|
2020-06-28 17:50:20 -07:00
|
|
|
sshpass -p $2 sftp -o StrictHostKeyChecking=no $1@$3 <<< `cat cmd`
|
2020-06-28 14:14:06 -07:00
|
|
|
retVal=$?
|
|
|
|
if [ $retVal -ne 0 ]; then
|
|
|
|
echo "Upload failed"
|
2020-06-30 17:49:16 -07:00
|
|
|
exit 1
|
2020-06-28 14:14:06 -07:00
|
|
|
fi
|
2020-06-28 11:50:59 -07:00
|
|
|
echo "* upload done!"
|
2021-10-13 19:06:43 -07:00
|
|
|
else
|
|
|
|
echo "Unexpected $sig"
|
2020-06-28 11:50:59 -07:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi; done
|