basic runner format; write a MAIN function

This commit is contained in:
Wryn (yage) Wagner 2024-02-06 14:06:44 -07:00
parent a200c1eb22
commit fcf492c661
50 changed files with 298 additions and 522 deletions

View File

@ -1,10 +1,7 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use cloud/aws/ecr use cloud/aws/ecr
CHECK_ENVIRONMENT
##################################################################### #####################################################################
ECR_LOGIN $@ MAIN() {
ECR_LOGIN $@
}

View File

@ -3,11 +3,9 @@ DEPENDENCIES+=(jq)
REQUIRED_ENV+=(AWS__EFS__LOCAL_MOUNT_POINT) REQUIRED_ENV+=(AWS__EFS__LOCAL_MOUNT_POINT)
use cloud/aws/cli use cloud/aws/cli
CHECK_ENVIRONMENT
##################################################################### #####################################################################
EFS_CONNECT() { MAIN() {
GETSUDO || exit 1 GETSUDO || exit 1
[ ! -d $AWS__EFS__LOCAL_MOUNT_POINT ] && { [ ! -d $AWS__EFS__LOCAL_MOUNT_POINT ] && {
sudo mkdir $AWS__EFS__LOCAL_MOUNT_POINT \ sudo mkdir $AWS__EFS__LOCAL_MOUNT_POINT \
@ -64,6 +62,3 @@ EFS_CONNECT() {
FAIL 2 "unable to mount '$FS_ID'" FAIL 2 "unable to mount '$FS_ID'"
} }
} }
#####################################################################
EFS_CONNECT $@

View File

@ -3,11 +3,9 @@ DEPENDENCIES+=(jq)
REQUIRED_ENV+=(AWS__EFS__LOCAL_MOUNT_POINT) REQUIRED_ENV+=(AWS__EFS__LOCAL_MOUNT_POINT)
use cloud/aws/cli use cloud/aws/cli
CHECK_ENVIRONMENT
##################################################################### #####################################################################
EFS_DISCONNECT() { MAIN() {
[ ! -d "$AWS__EFS__LOCAL_MOUNT_POINT" ] && { [ ! -d "$AWS__EFS__LOCAL_MOUNT_POINT" ] && {
STATUS 'no efs currently mounted' STATUS 'no efs currently mounted'
exit 0 exit 0
@ -32,6 +30,3 @@ EFS_DISCONNECT() {
&& SUCCESS "done" \ && SUCCESS "done" \
|| FAIL 2 "failed to unmount '$EFS'" || FAIL 2 "failed to unmount '$EFS'"
} }
#####################################################################
EFS_DISCONNECT $@

View File

@ -1,10 +1,7 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use cloud/aws/eks use cloud/aws/eks
CHECK_ENVIRONMENT
##################################################################### #####################################################################
EKS__CLUSTER_LOGIN $@ MAIN() {
EKS__CLUSTER_LOGIN $@
}

View File

@ -1,19 +1,11 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use cloud/aws/rds use cloud/aws/rds
use db/postgres use db/postgres
CHECK_ENVIRONMENT
##################################################################### #####################################################################
CREATE_BACKUP() { MAIN() {
local DB_HOST DB_PORT DB_NAME DB_USER DB_PASS local DB_HOST DB_PORT DB_NAME DB_USER DB_PASS
RDS__GET_DATABASE_CREDENTIALS $@ || return 1 RDS__GET_DATABASE_CREDENTIALS $@ || return 1
PG_DUMP PG_DUMP
} }
#####################################################################
CREATE_BACKUP $@

View File

@ -1,20 +1,11 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use cloud/aws/rds use cloud/aws/rds
use db/postgres use db/postgres
CHECK_ENVIRONMENT
##################################################################### #####################################################################
RDS_INTERACTIVE_LOGIN() { MAIN() {
local DB_HOST DB_PORT DB_NAME DB_USER DB_PASS local DB_HOST DB_PORT DB_NAME DB_USER DB_PASS
RDS__GET_DATABASE_CREDENTIALS $@ || return 1 RDS__GET_DATABASE_CREDENTIALS $@ || return 1
POSTGRES__LOGIN_INTERACTIVE POSTGRES__LOGIN_INTERACTIVE
} }
#####################################################################
RDS_INTERACTIVE_LOGIN $@

View File

@ -1,20 +1,11 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use cloud/aws/rds use cloud/aws/rds
use db/postgres use db/postgres
CHECK_ENVIRONMENT
##################################################################### #####################################################################
LOAD_BACKUP() { MAIN() {
local DB_HOST DB_PORT DB_NAME DB_USER DB_PASS local DB_HOST DB_PORT DB_NAME DB_USER DB_PASS
RDS__GET_DATABASE_CREDENTIALS $@ || return 1 RDS__GET_DATABASE_CREDENTIALS $@ || return 1
PG_RESTORE PG_RESTORE
} }
#####################################################################
LOAD_BACKUP $@

View File

@ -1,11 +1,9 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=(cli53) DEPENDENCIES+=(cli53)
REQUIRED_ENV+=(AWS_PROFILE) REQUIRED_ENV+=(AWS_PROFILE)
CHECK_ENVIRONMENT
##################################################################### #####################################################################
ROUTE53_BACKUP() { MAIN() {
local BACKUP_PATH="$SCWRYPTS_OUTPUT_PATH/$ENV_NAME/aws-dns-backup/$(date '+%Y-%m-%d')" local BACKUP_PATH="$SCWRYPTS_OUTPUT_PATH/$ENV_NAME/aws-dns-backup/$(date '+%Y-%m-%d')"
mkdir -p $BACKUP_PATH >/dev/null 2>&1 mkdir -p $BACKUP_PATH >/dev/null 2>&1
@ -25,12 +23,11 @@ ROUTE53_BACKUP() {
for P in ${JOBS[@]}; do wait $P >/dev/null 2>&1; done for P in ${JOBS[@]}; do wait $P >/dev/null 2>&1; done
} }
#####################################################################
ROUTE53_GET_DOMAINS() { ROUTE53_GET_DOMAINS() {
cli53 list --profile $AWS_PROFILE \ cli53 list --profile $AWS_PROFILE \
| awk '{print $2;}' \ | awk '{print $2;}' \
| sed '1d; s/\.$//'\ | sed '1d; s/\.$//'\
; ;
} }
#####################################################################
ROUTE53_BACKUP

View File

@ -1,10 +1,7 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use cloud/media-sync use cloud/media-sync
CHECK_ENVIRONMENT
##################################################################### #####################################################################
MEDIA_SYNC__PULL $@ MAIN() {
MEDIA_SYNC__PULL $@
}

View File

@ -1,10 +1,7 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use cloud/media-sync use cloud/media-sync
CHECK_ENVIRONMENT
##################################################################### #####################################################################
MEDIA_SYNC__PUSH $@ MAIN() {
MEDIA_SYNC__PUSH $@
}

View File

@ -1,9 +1,7 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use db/postgres use db/postgres
CHECK_ENVIRONMENT
##################################################################### #####################################################################
POSTGRES__LOGIN_INTERACTIVE $@
MAIN() {
POSTGRES__LOGIN_INTERACTIVE $@
}

View File

@ -1,9 +1,7 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use db/postgres use db/postgres
CHECK_ENVIRONMENT
##################################################################### #####################################################################
PG_DUMP $@
MAIN() {
PG_DUMP $@
}

View File

@ -1,9 +1,7 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use db/postgres use db/postgres
CHECK_ENVIRONMENT
##################################################################### #####################################################################
PG_RESTORE $@
MAIN() {
PG_RESTORE $@
}

View File

@ -1,13 +1,9 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use db/postgres use db/postgres
CHECK_ENVIRONMENT
##################################################################### #####################################################################
RUN_SQL_POSTGRES() { MAIN() {
WARNING " \nthis function is in a beta state\n "
local _PASS _ARGS=() local _PASS _ARGS=()
POSTGRES__SET_LOGIN_ARGS $@ POSTGRES__SET_LOGIN_ARGS $@
@ -43,9 +39,3 @@ RUN_SQL_POSTGRES() {
&& SUCCESS "finished running '$INPUT_FILE'" \ && SUCCESS "finished running '$INPUT_FILE'" \
|| FAIL 3 "something went wrong running '$INPUT_FILE' (see above)" || FAIL 3 "something went wrong running '$INPUT_FILE' (see above)"
} }
#####################################################################
WARNING
WARNING 'this function is in a beta state'
WARNING
RUN_SQL_POSTGRES $@

View File

@ -1,11 +1,8 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=(docker) DEPENDENCIES+=(docker)
REQUIRED_ENV+=()
CHECK_ENVIRONMENT
##################################################################### #####################################################################
DOCKER_CLEAN() { MAIN() {
WARNING 'this will prune all docker resources from the current machine' WARNING 'this will prune all docker resources from the current machine'
WARNING 'pruned resources are PERMANENTLY DELETED' WARNING 'pruned resources are PERMANENTLY DELETED'
yN 'continue?' || return 1 yN 'continue?' || return 1
@ -14,6 +11,3 @@ DOCKER_CLEAN() {
SUCCESS "IMAGE : $(docker image prune -f 2>/dev/null | tail -n 1)" SUCCESS "IMAGE : $(docker image prune -f 2>/dev/null | tail -n 1)"
SUCCESS "VOLUME : $(docker volume prune -f 2>/dev/null | tail -n 1)" SUCCESS "VOLUME : $(docker volume prune -f 2>/dev/null | tail -n 1)"
} }
#####################################################################
DOCKER_CLEAN $@

View File

@ -1,8 +1,4 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=() MAIN() {
REQUIRED_ENV+=() SUCCESS 'hello world!'
}
CHECK_ENVIRONMENT
#####################################################################
SUCCESS 'hello world!'

View File

@ -1,17 +1,9 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use helm use helm
use scwrypts use scwrypts
CHECK_ENVIRONMENT
##################################################################### #####################################################################
MAIN() { MAIN() {
unset USAGE unset USAGE
HELM__TEMPLATE__GET $@ HELM__TEMPLATE__GET $@
} }
#####################################################################
MAIN $@

View File

@ -1,17 +1,9 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use helm use helm
use scwrypts use scwrypts
CHECK_ENVIRONMENT
##################################################################### #####################################################################
MAIN() { MAIN() {
unset USAGE unset USAGE
HELM__DEPENDENCY__UPDATE $@ HELM__DEPENDENCY__UPDATE $@
} }
#####################################################################
MAIN $@

View File

@ -112,11 +112,28 @@ SCWRYPTS__GET_RUNSTRING() {
SCWRYPTS__GET_RUNSTRING__zsh() { SCWRYPTS__GET_RUNSTRING__zsh() {
__CHECK_DEPENDENCY zsh || return 1 __CHECK_DEPENDENCY zsh || return 1
local SCWRYPT_FILENAME
[ $(eval echo '$SCWRYPTS_TYPE__'$SCWRYPT_GROUP) ] \
&& SCWRYPT_FILENAME="$GROUP_PATH/$SCWRYPT_NAME" \
|| SCWRYPT_FILENAME="$GROUP_PATH/$SCWRYPT_TYPE/$SCWRYPT_NAME" \
;
echo "source '$SCWRYPT_FILENAME'; CHECK_ENVIRONMENT; MAIN"
return 0
}
SCWRYPTS__GET_RUNSTRING__zsh_v3_compatibility() {
__CHECK_DEPENDENCY zsh || return 1
[ $(eval echo '$SCWRYPTS_TYPE__'$SCWRYPT_GROUP) ] \ [ $(eval echo '$SCWRYPTS_TYPE__'$SCWRYPT_GROUP) ] \
&& echo "source $GROUP_PATH/$SCWRYPT_NAME" \ && echo "source $GROUP_PATH/$SCWRYPT_NAME" \
|| echo "source $GROUP_PATH/$SCWRYPT_TYPE/$SCWRYPT_NAME" \ || echo "source $GROUP_PATH/$SCWRYPT_TYPE/$SCWRYPT_NAME" \
; ;
WARNING "scwrypts zsh/v3 runstrings are now deprecated; please update to scwrypts v4 format"
return 0 return 0
} }

View File

@ -1,13 +1,8 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use media/youtube use media/youtube
CHECK_ENVIRONMENT
##################################################################### #####################################################################
DOWNLOAD_VIDEO() { MAIN() {
local URLS=($@) local URLS=($@)
[[ ${#URLS[@]} -eq 0 ]] && URLS=($(echo '' | FZF_HEAD 'enter URL')) [[ ${#URLS[@]} -eq 0 ]] && URLS=($(echo '' | FZF_HEAD 'enter URL'))
@ -23,6 +18,3 @@ DOWNLOAD_VIDEO() {
&& SUCCESS "downloaded to '$YT__OUTPUT_DIR/$FILENAME'" \ && SUCCESS "downloaded to '$YT__OUTPUT_DIR/$FILENAME'" \
|| { ERROR "failed to download '$FILENAME'"; return 2; } || { ERROR "failed to download '$FILENAME'"; return 2; }
} }
#####################################################################
DOWNLOAD_VIDEO $@

View File

@ -1,13 +1,8 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use media/youtube use media/youtube
CHECK_ENVIRONMENT
##################################################################### #####################################################################
GET_AUDIO_CLIP() { MAIN() {
local URLS=($@) local URLS=($@)
[[ ${#URLS[@]} -eq 0 ]] && URLS=($(echo '' | FZF_HEAD 'enter URL')) [[ ${#URLS[@]} -eq 0 ]] && URLS=($(echo '' | FZF_HEAD 'enter URL'))
@ -49,6 +44,3 @@ GET_AUDIO_CLIP() {
&& SUCCESS "created clip '$OUTPUT_FILE'" \ && SUCCESS "created clip '$OUTPUT_FILE'" \
|| { ERROR "error creating clip '$(basename $OUTPUT_FILE)' (see above)"; return 3; } || { ERROR "error creating clip '$(basename $OUTPUT_FILE)' (see above)"; return 3; }
} }
#####################################################################
GET_AUDIO_CLIP $@

View File

@ -1,17 +1,8 @@
#!/bin/zsh #!/bin/zsh
#####################################################################
DEPENDENCIES+=()
REQUIRED_ENV+=()
use misc/tally use misc/tally
CHECK_ENVIRONMENT
##################################################################### #####################################################################
MAIN() { MAIN() {
unset USAGE unset USAGE
TALLY $@ TALLY $@
} }
#####################################################################
MAIN $@

View File

@ -1,13 +1,8 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use office/latex use office/latex
CHECK_ENVIRONMENT
##################################################################### #####################################################################
PDFLATEX() { MAIN() {
[ ! $1 ] && FAIL 1 'must provide filename' [ ! $1 ] && FAIL 1 'must provide filename'
local FILENAME=$(LATEX__GET_MAIN_FILENAME "$1") local FILENAME=$(LATEX__GET_MAIN_FILENAME "$1")
@ -26,6 +21,3 @@ PDFLATEX() {
SUCCESS "created '$(echo $FILENAME | sed 's/\.[^.]*$/.pdf/')'" SUCCESS "created '$(echo $FILENAME | sed 's/\.[^.]*$/.pdf/')'"
} }
#####################################################################
PDFLATEX $@

View File

@ -1,13 +1,8 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use office/latex use office/latex
CHECK_ENVIRONMENT
##################################################################### #####################################################################
CLEAN_LATEX_LOGFILES() { MAIN() {
local DIRECTORY=$(SCWRYPTS__GET_REALPATH ".") local DIRECTORY=$(SCWRYPTS__GET_REALPATH ".")
[ $1 ] && DIRECTORY="$(dirname "$(LATEX__GET_MAIN_FILENAME "$1")")" [ $1 ] && DIRECTORY="$(dirname "$(LATEX__GET_MAIN_FILENAME "$1")")"
[ $DIRECTORY ] && [ -d $DIRECTORY ] \ [ $DIRECTORY ] && [ -d $DIRECTORY ] \
@ -18,6 +13,3 @@ CLEAN_LATEX_LOGFILES() {
SUCCESS "cleaned up latex artifacts in '$DIRECTORY'" SUCCESS "cleaned up latex artifacts in '$DIRECTORY'"
} }
#####################################################################
CLEAN_LATEX_LOGFILES $@

View File

@ -1,15 +1,10 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use office/latex use office/latex
CHECK_ENVIRONMENT
##################################################################### #####################################################################
TEMPLATE_DIR="${0:a:h}/templates" TEMPLATE_DIR="${0:a:h}/templates"
CREATE_NEW_LATEX_DOCUMENT_FROM_TEMPLATE() { MAIN() {
local DOCUMENT_DIR="$EXECUTION_DIR" local DOCUMENT_DIR="$EXECUTION_DIR"
local TEMPLATE=$(GET_TEMPLATES | FZF 'select a template') local TEMPLATE=$(GET_TEMPLATES | FZF 'select a template')
[ ! $TEMPLATE ] && ABORT [ ! $TEMPLATE ] && ABORT
@ -39,6 +34,8 @@ CREATE_NEW_LATEX_DOCUMENT_FROM_TEMPLATE() {
SUCCESS "finished generating '$(basename $DOCUMENT_FILE)' from '$TEMPLATE'" SUCCESS "finished generating '$(basename $DOCUMENT_FILE)' from '$TEMPLATE'"
} }
#####################################################################
GET_TEMPLATES() { GET_TEMPLATES() {
find "$TEMPLATE_DIR" -type d | sed "s^$TEMPLATE_DIR/*^^; /^$/d" find "$TEMPLATE_DIR" -type d | sed "s^$TEMPLATE_DIR/*^^; /^$/d"
} }
@ -59,4 +56,4 @@ SLUGIFY_TITLE() {
} }
##################################################################### #####################################################################
CREATE_NEW_LATEX_DOCUMENT_FROM_TEMPLATE $@ MAIN $@

View File

@ -1,10 +1,7 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use office/latex use office/latex
CHECK_ENVIRONMENT
##################################################################### #####################################################################
LATEX__GET_PDF $@ MAIN() {
LATEX__GET_PDF $@
}

View File

@ -1,18 +1,10 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use office/latex use office/latex
CHECK_ENVIRONMENT
##################################################################### #####################################################################
OPEN_PDF() { MAIN() {
local PDF=$(LATEX__GET_PDF $@) local PDF=$(LATEX__GET_PDF $@)
[ ! $PDF ] && return 1 [ ! $PDF ] && return 1
OPEN "$PDF" OPEN "$PDF"
} }
#####################################################################
OPEN_PDF $@

View File

@ -1,13 +1,8 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use office/memo use office/memo
CHECK_ENVIRONMENT
##################################################################### #####################################################################
OPEN_MEMO() { MAIN() {
local MEMO_NAME=$(MEMO__LIST_ALL | FZF_TAIL 'select/create a memo') local MEMO_NAME=$(MEMO__LIST_ALL | FZF_TAIL 'select/create a memo')
[ ! "$MEMO_NAME" ] && ABORT [ ! "$MEMO_NAME" ] && ABORT
@ -26,6 +21,3 @@ OPEN_MEMO() {
EDIT "$MEMO_FILE" EDIT "$MEMO_FILE"
} }
#####################################################################
OPEN_MEMO $@

View File

@ -1,13 +1,8 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use office/memo use office/memo
CHECK_ENVIRONMENT
##################################################################### #####################################################################
DELETE_MEMO() { MAIN() {
local MEMO_NAME=$(MEMO__LIST_ALL | FZF 'select a memo to delete') local MEMO_NAME=$(MEMO__LIST_ALL | FZF 'select a memo to delete')
local MEMO_FILE="$MEMO__DIR/$MEMO_NAME.$MEMO__FILETYPE" local MEMO_FILE="$MEMO__DIR/$MEMO_NAME.$MEMO__FILETYPE"
[ "$MEMO_NAME" ] && [ -f "$MEMO_FILE" ] || ABORT [ "$MEMO_NAME" ] && [ -f "$MEMO_FILE" ] || ABORT
@ -28,6 +23,3 @@ DELETE_MEMO() {
|| FAIL 1 "failed to remove memo '$MEMO_NAME'" \ || FAIL 1 "failed to remove memo '$MEMO_NAME'" \
; ;
} }
#####################################################################
DELETE_MEMO $@

View File

@ -1,13 +1,8 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use redis use redis
CHECK_ENVIRONMENT
##################################################################### #####################################################################
CURL_WITH_CACHE() { MAIN() {
[ ! $TTL ] && TTL=10 [ ! $TTL ] && TTL=10
[[ $(REDIS__ENABLED) -eq 0 ]] && { [[ $(REDIS__ENABLED) -eq 0 ]] && {
@ -46,7 +41,6 @@ CURL_WITH_CACHE() {
echo $OUTPUT echo $OUTPUT
} }
GET_URL_KEY() { echo "scwrypts:curl:$1" | sed 's/\s\+/+/g'; }
##################################################################### #####################################################################
CURL_WITH_CACHE $@
GET_URL_KEY() { echo "scwrypts:curl:$1" | sed 's/\s\+/+/g'; }

View File

@ -1,15 +1,11 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/meta use scwrypts/meta
CHECK_ENVIRONMENT
##################################################################### #####################################################################
USER_CONFIG_OVERRIDES="$SCWRYPTS_CONFIG_PATH/config.zsh" MAIN() {
local USER_CONFIG_OVERRIDES="$SCWRYPTS_CONFIG_PATH/config.zsh"
[ ! -f "$USER_CONFIG_OVERRIDES" ] && { [ ! -f "$USER_CONFIG_OVERRIDES" ] && {
STATUS 'first-time setup detected; creating local configuration override...' STATUS 'first-time setup detected; creating local configuration override...'
cp "$DEFAULT_CONFIG" "$USER_CONFIG_OVERRIDES" cp "$DEFAULT_CONFIG" "$USER_CONFIG_OVERRIDES"
@ -27,10 +23,11 @@ USER_CONFIG_OVERRIDES="$SCWRYPTS_CONFIG_PATH/config.zsh"
scwrypts --name scwrypts/virtualenv/update-all --group scwrypts --type zsh scwrypts --name scwrypts/virtualenv/update-all --group scwrypts --type zsh
' '
} || { } || {
EDIT "$USER_CONFIG_OVERRIDES" EDIT "$USER_CONFIG_OVERRIDES"
}
SUCCESS 'saved new configuration'
REMINDER 'changes which affect the hot-key plugin will require a ZSHRC reload'
} }
SUCCESS 'saved new configuration'
REMINDER 'changes which affect the hot-key plugin will require a ZSHRC reload'

View File

@ -1,25 +1,21 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/environment-files use scwrypts/environment-files
CHECK_ENVIRONMENT
##################################################################### #####################################################################
PROMPT 'choose an environment to copy' MAIN() {
TEMPLATE_ENV_NAME=$(SCWRYPTS__SELECT_ENV) PROMPT 'choose an environment to copy'
[ ! $TEMPLATE_ENV_NAME ] && ABORT TEMPLATE_ENV_NAME=$(SCWRYPTS__SELECT_ENV)
[ ! $TEMPLATE_ENV_NAME ] && ABORT
STATUS "selected '$TEMPLATE_ENV_NAME'" STATUS "selected '$TEMPLATE_ENV_NAME'"
PROMPT 'enter new environment name' PROMPT 'enter new environment name'
ENV_NAME=$(echo '' | FZF_HEAD 'new environment') ENV_NAME=$(echo '' | FZF_HEAD 'new environment')
[ ! $ENV_NAME ] && ABORT [ ! $ENV_NAME ] && ABORT
SCWRYPTS__GET_ENV_NAMES | grep -q $ENV_NAME && FAIL 1 "'$ENV_NAME' already exists" SCWRYPTS__GET_ENV_NAMES | grep -q $ENV_NAME && FAIL 1 "'$ENV_NAME' already exists"
for GROUP in ${SCWRYPTS_GROUPS[@]} for GROUP in ${SCWRYPTS_GROUPS[@]}
do do
TEMPLATE_ENV_FILE=$(SCWRYPTS__GET_ENV_FILE $TEMPLATE_ENV_NAME $GROUP 2>/dev/null) TEMPLATE_ENV_FILE=$(SCWRYPTS__GET_ENV_FILE $TEMPLATE_ENV_NAME $GROUP 2>/dev/null)
ENV_FILE=$(SCWRYPTS__GET_ENV_FILE $ENV_NAME $GROUP 2>/dev/null) ENV_FILE=$(SCWRYPTS__GET_ENV_FILE $ENV_NAME $GROUP 2>/dev/null)
@ -29,10 +25,11 @@ do
> "$ENV_FILE" \ > "$ENV_FILE" \
&& SUCCESS "created '$ENV_FILE'" \ && SUCCESS "created '$ENV_FILE'" \
|| FAIL 2 "something went wrong creating '$ENV_FILE'" || FAIL 2 "something went wrong creating '$ENV_FILE'"
done done
STATUS "synchronizing environments" STATUS "synchronizing environments"
SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \ SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \
&& SUCCESS "finished copy environment '$TEMPLATE_ENV_NAME > $ENV_NAME'" \ && SUCCESS "finished copy environment '$TEMPLATE_ENV_NAME > $ENV_NAME'" \
|| FAIL 3 'error during synchronization of new environment (see above)' \ || FAIL 3 'error during synchronization of new environment (see above)' \
; ;
}

View File

@ -1,36 +1,33 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/environment-files use scwrypts/environment-files
CHECK_ENVIRONMENT
##################################################################### #####################################################################
PROMPT 'choose an environment to delete' MAIN() {
ENV_NAME=$(SCWRYPTS__SELECT_ENV) PROMPT 'choose an environment to delete'
[ ! $ENV_NAME ] && ABORT ENV_NAME=$(SCWRYPTS__SELECT_ENV)
[ ! $ENV_NAME ] && ABORT
ENV_FILES=($(SCWRYPTS__GET_ENV_FILES $ENV_NAME)) ENV_FILES=($(SCWRYPTS__GET_ENV_FILES $ENV_NAME))
STATUS "preparing to remove '$ENV_NAME'" STATUS "preparing to remove '$ENV_NAME'"
WARNING " WARNING "
the '$ENV_NAME' environment will be removed configured options the '$ENV_NAME' environment will be removed configured options
and stored credentials will be lost forever: and stored credentials will be lost forever:
$(echo $ENV_FILES | sed 's| /|\n - /|g; s/^/ - /') $(echo $ENV_FILES | sed 's| /|\n - /|g; s/^/ - /')
" "
yN 'continue?' || ABORT yN 'continue?' || ABORT
STATUS "removing environment" STATUS "removing environment"
for ENV_FILE in ${ENV_FILES[@]} for ENV_FILE in ${ENV_FILES[@]}
do do
rm "$ENV_FILE" \ rm "$ENV_FILE" \
&& SUCCESS "removed '$ENV_FILE'" \ && SUCCESS "removed '$ENV_FILE'" \
|| ERROR "unable to remove '$ENV_FILE'; is it protected?" \ || ERROR "unable to remove '$ENV_FILE'; is it protected?" \
; ;
done done
CHECK_ERRORS -n || FAIL 2 "some errors ocurred when cleaning up $ENV_NAME" CHECK_ERRORS -n || FAIL 2 "some errors ocurred when cleaning up $ENV_NAME"
}

View File

@ -1,24 +1,20 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/environment-files use scwrypts/environment-files
CHECK_ENVIRONMENT
##################################################################### #####################################################################
[ $1 ] && ENV_NAME="$1" MAIN() {
[ $1 ] && ENV_NAME="$1"
[ ! $1 ] && { [ ! $1 ] && {
[ $SCWRYPTS_ENV ] \ [ $SCWRYPTS_ENV ] \
&& ENV_NAME=$SCWRYPTS_ENV \ && ENV_NAME=$SCWRYPTS_ENV \
|| ENV_NAME=$(SCWRYPTS__SELECT_OR_CREATE_ENV) || ENV_NAME=$(SCWRYPTS__SELECT_OR_CREATE_ENV)
} }
[ ! $ENV_NAME ] && ABORT [ ! $ENV_NAME ] && ABORT
ENV_FILES=($(SCWRYPTS__GET_ENV_FILES $ENV_NAME 2>/dev/null)) ENV_FILES=($(SCWRYPTS__GET_ENV_FILES $ENV_NAME 2>/dev/null))
for ENV_FILE in ${ENV_FILES[@]} for ENV_FILE in ${ENV_FILES[@]}
do do
[ ! -f "$ENV_FILE" ] && { [ ! -f "$ENV_FILE" ] && {
STATUS "Creating '$ENV_FILE'..." \ STATUS "Creating '$ENV_FILE'..." \
&& mkdir -p "$(dirname "$ENV_FILE")" \ && mkdir -p "$(dirname "$ENV_FILE")" \
@ -34,12 +30,13 @@ do
|| FAIL 1 "failure during sync for '$ENV_NAME'" \ || FAIL 1 "failure during sync for '$ENV_NAME'" \
} }
; ;
done done
EDIT $ENV_FILES EDIT $ENV_FILES
SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \ SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \
|| FAIL 4 'failed to run environment sync' \ || FAIL 4 'failed to run environment sync' \
; ;
SUCCESS "environment '$ENV_NAME' successfully modified" SUCCESS "environment '$ENV_NAME' successfully modified"
}

View File

@ -1,13 +1,8 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/environment-files use scwrypts/environment-files
CHECK_ENVIRONMENT
##################################################################### #####################################################################
SYNCHRONIZE() { MAIN() {
while [[ $# -gt 0 ]] while [[ $# -gt 0 ]]
do do
case $1 in case $1 in
@ -176,4 +171,4 @@ CLEANUP_ENVIRONMENT_FILE() {
} }
##################################################################### #####################################################################
SYNCHRONIZE $@ MAIN $@

View File

@ -1,22 +1,20 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
CHECK_ENVIRONMENT
##################################################################### #####################################################################
cd $SCWRYPTS_ROOT MAIN() {
cd $SCWRYPTS_ROOT
STATUS "Found $(ls $SCWRYPTS_LOG_PATH | wc -l) log files" STATUS "Found $(ls $SCWRYPTS_LOG_PATH | wc -l) log files"
WARNING " WARNING "
this will permanently clear all local cloud script logs found in this will permanently clear all local cloud script logs found in
'$SCWRYPTS_LOG_PATH' '$SCWRYPTS_LOG_PATH'
" "
yN 'continue?' || ABORT yN 'continue?' || ABORT
STATUS 'removing logfiles' STATUS 'removing logfiles'
rm -rf $SCWRYPTS_LOG_PATH/* \ rm -rf $SCWRYPTS_LOG_PATH/* \
&& SUCCESS 'done' \ && SUCCESS 'done' \
|| { ERROR 'failed :c'; exit 2; }\ || { ERROR 'failed :c'; exit 2; }\
; ;
}

View File

@ -1,15 +1,13 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
CHECK_ENVIRONMENT
##################################################################### #####################################################################
cd $SCWRYPTS_ROOT MAIN() {
PROMPT 'select a script log' cd $SCWRYPTS_ROOT
LOG_FILE=$(ls -t $SCWRYPTS_LOG_PATH | FZF 'logfile') PROMPT 'select a script log'
[ ! $LOG_FILE ] && { ERROR 'user abort'; exit 1; } LOG_FILE=$(ls -t $SCWRYPTS_LOG_PATH | FZF 'logfile')
[ ! $LOG_FILE ] && { ERROR 'user abort'; exit 1; }
STATUS 'opening logfile' STATUS 'opening logfile'
LESS "$SCWRYPTS_LOG_PATH/$LOG_FILE" LESS "$SCWRYPTS_LOG_PATH/$LOG_FILE"
SUCCESS 'done' SUCCESS 'done'
}

View File

@ -1,30 +1,27 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/virtualenv use scwrypts/virtualenv
CHECK_ENVIRONMENT
##################################################################### #####################################################################
while [[ $# -gt 0 ]] MAIN() {
do while [[ $# -gt 0 ]]
do
case $1 in case $1 in
-g | --group ) ENV_GROUP="$2"; shift 1 ;; -g | --group ) ENV_GROUP="$2"; shift 1 ;;
esac esac
shift 1 shift 1
done done
[ ! $ENV_GROUP ] && ENV_GROUP=scwrypts [ ! $ENV_GROUP ] && ENV_GROUP=scwrypts
ENV_TYPE=$(echo $AVAILABLE_VIRTUALENVS | sed 's/ \+/\n/' | FZF 'select an environment to refresh') ENV_TYPE=$(echo $AVAILABLE_VIRTUALENVS | sed 's/ \+/\n/' | FZF 'select an environment to refresh')
[ ! $ENV_TYPE ] && ABORT [ ! $ENV_TYPE ] && ABORT
REMINDER " REMINDER "
this will permanently remove all artifacts for the scwrypts $ENV_TYPE environment this will permanently remove all artifacts for the scwrypts $ENV_TYPE environment
(safe unless you have put something important in $(GET_VIRTUALENV_PATH $ENV_GROUP $ENV_TYPE)) (safe unless you have put something important in $(GET_VIRTUALENV_PATH $ENV_GROUP $ENV_TYPE))
" "
Yn "drop and recreate $ENV_TYPE virtual environment?" || ABORT Yn "drop and recreate $ENV_TYPE virtual environment?" || ABORT
REFRESH_VIRTUALENV $ENV_GROUP $ENV_TYPE REFRESH_VIRTUALENV $ENV_GROUP $ENV_TYPE
}

View File

@ -1,25 +1,21 @@
#!/bin/zsh #!/bin/zsh
echo hey
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/virtualenv use scwrypts/virtualenv
CHECK_ENVIRONMENT
##################################################################### #####################################################################
STATUS 'beginning update for all environments' MAIN() {
STATUS 'beginning update for all environments'
FAILED_COUNT=0 FAILED_COUNT=0
for ENV_GROUP in ${SCWRYPTS_GROUPS[@]} for ENV_GROUP in ${SCWRYPTS_GROUPS[@]}
do do
for ENV_TYPE in ${AVAILABLE_VIRTUALENVS[@]} for ENV_TYPE in ${AVAILABLE_VIRTUALENVS[@]}
do do
UPDATE_VIRTUALENV $ENV_GROUP $ENV_TYPE || ((FAILED_COUNT+=1)) UPDATE_VIRTUALENV $ENV_GROUP $ENV_TYPE || ((FAILED_COUNT+=1))
done done
done done
[[ $FAILED_COUNT -eq 0 ]] \ [[ $FAILED_COUNT -eq 0 ]] \
&& SUCCESS 'all environments up-to-date' \ && SUCCESS 'all environments up-to-date' \
|| FAIL $FAILED_COUNT "failed to update $FAILED_COUNT more environment(s)" || FAIL $FAILED_COUNT "failed to update $FAILED_COUNT more environment(s)"
}

View File

@ -1,9 +1,7 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use system/config use system/config
CHECK_ENVIRONMENT
##################################################################### #####################################################################
EDIT "$CONFIG__USER_SETTINGS"
MAIN() {
EDIT "$CONFIG__USER_SETTINGS"
}

View File

@ -1,19 +1,16 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use system/config use system/config
CHECK_ENVIRONMENT
##################################################################### #####################################################################
SETUP_SYMLINKS() { MAIN() {
while read SYMLINK while read SYMLINK
do do
SETUP_SYMLINK $(echo $SYMLINK | awk '{print $1;}') $(echo $SYMLINK | awk '{print $2}') SETUP_SYMLINK $(echo $SYMLINK | awk '{print $1;}') $(echo $SYMLINK | awk '{print $2}')
done < <(echo $SYMLINKS | sed -n '/^[^#]/p') done < <(echo $SYMLINKS | sed -n '/^[^#]/p')
} }
#####################################################################
SETUP_SYMLINK() { SETUP_SYMLINK() {
[ ! $2 ] && FAIL 1 'must provide SOURCE_CONFIG and TARGET_CONFIG' [ ! $2 ] && FAIL 1 'must provide SOURCE_CONFIG and TARGET_CONFIG'
@ -42,6 +39,3 @@ SETUP_SYMLINK() {
|| FAIL 3 "failed to create link '$TARGET_CONFIG'" \ || FAIL 3 "failed to create link '$TARGET_CONFIG'" \
; ;
} }
#####################################################################
SETUP_SYMLINKS $@

View File

@ -1,13 +1,10 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=(tic) DEPENDENCIES+=(tic)
REQUIRED_ENV+=()
use system/config use system/config
CHECK_ENVIRONMENT
##################################################################### #####################################################################
SETUP_TERMINFO() { MAIN() {
[ ! $TERMINFO_PATH ] && return 0 [ ! $TERMINFO_PATH ] && return 0
[ ! -d $TERMINFO_PATH ] && FAIL 1 "TERMINFO_PATH='$TERMINFO_PATH' does not exist" [ ! -d $TERMINFO_PATH ] && FAIL 1 "TERMINFO_PATH='$TERMINFO_PATH' does not exist"
@ -22,6 +19,3 @@ SETUP_TERMINFO() {
CHECK_ERRORS CHECK_ERRORS
} }
#####################################################################
SETUP_TERMINFO $@

View File

@ -1,13 +1,10 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/meta use scwrypts/meta
CHECK_ENVIRONMENT
##################################################################### #####################################################################
STATUS 'updating all config files and links' MAIN() {
SCWRYPTS__RUN --name system/config/symlinks --group scwrypts --type zsh || exit 1 STATUS 'updating all config files and links'
SCWRYPTS__RUN --name system/config/terminfo --group scwrypts --type zsh || exit 2 SCWRYPTS__RUN --name system/config/symlinks --group scwrypts --type zsh || exit 1
SUCCESS 'finished updating config files and links' SCWRYPTS__RUN --name system/config/terminfo --group scwrypts --type zsh || exit 2
SUCCESS 'finished updating config files and links'
}

View File

@ -1,9 +1,7 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/meta use scwrypts/meta
CHECK_ENVIRONMENT
##################################################################### #####################################################################
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --only-build $@
MAIN() {
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --only-build $@
}

View File

@ -1,9 +1,7 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/meta use scwrypts/meta
CHECK_ENVIRONMENT
##################################################################### #####################################################################
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --only-pull $@
MAIN() {
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --only-pull $@
}

View File

@ -1,13 +1,8 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use system/packages/git use system/packages/git
CHECK_ENVIRONMENT
##################################################################### #####################################################################
INSTALL() { MAIN() {
local USAGE=" local USAGE="
usage: [...options...] usage: [...options...]
@ -86,6 +81,3 @@ INSTALL() {
[[ $SKIP_BUILD -eq 1 ]] && return 0 [[ $SKIP_BUILD -eq 1 ]] && return 0
BUILD BUILD
} }
#####################################################################
INSTALL $@

View File

@ -1,9 +1,7 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use scwrypts/meta use scwrypts/meta
CHECK_ENVIRONMENT
##################################################################### #####################################################################
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --update $@
MAIN() {
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --update $@
}

View File

@ -1,9 +1,7 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use system/vim/vundle use system/vim/vundle
CHECK_ENVIRONMENT
##################################################################### #####################################################################
EDIT "$VUNDLE__BUILD_DEFINITIONS"
MAIN() {
EDIT "$VUNDLE__BUILD_DEFINITIONS"
}

View File

@ -1,13 +1,8 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use system/vim/vundle use system/vim/vundle
CHECK_ENVIRONMENT
##################################################################### #####################################################################
PLUGIN_INSTALL() { MAIN() {
[ -d "$HOME/.vim/bundle/Vundle.vim" ] || { [ -d "$HOME/.vim/bundle/Vundle.vim" ] || {
mkdir -p "$HOME/.vim/bundle/" mkdir -p "$HOME/.vim/bundle/"
git clone https://github.com/VundleVim/Vundle.vim.git "$HOME/.vim/bundle/Vundle.vim" git clone https://github.com/VundleVim/Vundle.vim.git "$HOME/.vim/bundle/Vundle.vim"
@ -16,6 +11,3 @@ PLUGIN_INSTALL() {
VUNDLE__PLUGIN_INSTALL || return 1 VUNDLE__PLUGIN_INSTALL || return 1
VUNDLE__REBUILD_PLUGINS || return 2 VUNDLE__REBUILD_PLUGINS || return 2
} }
#####################################################################
PLUGIN_INSTALL $@

View File

@ -1,9 +1,7 @@
#!/bin/zsh #!/bin/zsh
DEPENDENCIES+=()
REQUIRED_ENV+=()
use system/vim/vundle use system/vim/vundle
CHECK_ENVIRONMENT
##################################################################### #####################################################################
VUNDLE__REBUILD_PLUGINS $@
MAIN() {
VUNDLE__REBUILD_PLUGINS $@
}