diff --git a/bin/aws/s3/sync-media b/bin/aws/s3/sync-media new file mode 100755 index 0000000..afc1ad7 --- /dev/null +++ b/bin/aws/s3/sync-media @@ -0,0 +1,48 @@ +#!/bin/zsh +source "$HOME/.config/wryn/env/env.zsh" +source $ZSH_COLOR_UTIL + +##################################################################### + +case $1 in + pull ) PULL=1 ;; + push ) PUSH=1 ;; +esac + +[ ! $PULL ] && [ ! $PUSH ] && FATAL 'must specify "pull" or "push"' + +##################################################################### + +PULL_MEDIA() { + local TARGET="$1" + local REMOTE_TARGET="s3://$S3_SYNC_BUCKET/$1" + local LOCAL_TARGET="$HOME/$1" + + [ ! -d $LOCAL_TARGET ] && mkdir -p $LOCAL_TARGET + + CHECK "updating $1" + aws --profile $DOTWRYN_AWS_PROFILE \ + s3 sync $REMOTE_TARGET $LOCAL_TARGET \ + >/dev/null 2>&1 \ + && OK || WARN +} + +PUSH_MEDIA() { + local TARGET="$1" + local REMOTE_TARGET="s3://$S3_SYNC_BUCKET/$1" + local LOCAL_TARGET="$HOME/$1" + + CHECK "updating $1" + aws --profile $DOTWRYN_AWS_PROFILE \ + s3 sync $LOCAL_TARGET $REMOTE_TARGET \ + --delete \ + >/dev/null 2>&1 \ + && OK || WARN +} + + +for m in $S3_SYNC_MEDIA +do + [ $PULL ] && PULL_MEDIA $m + [ $PUSH ] && PUSH_MEDIA $m +done diff --git a/env/env.zsh b/env/env.zsh index df1db53..baf43a5 100644 --- a/env/env.zsh +++ b/env/env.zsh @@ -23,6 +23,20 @@ WEBBROWSER='google-chrome-stable' #I3__DMENU_FONT_SIZE= #I3__BORDER_PIXEL_SIZE= +S3_SYNC_AWS_PROFILE='yage' +S3_SYNC_BUCKET='yage' +S3_SYNC_MEDIA=( + "Games/roms" + "Games/wrynscape" + "Media/sfx" + "Pictures/bg" + "Pictures/bg-archives" + "Pictures/custom-emoji" + "Pictures/jest" + "Pictures/profile" + ) + + PS1_BRANCH_SYMBOL='' PS1_INDICATOR_SYMBOL='☕' PS1_SEPARATOR='::'