Skip to content

Instantly share code, notes, and snippets.

@jjtroberts
Created October 12, 2022 22:03
Show Gist options
  • Save jjtroberts/99b78a530ee386684bdbae92f58f58a4 to your computer and use it in GitHub Desktop.
Save jjtroberts/99b78a530ee386684bdbae92f58f58a4 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ -z "$1" ]; then
echo "Email requires parameter 1 to be a string.";
exit 1;
fi
if [ -z "$2" ]; then
echo "Filename requires parameter 2 to be a string.";
exit 1;
fi
if [ -z "$3" ]; then
echo "Target host requires parameter 3 to be a string.";
exit 1;
fi
SERVER="https://transfer-appliance.com"
EXPIRES=`date +%Y-%m-%d -d "+10 days"`
cat <<EOF | curl -k -X POST -H 'Content-Type: application/json' --user "$APIKEY:x" -d @- $SERVER/message
{"message":
{
"recipients":["name@email.com","${1}"],
"subject":"Backup of ${3}",
"message":"Please download the attached archive for '${3}'",
"expires_at":"${EXPIRES}",
"send_email":true,
"authorization":0,
"attachments":[{
"filename":"${2}",
"data":"`openssl base64 -in ${2}`",
"checksum":"`openssl sha1 ${2} | awk '{print $2}'`"
}]
}
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment