diff --git a/bin/aws/configure b/bin/aws/configure new file mode 100755 index 0000000..a93dfe5 --- /dev/null +++ b/bin/aws/configure @@ -0,0 +1,19 @@ +#!/bin/zsh +source "$HOME/.config/wryn/env/env.zsh" +source $ZSH_COLOR_UTIL + +##################################################################### + +CONFIGURE() { + CHECK "checking for '$DOTWRYN_AWS_PROFILE' aws credentials" + grep -q "^\\[$DOTWRYN_AWS_PROFILE\\]$" "$HOME/.aws/credentials" \ + && { OK; return 0 } || WARN + + USER_PROMPT "set up credentials now? [Y/n]" + READ_K yn + [[ $yn =~ ^[nN] ]] && return 1 + + aws --profile $DOTWRYN_AWS_PROFILE configure +} + +CONFIGURE diff --git a/env/env.zsh b/env/env.zsh index baf43a5..90e5d74 100644 --- a/env/env.zsh +++ b/env/env.zsh @@ -23,7 +23,11 @@ WEBBROWSER='google-chrome-stable' #I3__DMENU_FONT_SIZE= #I3__BORDER_PIXEL_SIZE= -S3_SYNC_AWS_PROFILE='yage' +DOTWRYN_AWS_PROFILE='yage' +DOTWRYN_AWS_REGION='us-east-2' +DOTWRYN_AWS_OUTPUT='json' + +S3_SYNC_AWS_PROFILE=$DOTWRYN_AWS_PROFILE S3_SYNC_BUCKET='yage' S3_SYNC_MEDIA=( "Games/roms" diff --git a/setup/aws/setup.zsh b/setup/aws/setup.zsh new file mode 100644 index 0000000..95250f0 --- /dev/null +++ b/setup/aws/setup.zsh @@ -0,0 +1,7 @@ +AWS__SETUP() { + STATUS 'starting aws setup' + "$DOTWRYN_PATH/bin/aws/configure" + + STATUS 'getting media from s3' + "$DOTWRYN_PATH/bin/aws/s3/sync-media" pull +} diff --git a/setup/dotconfig/setup.zsh b/setup/config/setup.zsh similarity index 61% rename from setup/dotconfig/setup.zsh rename to setup/config/setup.zsh index 8d705d4..acee77c 100644 --- a/setup/dotconfig/setup.zsh +++ b/setup/config/setup.zsh @@ -1,4 +1,4 @@ -DOTCONFIG__SETUP() { +CONFIG__SETUP() { ############################################################################################ # Friendly Name ~/.config/THE_REST .wryn/config/THE_REST (if different) CONFIG__SYMLINK 'compton' 'compton/compton.conf' @@ -19,6 +19,9 @@ DOTCONFIG__SETUP() { ############################################################################################ CONFIG__TERMINFO + + CONFIG__RC 'zsh' + CONFIG__RC 'vim' } function CONFIG__SYMLINK() { @@ -34,14 +37,52 @@ function CONFIG__SYMLINK() { CHECK "linking $1" { mv "$LOCAL_CONFIG" "$LOCAL_CONFIG.bak" - ln -s "$DOTWRYN_CONFIG" "$LOCAL_CONFIG" + ln -s "$DOTWRYN_CONFIG" "$LOCAL_CONFIG" } >>$LOG 2>&1 && OK || WARN } function CONFIG__TERMINFO() { for file in $(find "$DOTWRYN_PATH/config/terminfo" -type f); do - CHECK "adding '$(basename $file)'" + CHECK "adding $(basename $file)" tic -x $file >>$LOG 2>&1 \ && OK || WARN done } + +function CONFIG__RC() { + local DEFAULT_CONFIG="$DOTWRYN_PATH/env/env.$1" + local LOCAL_CONFIG="$HOME/.config/wryn/env/env.$1" + + [ -f $LOCAL_CONFIG ] && { + WARNING "local $1 configuration exists ($LOCAL_CONFIG)" + USER_PROMPT 'overwrite? [y/N]' + READ_K yn + [[ $yn =~ ^[yY] ]] && { + CHECK "backing up local copy ($LOCAL_CONFIG.bak)" + mv "$LOCAL_CONFIG" "$LOCAL_CONFIG.bak" && OK || WARN + } || { + STATUS 'skipping' + return + } + } + + CHECK "setting up $1 configuration ($LOCAL_CONFIG)" + + case $1 in + vim ) COMMENT='"' ;; + zsh ) COMMENT='#' ;; + esac + + { + echo "source $DEFAULT_CONFIG" + echo -e "\\n$COMMENT\n$COMMENT .wryn configuration overrides\n$COMMENT\n" + sed "s/^[^$COMMENT].*/$COMMENT&/" $DEFAULT_CONFIG + } > $LOCAL_CONFIG && OK || WARN + + USER_PROMPT 'change local configuration options? [y/N]' + READ_K yn + + [[ $yn =~ ^[yY] ]] && { + $EDITOR "$HOME/.config/wryn/env/env.$1" + } +} diff --git a/setup/linux b/setup/linux index 8bda08d..730d87f 100755 --- a/setup/linux +++ b/setup/linux @@ -118,7 +118,8 @@ MAKE_REQUIRED_DIRECTORY_STRUCTURE() { source "$DOTWRYN_PATH/setup/os-dependencies/setup.zsh" source "$DOTWRYN_PATH/setup/zsh/setup.zsh" source "$DOTWRYN_PATH/setup/vim/setup.zsh" -source "$DOTWRYN_PATH/setup/dotconfig/setup.zsh" +source "$DOTWRYN_PATH/setup/config/setup.zsh" +source "$DOTWRYN_PATH/setup/aws/setup.zsh" ################################################################################ @@ -132,9 +133,11 @@ GET_SUDO_PASSWORD OS_DEPENDENCY__SETUP || FATAL 'user abort' MAKE_REQUIRED_DIRECTORY_STRUCTURE -ZSH__SETUP || ERROR=1 -VIM__SETUP || ERROR=2 -DOTCONFIG__SETUP || ERROR=3 +CONFIG__SETUP || ERROR=1 + +ZSH__SETUP || ERROR=2 +VIM__SETUP || ERROR=3 +AWS__SETUP || ERROR=4 CLEANUP $ERROR diff --git a/setup/os-dependencies/arch.txt b/setup/os-dependencies/arch.txt index 5742cbd..ad1c778 100644 --- a/setup/os-dependencies/arch.txt +++ b/setup/os-dependencies/arch.txt @@ -1,4 +1,4 @@ -base-devel +aws-cli-v2 cmake cowsay figlet diff --git a/setup/os-dependencies/debian.txt b/setup/os-dependencies/debian.txt index 43241ac..3e3673f 100644 --- a/setup/os-dependencies/debian.txt +++ b/setup/os-dependencies/debian.txt @@ -1,3 +1,4 @@ +awscli build-essential cmake cowsay diff --git a/setup/os-dependencies/generic.txt b/setup/os-dependencies/generic.txt index 0249905..23ad7b0 100644 --- a/setup/os-dependencies/generic.txt +++ b/setup/os-dependencies/generic.txt @@ -1,3 +1,4 @@ +aws build-essential cmake cowsay diff --git a/setup/os-dependencies/setup.zsh b/setup/os-dependencies/setup.zsh index 6bcd0d1..e970c6b 100644 --- a/setup/os-dependencies/setup.zsh +++ b/setup/os-dependencies/setup.zsh @@ -21,6 +21,7 @@ function OS_DEPENDENCY__SETUP() { case $OS_NAME in arch ) OS_INSTALL() { OS_INSTALL__ARCH $@; } + WARNING 'base-devel is required; make sure it is installed' YAY__INSTALL_FROM_SOURCE ;; debian | ubuntu ) @@ -60,10 +61,6 @@ function OS_DEPENDENCY__SETUP() { function OS_INSTALL__ARCH() { local TARGET="$1" - [[ $TARGET =~ ^base-devel$ ]] && { - WARNING 'base-devel is required; make sure it is installed' - return 0 - } CHECK "checking for $TARGET" pacman -Qq | grep -q "^$TARGET$\|^$TARGET-git$" && OK || { WARN "$TARGET not found" diff --git a/setup/vim/setup.zsh b/setup/vim/setup.zsh index 310764a..e5a80f4 100644 --- a/setup/vim/setup.zsh +++ b/setup/vim/setup.zsh @@ -6,7 +6,6 @@ function VIM__SETUP() { STATUS 'starting vim setup' VIM__COMPILE_FROM_SOURCE VIM__SOURCE_RC - VIM__SET_LOCAL_CONFIG VIM__UPDATE_COLORSCHEMES VIM__INSTALL_VUNDLE_PLUGINS VIM__CREATE_PANE_DEFAULT_APP @@ -31,31 +30,6 @@ function VIM__SOURCE_RC() { } } -function VIM__SET_LOCAL_CONFIG() { - local DEFAULT_CONFIG="$DOTWRYN_PATH/env/env.vim" - local LOCAL_CONFIG="$HOME/.config/wryn/env/env.vim" - - [ -f $LOCAL_CONFIG ] && { - WARNING "local vim env configuration ($LOCAL_CONFIG)" - USER_PROMPT 'overwrite? [y/N]' - READ_K yn - [[ $yn =~ ^[yY] ]] && { - CHECK "backing up local copy ($LOCAL_CONFIG.bak)" - mv "$LOCAL_CONFIG" "$LOCAL_CONFIG.bak" && OK || WARN - } || { - STATUS 'skipping' - return - } - } - - CHECK "setting vim configuration file ($LOCAL_CONFIG)" - { - echo "source $DEFAULT_CONFIG" - echo -e '\n"\n" .wryn configuration overrides\n"\n' - sed 's/["]*\(.*\)/"\1/' $DEFAULT_CONFIG - } > $LOCAL_CONFIG && OK || WARN -} - function VIM__UPDATE_COLORSCHEMES() { CHECK 'updating colorschemes' $DOTWRYN_PATH/bin/vim/update_colorschemes >>$LOG 2>&1\ diff --git a/setup/zsh/setup.zsh b/setup/zsh/setup.zsh index 6a89ee7..6d91054 100644 --- a/setup/zsh/setup.zsh +++ b/setup/zsh/setup.zsh @@ -3,7 +3,6 @@ function ZSH__SETUP() { ZSH__SET_DEFAULT_SHELL ZSH__SOURCE_RC - ZSH__SET_LOCAL_CONFIG } ##################################################################### @@ -27,28 +26,3 @@ function ZSH__SOURCE_RC() { && OK || WARN } } - -function ZSH__SET_LOCAL_CONFIG() { - local DEFAULT_CONFIG="$DOTWRYN_PATH/env/env.zsh" - local LOCAL_CONFIG="$HOME/.config/wryn/env/env.zsh" - - [ -f $LOCAL_CONFIG ] && { - WARNING "local zsh env configuration ($LOCAL_CONFIG)" - USER_PROMPT 'overwrite? [y/N]' - READ_K yn - [[ $yn =~ ^[yY] ]] && { - CHECK "backing up local copy ($LOCAL_CONFIG.bak)" - mv "$LOCAL_CONFIG" "$LOCAL_CONFIG.bak" && OK || WARN - } || { - STATUS 'skipping' - return - } - } - - CHECK "setting zsh configuration file ($LOCAL_CONFIG)" - { - echo "source $DEFAULT_CONFIG" - echo -e '\n#\n# .wryn configuration overrides\n#\n' - sed 's/^[^#].*/#&/' $DEFAULT_CONFIG - } > $LOCAL_CONFIG && OK || WARN -}