2020-06-28 11:50:59 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! "$1" ] || [ ! "$2" ] || [ ! "$3" ]; then
|
|
|
|
echo "No Secrets"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "\nUploading .ini files"
|
|
|
|
|
|
|
|
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"
|
2020-06-28 12:03:53 -07:00
|
|
|
if [[ "$sig" =~ rusEFI.*([0-9]{4}\.[^\"]+) ]]; then
|
2020-06-28 11:50:59 -07:00
|
|
|
sig=${BASH_REMATCH[1]}
|
|
|
|
sig="${sig//\./\/}.ini"
|
|
|
|
path="/rusefi/$sig"
|
|
|
|
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
|
|
|
|
echo mkdir 2020 >> cmd
|
|
|
|
echo cd 2020 >> cmd
|
|
|
|
echo mkdir 06 >> cmd
|
|
|
|
echo cd 06 >> cmd
|
|
|
|
echo put $f >> cmd
|
|
|
|
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"
|
|
|
|
exit -1
|
|
|
|
fi
|
2020-06-28 11:50:59 -07:00
|
|
|
echo "* upload done!"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi; done
|