Added s3 media synchronizer

This commit is contained in:
Wryn Wagner 2021-09-24 09:36:29 -06:00
parent 103b4a8d34
commit 72d6e76602
2 changed files with 62 additions and 0 deletions

48
bin/aws/s3/sync-media Executable file
View File

@ -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

14
env/env.zsh vendored
View File

@ -23,6 +23,20 @@ WEBBROWSER='google-chrome-stable'
#I3__DMENU_FONT_SIZE= #I3__DMENU_FONT_SIZE=
#I3__BORDER_PIXEL_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_BRANCH_SYMBOL=''
PS1_INDICATOR_SYMBOL='☕' PS1_INDICATOR_SYMBOL='☕'
PS1_SEPARATOR='::' PS1_SEPARATOR='::'