updated build/setup to match scwrypts v3

This commit is contained in:
Wryn (yage) Wagner 2023-06-27 18:30:02 -06:00
parent 1a64551465
commit dff8211b9d
11 changed files with 111 additions and 81 deletions

View File

@ -20,6 +20,8 @@ RUN : \
openssh \ openssh \
pciutils \ pciutils \
postgresql \ postgresql \
py3-virtualenv \
py3-nodeenv \
redis \ redis \
ripgrep \ ripgrep \
sed \ sed \
@ -31,21 +33,26 @@ RUN : \
zsh \ zsh \
&& apk add --update --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community/ \ && apk add --update --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community/ \
helm \ helm \
&& apk add --update --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/ \
kubectl \ kubectl \
&& apk add --update --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/ \
&& mkdir -p /root/.wryn \ && mkdir -p /root/.wryn \
; ;
COPY . /root/.wryn COPY . /root/.wryn
RUN : \ RUN : \
&& echo "#!/bin/zsh" > /bin/hostnamectl && echo "echo container" > /bin/hostnamectl && chmod +x /bin/hostnamectl \
&& echo "#!/bin/zsh" > /bin/scwrypts && echo '/root/.wryn/zsh/plugins/scwrypts/scwrypts $@' >> /bin/scwrypts && chmod +x /bin/scwrypts \
&& mkdir /root/.wryn/bin/container \
&& sed -i 's|/bin/ash|/bin/zsh|g' /etc/passwd \
&& /bin/zsh -c '/root/.wryn/setup/run --no-fluff --ci --force-root' \ && /bin/zsh -c '/root/.wryn/setup/run --no-fluff --ci --force-root' \
&& echo 'hostnamectl() { echo docker; }' > $HOME/.config/wryn/env.zsh \ && echo 'source /root/.wryn/config/dotwryn.env.zsh' > /root/.config/wryn/env.zsh \
&& echo 'source /root/.wryn/config/dotwryn.env.zsh' >> $HOME/.config/wryn/env.zsh \ && echo "WELCOME() {}" >> /root/.config/wryn/env.zsh \
&& echo "WELCOME() {}" >> $HOME/.config/wryn/env.zsh \ && echo "PS1_INDICATOR_SYMBOL=''" >> /root/.config/wryn/env.zsh \
&& echo "PS1_INDICATOR_SYMBOL=''" >> $HOME/.config/wryn/env.zsh \ && echo "PS1_USER=\"root@\$(ip a | grep inet | grep -v '127\\.0\\.0\.1' | sed 's|/| |g' | awk '{print \$2;}')\"" >> /root/.config/wryn/env.zsh \
&& echo "PS1_USER='root@debugger'" >> $HOME/.config/wryn/env.zsh \ && echo "source /root/.wryn/zsh/plugins/scwrypts/scwrypts.plugin.zsh" >> /root/.config/wryn/env.zsh \
&& rm /root/dotwryn-install.log \ && rm /root/dotwryn-install.log \
&& scwrypts --name scwrypts/virtualenv/update-all --group scwrypts --type zsh \
; ;
ENTRYPOINT ["/root/.wryn/.docker/entrypoint"] ENTRYPOINT ["/root/.wryn/.docker/entrypoint"]

View File

@ -1,18 +1,13 @@
#!/bin/zsh #!/bin/zsh
##################################################################### #####################################################################
echo -e "\\033[1;31m=====================================================================\\033[0m
\\033[1;32mWelcome to Debugger!\\033[0m
You are now entering a root-privileged container with a variety of
powerful tools. Be sure to exercise appropriate caution for your
current use-case / environment!
\\033[1;32mGLHF <3\\033[0m
\\033[1;31m=====================================================================\\033[0m"
##################################################################### #####################################################################
zsh -l source /root/.wryn/.docker/session/start-background
[ -t 0 ] && tmux a -t $SESSION || echo -e "\\033[1;32m
REMINDER: connect by executing 'tmux a -t $SESSION'
\\033[0m"
until ! tmux list-sessions 2>/dev/null | awk '{print $1;}' | grep -q "${SESSION}:"; do sleep 1; done
##################################################################### #####################################################################
echo -e "\\033[1;31m=====================================================================\\033[0m echo -e "\\033[1;31m=====================================================================\\033[0m
\\033[1;32mExiting Debugger; see you next time!\\033[0m \\033[1;32mExiting Debugger; see you next time!\\033[0m

15
.docker/session/show-warning Executable file
View File

@ -0,0 +1,15 @@
#!/bin/zsh
echo -e "\\033[1;31m=====================================================================\\033[0m
\\033[1;32mWelcome to Debugger!\\033[0m
You are now entering a root-privileged container with a variety of
powerful tools. Be sure to exercise appropriate caution for your
current use-case / environment!
\\033[1;32mGLHF <3\\033[0m
\\033[1;31m=====================================================================\\033[0m"
echo 'press Enter to continue'
read

View File

@ -0,0 +1,13 @@
#!/bin/zsh
SESSION=debugger
tmux ls | grep -q "^$SESSION" && exit 0
#####################################################################
cd
tmux new -d -s $SESSION \
;
tmux new-window -t $SESSION -n \
'WARNING' /root/.wryn/.docker/session/show-warning \
;

View File

@ -1,6 +1,6 @@
# don't use escape key # don't use escape key
set -sg escape-time 0 set -sg escape-time 0
set-option -g default-shell $SHELL set-option -g default-shell /bin/zsh
# quick reload # quick reload
bind-key r source-file ~/.tmux.conf\; display "TMUX CONFIG RELOADED" bind-key r source-file ~/.tmux.conf\; display "TMUX CONFIG RELOADED"

View File

@ -1,11 +1,11 @@
__yN 'keep logfile?' || { yN 'keep logfile?' || {
rm "$LOGFILE" \ rm "$LOGFILE" \
|| __ERROR "unable to remote '$LOGFILE'" \ || ERROR "unable to remote '$LOGFILE'" \
; ;
} }
__SUCCESS SUCCESS '
__SUCCESS '.wryn setup complete; have a nice day :)' .wryn setup complete; have a nice day :)
__SUCCESS '
exit 0 exit 0

View File

@ -1,12 +1,12 @@
function SETUP__CONFIG() { function SETUP__CONFIG() {
__STATUS 'starting application configuration' STATUS 'starting application configuration'
SCWRYPTS zsh/config/update || return 1 SCWRYPTS system/config/update || return 1
CONFIG__ZSH || return 2 CONFIG__ZSH || return 2
CONFIG__VIM || return 3 CONFIG__VIM || return 3
__SUCCESS 'finished application configuration' SUCCESS 'finished application configuration'
} }
##################################################################### #####################################################################
@ -23,10 +23,10 @@ CONFIG__SET_DEFAULT_SHELL() {
[ $FORCE_ROOT ] && return 0 [ $FORCE_ROOT ] && return 0
__STATUS 'setting zsh as default shell' STATUS 'setting zsh as default shell'
sudo chsh -s $(which zsh) $(whoami) 2>&1 \ sudo chsh -s $(which zsh) $(whoami) 2>&1 \
&& __SUCCESS "set zsh as default shell for '$USER'" \ && SUCCESS "set zsh as default shell for '$USER'" \
|| __FAIL 1 'failed to set zsh as default shell' \ || FAIL 1 'failed to set zsh as default shell' \
; ;
} }
@ -38,10 +38,10 @@ CONFIG__VIM() {
[ $NO_COMPILE_VIM ] && return 0 [ $NO_COMPILE_VIM ] && return 0
__STATUS 'starting vim setup' STATUS 'starting vim setup'
"$DOTWRYN_PATH/vim/update" \ "$DOTWRYN_PATH/vim/update" \
&& __SUCCESS 'completed vim setup' \ && SUCCESS 'completed vim setup' \
|| __FAIL 1 'error detected in vim setup (see above)' \ || FAIL 1 'error detected in vim setup (see above)' \
; ;
} }
@ -52,14 +52,14 @@ CONFIG__ENV() {
local LOCAL_CONFIG="$HOME/.config/wryn/env.$1" local LOCAL_CONFIG="$HOME/.config/wryn/env.$1"
[ -f $LOCAL_CONFIG ] && { [ -f $LOCAL_CONFIG ] && {
__WARNING "local $1 configuration exists ($LOCAL_CONFIG)" WARNING "local $1 configuration exists ($LOCAL_CONFIG)"
__yN 'overwrite this configuration?' || return 0 yN 'overwrite this configuration?' || return 0
mv "$LOCAL_CONFIG" "$LOCAL_CONFIG.bak" >/dev/null 2>&1 \ mv "$LOCAL_CONFIG" "$LOCAL_CONFIG.bak" >/dev/null 2>&1 \
&& __INFO "created backup of local configuration ($LOCAL_CONFIG.bak)" && INFO "created backup of local configuration ($LOCAL_CONFIG.bak)"
} }
__STATUS "setting up $1 configuration ($LOCAL_CONFIG)" STATUS "setting up $1 configuration ($LOCAL_CONFIG)"
case $1 in case $1 in
vim ) COMMENT='"' ;; vim ) COMMENT='"' ;;
@ -71,11 +71,11 @@ CONFIG__ENV() {
echo -e "\\n$COMMENT\n$COMMENT .wryn configuration overrides\n$COMMENT\n" echo -e "\\n$COMMENT\n$COMMENT .wryn configuration overrides\n$COMMENT\n"
sed "s/^[^$COMMENT].*/$COMMENT&/" $DEFAULT_CONFIG sed "s/^[^$COMMENT].*/$COMMENT&/" $DEFAULT_CONFIG
} > $LOCAL_CONFIG \ } > $LOCAL_CONFIG \
&& __SUCCESS "created $1 configuration" \ && SUCCESS "created $1 configuration" \
|| __FAIL 1 "unable to create $1 configuration" \ || FAIL 1 "unable to create $1 configuration" \
; ;
__EDIT "$LOCAL_CONFIG" EDIT "$LOCAL_CONFIG"
} }
@ -93,8 +93,8 @@ CONFIG__RC() {
|| echo "$SOURCE_LINE" >> $RC || echo "$SOURCE_LINE" >> $RC
grep -q "^$SOURCE_LINE$" "$RC" \ grep -q "^$SOURCE_LINE$" "$RC" \
&& __SUCCESS "${TYPE}rc is configured correctly" \ && SUCCESS "${TYPE}rc is configured correctly" \
|| __FAIL 1 "failed to configure ${TYPE}rc" \ || FAIL 1 "failed to configure ${TYPE}rc" \
; ;
} }

View File

@ -1,7 +1,7 @@
##################################################################### #####################################################################
SETUP__GIT() { SETUP__GIT() {
__STATUS 'updating remotes for .wryn' STATUS 'updating remotes for .wryn'
cd $DOTWRYN_PATH cd $DOTWRYN_PATH
git remote rm origin 2>/dev/null git remote rm origin 2>/dev/null
git remote add origin git@github.com:wrynegade/dotwryn.git git remote add origin git@github.com:wrynegade/dotwryn.git
@ -12,21 +12,21 @@ SETUP__GIT() {
git branch --set-upstream-to=origin/main main >/dev/null 2>&1 git branch --set-upstream-to=origin/main main >/dev/null 2>&1
__STATUS 'updating upstream for zsh/plugins/code-activator' STATUS 'updating upstream for zsh/plugins/code-activator'
cd $DOTWRYN_PATH/zsh/plugins/code-activator cd $DOTWRYN_PATH/zsh/plugins/code-activator
git remote rm upstream 2>/dev/null git remote rm upstream 2>/dev/null
git remote add upstream git@yage.io:zsh/code-activator.git git remote add upstream git@yage.io:zsh/code-activator.git
git remote set-url --add --push upstream git@yage.io:zsh/code-activator.git git remote set-url --add --push upstream git@yage.io:zsh/code-activator.git
git remote set-url --add --push upstream git@github.com:wrynegade/code-activator-zsh.git git remote set-url --add --push upstream git@github.com:wrynegade/code-activator-zsh.git
__STATUS 'updating upstream for zsh/plugins/scwrypts' STATUS 'updating upstream for zsh/plugins/scwrypts'
cd $DOTWRYN_PATH/zsh/plugins/scwrypts cd $DOTWRYN_PATH/zsh/plugins/scwrypts
git remote rm upstream 2>/dev/null git remote rm upstream 2>/dev/null
git remote add upstream git@yage.io:zsh/code-activator git remote add upstream git@yage.io:zsh/code-activator
git remote set-url --add --push upstream git@yage.io:zsh/code-activator git remote set-url --add --push upstream git@yage.io:zsh/code-activator
git remote set-url --add --push upstream git@github.com:wrynegade/scwrypts.git git remote set-url --add --push upstream git@github.com:wrynegade/scwrypts.git
__STATUS 'updating upstream for zsh/plugins/ssh' STATUS 'updating upstream for zsh/plugins/ssh'
cd $DOTWRYN_PATH/zsh/plugins/ssh cd $DOTWRYN_PATH/zsh/plugins/ssh
git remote rm upstream git remote rm upstream
git remote add upstream git@yage.io:zsh/ssh.git git remote add upstream git@yage.io:zsh/ssh.git

View File

@ -2,11 +2,11 @@
SETUP__OS() { SETUP__OS() {
OS__MAKE_REQUIRED_RESOURCES || return 1 OS__MAKE_REQUIRED_RESOURCES || return 1
[ $CI ] && { __STATUS 'detected CI; skipping os setup'; return 0; } [ $CI ] && { STATUS 'detected CI; skipping os setup'; return 0; }
__GETSUDO GETSUDO
local OS_NAME=$(OS__GET_OS) local OS_NAME=$(OS__GET_OS)
[ ! $OS_NAME ] && __ABORT [ ! $OS_NAME ] && ABORT
OS__INSTALL_SOURCE_DEPENDENCIES || return 2 OS__INSTALL_SOURCE_DEPENDENCIES || return 2
OS__INSTALL_MANAGED_DEPENDENCIES || return 3 OS__INSTALL_MANAGED_DEPENDENCIES || return 3
@ -19,8 +19,8 @@ OS__GET_OS() {
&& OS_NAME=$(cat /etc/os-release 2>/dev/null | grep '^ID=' | sed 's/^ID=//') && OS_NAME=$(cat /etc/os-release 2>/dev/null | grep '^ID=' | sed 's/^ID=//')
[ ! $OS_NAME ] \ [ ! $OS_NAME ] \
&& __WARNING 'failed to detect operating system' \ && WARNING 'failed to detect operating system' \
&& OS_NAME=$(echo -e "arch\ndebian\nother" | __FZF 'select an operating system') \ && OS_NAME=$(echo -e "arch\ndebian\nother" | FZF 'select an operating system') \
; ;
[[ $OS_NAME =~ ^ubuntu$ ]] && OS_NAME=debian [[ $OS_NAME =~ ^ubuntu$ ]] && OS_NAME=debian
@ -33,7 +33,7 @@ OS__GET_OS() {
OS__INSTALL_SOURCE_DEPENDENCIES() { OS__INSTALL_SOURCE_DEPENDENCIES() {
case $OS_NAME in case $OS_NAME in
arch ) arch )
SCWRYPTS zsh/git/package/install \ SCWRYPTS packages/install \
'https://aur.archlinux.org/yay.git' \ 'https://aur.archlinux.org/yay.git' \
--local-name 'yay' \ --local-name 'yay' \
; ;
@ -42,7 +42,7 @@ OS__INSTALL_SOURCE_DEPENDENCIES() {
* ) ;; * ) ;;
esac esac
SCWRYPTS zsh/git/package/install \ SCWRYPTS packages/install \
'https://github.com/tiyn/dmenu' \ 'https://github.com/tiyn/dmenu' \
--local-name 'patched-dmenu' \ --local-name 'patched-dmenu' \
; ;
@ -53,15 +53,15 @@ OS__INSTALL_SOURCE_DEPENDENCIES() {
OS__INSTALL_MANAGED_DEPENDENCIES() { OS__INSTALL_MANAGED_DEPENDENCIES() {
local ERRORS=0 local ERRORS=0
__STATUS 'checking os dependencies' STATUS 'checking os dependencies'
case $OS_NAME in case $OS_NAME in
arch ) arch )
__REMINDER "package 'base-devel' is required" REMINDER "package 'base-devel' is required"
;; ;;
debian ) ;; debian ) ;;
* ) * )
OS_NAME='generic' OS_NAME='generic'
__WARNING "no automated installer available for '$OS_NAME'" WARNING "no automated installer available for '$OS_NAME'"
;; ;;
esac esac
@ -71,42 +71,42 @@ OS__INSTALL_MANAGED_DEPENDENCIES() {
done done
[[ $ERRORS -ne 0 ]] && { [[ $ERRORS -ne 0 ]] && {
__WARNING "detected $ERRORS errors; double check warnings before proceeding!" WARNING "detected $ERRORS errors; double check warnings before proceeding!"
__yN 'continue with install?' && return 0 || __ABORT yN 'continue with install?' && return 0 || ABORT
} }
__SUCCESS 'all dependencies satisfied' SUCCESS 'all dependencies satisfied'
return 0 return 0
} }
INSTALL_MANAGED__arch() { INSTALL_MANAGED__arch() {
local TARGET="$1" local TARGET="$1"
__STATUS "checking for $TARGET" STATUS "checking for $TARGET"
pacman -Qq | grep -q "^$TARGET$\|^$TARGET-git$" && { pacman -Qq | grep -q "^$TARGET$\|^$TARGET-git$" && {
__SUCCESS "found installation of '$TARGET'" SUCCESS "found installation of '$TARGET'"
} || { } || {
__WARNING "'$TARGET' not found" WARNING "'$TARGET' not found"
__STATUS "installing '$TARGET'" STATUS "installing '$TARGET'"
sudo pacman -Syu --noconfirm $TARGET \ sudo pacman -Syu --noconfirm $TARGET \
&& __SUCCESS "successfully installed '$TARGET'" \ && SUCCESS "successfully installed '$TARGET'" \
|| __ERROR "failed to install '$TARGET'" || ERROR "failed to install '$TARGET'"
} }
} }
INSTALL_MANAGED__debian() { INSTALL_MANAGED__debian() {
__STATUS "checking / installing '$1'" STATUS "checking / installing '$1'"
sudo apt-get install --yes $1 \ sudo apt-get install --yes $1 \
&& __SUCCESS "'$1' installed" \ && SUCCESS "'$1' installed" \
|| __ERROR "failed to install $TARGET" \ || ERROR "failed to install $TARGET" \
; ;
} }
INSTALL_MANAGED__generic() { INSTALL_MANAGED__generic() {
command -v $1 >/dev/null 2>&1 \ command -v $1 >/dev/null 2>&1 \
|| __ERROR "could not find '$1'; it's up to you to install this one!" || ERROR "could not find '$1'; it's up to you to install this one!"
} }
##################################################################### #####################################################################
@ -125,20 +125,20 @@ OS__MAKE_REQUIRED_RESOURCES() {
"$HOME/.zshrc" "$HOME/.zshrc"
) )
__STATUS 'making required system resources' STATUS 'making required system resources'
for D in $DIRECTORIES for D in $DIRECTORIES
do do
[ ! -d $D ] && { mkdir -p $D || __ERROR "failed to create directory '$D'"; } [ ! -d $D ] && { mkdir -p $D || ERROR "failed to create directory '$D'"; }
done done
for F in $FILES for F in $FILES
do do
[ ! -f $F ] && { touch $F || __ERROR "failed to create file '$F'"; } [ ! -f $F ] && { touch $F || ERROR "failed to create file '$F'"; }
done done
[[ $ERRORS -eq 0 ]] \ [[ $ERRORS -eq 0 ]] \
&& __SUCCESS 'finished creating system resources' \ && SUCCESS 'finished creating system resources' \
|| __ERROR 'failed to create system resources' \ || ERROR 'failed to create system resources' \
; ;
return $ERRORS return $ERRORS

View File

@ -19,7 +19,7 @@ git submodule update --init --remote --recursive >/dev/null 2>&1 || {
_DEPENDENCIES+=(zsh fzf) _DEPENDENCIES+=(zsh fzf)
_REQUIRED_ENV+=() _REQUIRED_ENV+=()
source "$DOTWRYN_PATH/zsh/plugins/scwrypts/zsh/utils/utils.module.zsh" || exit 3 source "$DOTWRYN_PATH/zsh/plugins/scwrypts/zsh/lib/utils/utils.module.zsh" || exit 3
SCWRYPTS() { SCWRYPTS() {
CI=1 \ CI=1 \
@ -38,4 +38,4 @@ source "$DOTWRYN_PATH/setup/config.zsh"
clear clear
# shhh don't worry about it # shhh don't worry about it
C=$((){B(){base64 -d};A="$(cat "$2")";for _ in {1..$1};do A=$(echo $A|B);done;echo $A} 7 "$DOTWRYN_PATH/setup/welcome");for ((i=0;i<${#C};i++));do [[ ${C:$i:1} =~ z ]] && M=$(__GET_RANDOM_COLOR) && continue;__PRINT $M "${C:$i:1}" none;sleep 0.01;done;echo;unset C M [[ $CI -ne 0 ]] || {C=$((){B(){base64 -d};A="$(cat "$2")";for _ in {1..$1};do A=$(echo $A|B);done;echo $A} 7 "$DOTWRYN_PATH/setup/welcome");for ((i=0;i<${#C};i++));do [[ ${C:$i:1} =~ z ]] && M=$(__GET_RANDOM_COLOR) && continue;PRINT $M "${C:$i:1}" none;sleep 0.01;done;echo;unset C M;}

View File

@ -17,14 +17,14 @@ source ./requirements.zsh || exit 1
LOGFILE="$HOME/dotwryn-install.log" LOGFILE="$HOME/dotwryn-install.log"
__INFO "installation start : $(date)" 2>> "$LOGFILE" INFO "installation start : $(date)" 2>> "$LOGFILE"
{ {
SETUP__OS || __FAIL 1 'failed to set up os-dependencies (see above)' SETUP__OS || FAIL 1 'failed to set up os-dependencies (see above)'
SETUP__GIT || __FAIL 2 'failed to set up git (see above)' SETUP__GIT || FAIL 2 'failed to set up git (see above)'
SETUP__CONFIG || __FAIL 3 'failed to set up program configuration (see above)' SETUP__CONFIG || FAIL 3 'failed to set up program configuration (see above)'
} 2>&1 | tee --append "$LOGFILE" } 2>&1 | tee --append "$LOGFILE"
__INFO "installation complete: $(date)" 2>> "$LOGFILE" INFO "installation complete: $(date)" 2>> "$LOGFILE"
################################################################################ ################################################################################
source "$DOTWRYN_PATH/setup/cleanup.zsh" source "$DOTWRYN_PATH/setup/cleanup.zsh"