diff --git a/.aliases.sh b/.aliases.sh index 9962f24..3df0890 100644 --- a/.aliases.sh +++ b/.aliases.sh @@ -78,26 +78,31 @@ function upload() { if [ "$#" -ne 2 ]; then echo "Invalid number of parameters" echo "usage: upload " + echo "example: upload tmp img.png" return fi - if [ -z "$FILE_STORAGE_API_KEY" ]; then - echo "No API key set, did you forget to 'source ~/.tokens'?" + if [ -z "$RSYNC_HOST" ]; then + echo "No rsync env variables set, did you forget to source?" return fi echo "Uploading to $1/$2" - curl --request PUT \ - --url "$FILE_STORAGE_API_URL/$1/$2" \ - --header "AccessKey: $FILE_STORAGE_API_KEY" \ - --header "Content-Type: application/octet-stream" \ - --header "accept: application/json" \ - --data-binary "@$2" + rsync \ + --verbose \ + --recursive \ + --rsh "ssh -p $RSYNC_PORT -i $HOME/.ssh/$RSYNC_KEY" \ + "$2" \ + "$RSYNC_USER@$RSYNC_HOST:$RSYNC_DEST/$1" + + if [ "$?" -ne 0 ]; then + return + fi echo "" - echo "$FILE_STORAGE_EXTERNAL_URL/$1/$2 (copied to clipboard)" - echo "$FILE_STORAGE_EXTERNAL_URL/$1/$2" | xclip -sel clip + echo "https://$RSYNC_HOST/$1/$2 (copied to clipboard)" + echo "https://$RSYNC_HOST/$1/$2" | xclip -sel clip } function upload_all() { diff --git a/.rsync_template b/.rsync_template new file mode 100644 index 0000000..82e1594 --- /dev/null +++ b/.rsync_template @@ -0,0 +1,5 @@ +RSYNC_USER=foo +RSYNC_HOST=bar.com +RSYNC_PORT=22 +RSYNC_KEY=my-ssh-key +RSYNC_DEST=/var/www diff --git a/.tokens_template b/.tokens_template deleted file mode 100644 index 4d44baf..0000000 --- a/.tokens_template +++ /dev/null @@ -1,3 +0,0 @@ -FILE_STORAGE_API_KEY=my-secret-key -FILE_STORAGE_API_URL=https://my-file-host-api.url -FILE_STORAGE_EXTERNAL_URL=https://hello-friend-have-a-file.url diff --git a/link.sh b/link.sh index 644c9c6..53c5d62 100755 --- a/link.sh +++ b/link.sh @@ -9,4 +9,4 @@ sudo chmod +x ~/bin/*.sh mkdir -p ~/.config stow --target=$HOME/.config .config -cp --update=none .tokens_template ~/.tokens +cp --update=none .rsync_template ~/.rsync