Last active
August 5, 2016 23:40
-
-
Save BytewaveMLP/46cdd205286897b90fe4f5ad30cd5a3f to your computer and use it in GitHub Desktop.
Uploads a file to eeti.me (when file is -, uploads stdin)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ================================================================== | |
# eeti-upload - Uploads a file to eeti.me | |
# Made with love by Bytewave (http://steamcommunity.com/id/Bytewave) | |
# Licensed under the WTFPL (http://www.wtfpl.net) | |
# ================================================================== | |
EETI_USER="" # your eeti2 username | |
EETI_PASS="" # your eeti2 password | |
exit_with_error() { | |
>&2 echo "`basename "$0"`: $1" | |
exit $2 | |
} | |
usage() { | |
echo "Bytewave's eeti2 upload script" | |
echo "Licensed under the WTFPL, because I could care less" | |
echo "" | |
echo "Usage:" | |
echo " `basename "$0"` <file>" | |
echo "Arguments:" | |
echo " file The file to upload (when -, read stdin)" | |
echo "Exit codes:" | |
echo " 1 file not found" | |
echo " 2 no file specified" | |
echo " 3 eeti user details missing" | |
echo " 127 dependency missing" | |
echo "" | |
echo "Direct all issues to Byte, and all hate to /dev/null. <3" | |
} | |
# test for missing command dependencies | |
type tee >/dev/null 2>&1 || exit_with_error "tee: command not found" 127 | |
type xclip >/dev/null 2>&1 || exit_with_error "xclip: command not found" 127 | |
type curl >/dev/null 2>&1 || exit_with_error "curl: command not found" 127 | |
if [ -z "$EETI_USER" ]; then | |
exit_with_error "no eeti user specified" 3 | |
fi | |
if [ -z "$EETI_PASS" ]; then | |
exit_with_error "no eeti password specified" 3 | |
fi | |
if [ -z "$1" ]; then | |
usage | |
echo "" | |
exit_with_error "no file specified" 2 | |
fi | |
if [ ! "$1" = "-" ]; then | |
if [ ! -f "$1" ]; then | |
exit_with_error "$1: file not found" 1 | |
fi | |
fi | |
curl -F file=@"$1" -F user="$EETI_USER" -F pass="$EETI_PASS" https://eeti.me/upload.php\?uploaded | tee >(xclip -selection clipboard) | |
echo "" # fixes partial line issue in zsh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment