82 lines
2.4 KiB
Shell
Executable file
82 lines
2.4 KiB
Shell
Executable file
#!/bin/bash
|
|
|
|
# Source - https://stackoverflow.com/a/7069755
|
|
# Posted by Flexo - Save the data dump, modified by community. See post 'Timeline' for change history
|
|
# Retrieved 2026-06-20, License - CC BY-SA 4.0
|
|
|
|
USERNAME="$COPY_PARTY_USERNAME"
|
|
PASSWORD="$COPY_PARTY_PASSWORD"
|
|
ROOT="https://stuff.forgeserv.cloud/Jose's%20Junk"
|
|
FILE=""
|
|
|
|
while test $# -gt 0; do
|
|
case "$1" in
|
|
-h|--help)
|
|
echo "upload - push a file to CopyParty"
|
|
echo " Supports deep searching (searching all files within the jar) and regex"
|
|
echo " "
|
|
echo "Usage:"
|
|
echo " upload <file_path> [-u|--user] [-p|--password] [-r|--root]"
|
|
echo " "
|
|
echo "options:"
|
|
echo "-u, --user Define the user for BasicAuth. Defaults to COPY_PARTY_USERNAME"
|
|
echo "-p, --password Define the password for BasicAuth. Defaults to COPY_PARTY_PASSWORD"
|
|
echo "-r, --root Define the root for the upload. Defaults to $ROOT"
|
|
echo "-h, --help Show this prompt"
|
|
exit 0
|
|
;;
|
|
-u|--user)
|
|
shift
|
|
if test $# -gt 0; then
|
|
export USERNAME=$1
|
|
else
|
|
echo "No username defined!"
|
|
exit 1
|
|
fi
|
|
shift
|
|
;;
|
|
-p|--password)
|
|
shift
|
|
if test $# -gt 0; then
|
|
export PASSWORD=$1
|
|
else
|
|
echo "No password defined!"
|
|
exit 1
|
|
fi
|
|
shift
|
|
;;
|
|
-r|--root)
|
|
shift
|
|
if test $# -gt 0; then
|
|
export ROOT=$1
|
|
else
|
|
echo "No alt root specified!"
|
|
exit 1
|
|
fi
|
|
shift
|
|
;;
|
|
*)
|
|
if test -z "$FILE"; then
|
|
export FILE=$1
|
|
shift
|
|
else
|
|
echo "Only one file can be provided!"
|
|
exit 1
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
|
|
|
|
if test -z "$FILE"; then
|
|
echo "No file was provided!"
|
|
exit 1
|
|
fi
|
|
|
|
|
|
full_url=$(printf '%s/%s?j' "$ROOT" "$FILE")
|
|
output=$(curl -u "$USERNAME:$PASSWORD" -T "$FILE" "$full_url" 2>/dev/null)
|
|
fileurl=$(jq -r '.fileurl' <<<"$output")
|
|
|
|
echo "$fileurl" | wl-copy
|
|
notify-send -a 'Uploaded to Copyparty' 'Link Copied to Clipboard!'
|