diff options
Diffstat (limited to 'bin/b2')
| -rwxr-xr-x | bin/b2 | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/bin/b2 b/bin/b2 deleted file mode 100755 index 07d1976..0000000 --- a/bin/b2 +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh - -set -e - -cdn_uri=${B2CLI_CDN_URI:-cdn.example.com} -bucket=${B2CLI_BUCKET:?missing bucket} -b2_uri=${B2CLI_B2_URI:-f001.backblazeb2.com} - -canonical_uri() { - sed "s|${b2_uri}/file/${bucket}|${cdn_uri}/static|g" -} - -list= -delete= -hash= -while getopts Hldh opt; do - case "$opt" in - l) list=1 ;; - d) delete=1 ;; - H) hash=1 ;; - h | ?) - printf "usage: %s [-hld] [FILE] [DESTINATION]\n" "$(basename "$0")" - printf "\n" - printf " -l list\n" - printf " -d delete\n" - printf " -H hash as filename\n" - printf "\n" - printf "The default action is to put the FILE into the remote bucket\n" - exit 2 - ;; - esac -done -shift $((OPTIND - 1)) - -file="${1}" -dest=${2:-"$(basename "${file}")"} - -if [ -n "$list" ]; then - for lnk in $(rclone lsf -R b2:${bucket}/ | sort); do - echo "https://${b2_uri}/file/${bucket}/${lnk}" | canonical_uri - done - exit 0 -fi - -if [ -n "$delete" ]; then - rclone deletefile b2:${bucket}/"${file}" - printf "deleted: %s\n" "${file}" >&2 - exit 0 -fi - -if [ -n "$hash" ]; then - ext="$(echo "${file}" | rev | cut -d\. -f1 | rev | sed -e "s#${file}##")" - [ -n "$ext" ] && ext=".${ext}" - sum=$(md5sum "$file" | cut -d\ -f1) - dest=$(echo "${dest}" | sed -e "s#$(basename "${file}")#${sum}${ext}#") -fi - -rclone copyto "${file}" b2:${bucket}/"${dest}" >&2 - -b2_share_link="https://${b2_uri}/file/${bucket}/${dest}" -echo "${b2_share_link}" | sed "s|${b2_uri}|${cdn_uri}|" >&2 -echo "${b2_share_link}" | canonical_uri |