working through some setup fixes -> good checkpoint

This commit is contained in:
2026-09-19 23:27:44 -06:00
parent c023ffc6b9
commit b67a76d0da
18 changed files with 410 additions and 246 deletions
+13 -11
View File
@@ -9,17 +9,19 @@ This serves as CI/CD for the ZSH library and a convenient, root-privileged conta
## Setup / Configuration ## Setup / Configuration
The setup script is the pride and joy of this project. The setup script is the pride and joy of this project.
Running an [interactive installer](./setup/linux) removes the hassle of setting up a new computer by configuring symlinks, installing applications, and synchronizing media with the cloud. Running the [interactive installer](./setup/run) removes the hassle of setting up a new computer by configuring symlinks, installing applications, and synchronizing media with the cloud.
After running the setup, [default configurations](./env) can be overridden by editing the appropriate local configuration (`~/.config/wryn/env`). After running the setup, default configurations can be overridden by editing the appropriate local configuration (`~/.config/wryn/env.*`).
## System Breakdown ## System Breakdown
`.wryn/MODULE` | Description
------------------------------- | -------------------------------------- <!---------------------------------------------------------------------------------------------------------------------------------------------------------------->
[setup/](./setup) | os-specific setup / update utilities | `.wryn/MODULE` | Description |
[colorschemes/](./colorschemes) | 16-color terminal colorschemes; see [colors](./zsh/colors) to see how these are loaded | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
[config/](./config) | general configuration; appropriate `~/.config` files are symlinked on setup | [setup/](./setup) | os-specific setup / update utilities |
[resume/](./resume) | my working resume in `.tex` format | [config/](./config) | general configuration (including [colorschemes](./config/colorschemes)); appropriate `~/.config` files are symlinked on setup |
[vim/](./vim) | `vim` keybindings, plugins, and dictionary binary; activated by an [entry rc](./vim/rc.vim) | [resume/](./resume) | my working resume in `.tex` format |
[zsh/](./zsh) | `zsh` aliases, functions, and plugins; activated by an [entry rc](./zsh/rc) | [vim/](./vim) | `vim` keybindings, plugins, and dictionary binary; activated by an [entry rc](./vim/rc.vim) |
[zsh/plugins](./zsh/plugins) | external `zsh` plugins | [zsh/](./zsh) | `zsh` aliases, functions, and plugins; activated by an [entry rc](./zsh/rc) |
| [zsh/plugins](./zsh/plugins) | external `zsh` plugins |
<!---------------------------------------------------------------------------------------------------------------------------------------------------------------->
+1 -1
View File
@@ -6,7 +6,7 @@ readonly ${scwryptsgroup}__color=$(utils.colors.red)
[ "${DOTWRYN}" ] \ [ "${DOTWRYN}" ] \
|| export DOTWRYN=$(git -C "${0:a:h}" rev-parse --show-toplevel 2>/dev/null) || export DOTWRYN=$(git -C "${0:a:h}" rev-parse --show-toplevel 2>/dev/null)
export DOTWRYN_HOSTNAME=$(hostnamectl --static) export DOTWRYN_HOSTNAME=$(hostnamectl --static 2>/dev/null || hostname 2>/dev/null | sed 's/\.local$//')
[ "${XDG_CONFIG_HOME}" ] \ [ "${XDG_CONFIG_HOME}" ] \
|| export XDG_CONFIG_HOME="${HOME}/.config" || export XDG_CONFIG_HOME="${HOME}/.config"
+1 -1
View File
@@ -2,6 +2,6 @@
use office/vim/vundle --group dotwryn use office/vim/vundle --group dotwryn
##################################################################### #####################################################################
dotwryn.office.vim.vundle.parse.usage dotwryn.office.vim.vundle.update.parse.usage
MAIN() { dotwryn.office.vim.vundle.update $@; } MAIN() { dotwryn.office.vim.vundle.update $@; }
+1 -1
View File
@@ -3,7 +3,7 @@
# must work as a standalone zsh script # must work as a standalone zsh script
# #
eval "$(scwrypts --config)" \ eval "$(scwrypts --config)" \
&& use --group omni \ && use --group remote omni \
&& utils.check-environment \ && utils.check-environment \
|| { echo 'scwrypts config error; aborting' >&2; sleep 5; return 1; } || { echo 'scwrypts config error; aborting' >&2; sleep 5; return 1; }
+90 -81
View File
@@ -1,161 +1,170 @@
function SETUP__CONFIG() { setup.config() {
STATUS 'starting application configuration' echo.status 'starting application configuration'
GENERATE_INITIAL_LOCAL_CONFIG setup.config._.generate-initial-local-config
CONFIG__ZSH || return 2 setup.config._.zsh || return 2
CONFIG__VIM || return 3 setup.config._.vim || return 3
CONFIG__SYSTEM || return 4 setup.config._.system || return 4
SCWRYPTS generate i3 config || return 5 SCWRYPTS generate i3 config || return 5
SUCCESS 'finished application configuration' echo.success 'finished application configuration'
} }
##################################################################### #####################################################################
GENERATE_INITIAL_LOCAL_CONFIG() { setup.config._.generate-initial-local-config() {
local HOSTNAME="$(hostnamectl --static 2>/dev/null || hostname | sed 's/\.local$//' 2>/dev/null)" local local_hostname="$(hostnamectl --static 2>/dev/null || hostname 2>/dev/null | sed 's/\.local$//')"
[ ${HOSTNAME} ] || return 0 [ "${local_hostname}" ] || return 0
mkdir -p "${DOTWRYN_PATH}/bin/${HOSTNAME}" mkdir -p "${DOTWRYN_PATH}/bin/${local_hostname}"
local ENV_DIR="${DOTWRYN_PATH}/config/scwrypts/environments" local env_dir="${DOTWRYN_PATH}/config/scwrypts/environments"
local GROUP local group
for GROUP in $(find "${ENV_DIR}" -type f -name \*env.yaml | sed -n 's|.*/local\.\([^.]*\)\.env\.yaml|\1|p') for group in $(find "${env_dir}" -type f -name \*env.yaml | sed -n 's|.*/local\.\([^.]*\)\.env\.yaml|\1|p')
do do
[ -f "${ENV_DIR}/local.${HOSTNAME}.${GROUP}.env.yaml" ] \ [ -f "${env_dir}/local.${local_hostname}.${group}.env.yaml" ] && continue
|| cp "${ENV_DIR}/local.altaria.${GROUP}.env.yaml" "${ENV_DIR}/local.${HOSTNAME}.${GROUP}.env.yaml"
done
local LOCAL_OVERRIDE if [ -f "${env_dir}/local.altaria.${group}.env.yaml" ]
for LOCAL_OVERRIDE in \ then
cp "${env_dir}/local.altaria.${group}.env.yaml" "${env_dir}/local.${local_hostname}.${group}.env.yaml"
else
cp "${env_dir}/local.${group}.env.yaml" "${env_dir}/local.${local_hostname}.${group}.env.yaml"
fi
done
unset group
local local_override
for local_override in \
i3/local.yaml \ i3/local.yaml \
polybar/local.ini \ polybar/local.ini \
alacritty/local.toml \ alacritty/local.toml \
; ;
do do
mkdir -p -- "${DOTWRYN_PATH}/config/${HOSTNAME}/user/$(dirname -- "${LOCAL_OVERRIDE}")" mkdir -p -- "${DOTWRYN_PATH}/config/${local_hostname}/user/$(dirname -- "${local_override}")"
touch -- "${DOTWRYN_PATH}/config/${HOSTNAME}/user/${LOCAL_OVERRIDE}" touch -- "${DOTWRYN_PATH}/config/${local_hostname}/user/${local_override}"
done done
unset local_override
} }
##################################################################### #####################################################################
CONFIG__ZSH() { setup.config._.zsh() {
CONFIG__ENV zsh || return 1 setup.config._.env zsh || return 1
CONFIG__RC zsh || return 2 setup.config._.rc zsh || return 2
CONFIG__SET_DEFAULT_SHELL || return 3 setup.config._.set-default-shell || return 3
} }
CONFIG__SET_DEFAULT_SHELL() { setup.config._.set-default-shell() {
local DEFAULT_SHELL=$(awk -F: -v user="${USER}" '$1 == user {print $NF}' /etc/passwd) local default_shell="$(awk -F: -v user="${USER}" '$1 == user {print $NF}' /etc/passwd)"
[[ ${DEFAULT_SHELL} =~ zsh ]] && return 0 [[ "${default_shell}" =~ zsh ]] && return 0
[ ${FORCE_ROOT} ] && return 0 [[ "${FORCE_ROOT}" == true ]] && return 0
STATUS 'setting zsh as default shell' echo.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}'" \ && echo.success "set zsh as default shell for '${USER}'" \
|| FAIL 1 'failed to set zsh as default shell' \ || utils.fail 1 'failed to set zsh as default shell' \
; ;
} }
##################################################################### #####################################################################
CONFIG__VIM() { setup.config._.vim() {
CONFIG__RC vim || return 1 setup.config._.rc vim || return 1
STATUS 'starting vim setup' echo.status 'starting vim setup'
SCWRYPTS dotwryn vundle update || return 2 SCWRYPTS dotwryn vundle update || return 2
CONFIG__VIM__LINK_SUPERUSER_RC setup.config._.vim.link-superuser-rc
return 0 return 0
} }
CONFIG__VIM__LINK_SUPERUSER_RC() { setup.config._.vim.link-superuser-rc() {
sudo [ /root/.vimrc ] && return 0 sudo [ -f /root/.vimrc ] && return 0
echo "let \$DOTWRYN=\"${DOTWRYN_PATH}\"\nsource \"${DOTWRYN_PATH}/vim/rc.vim\"" \ echo "let \$DOTWRYN=\"${DOTWRYN_PATH}\"\nsource \"${DOTWRYN_PATH}/vim/rc.vim\"" \
| sudo tee /root/.vimrc >/dev/null | sudo tee /root/.vimrc >/dev/null
sudo mkdir -p /root/.vim sudo mkdir -p /root/.vim
sudo ln -s /home/w0ryn/.vim/bundle /root/.vim/bundle sudo ln -s "${HOME}/.vim/bundle" /root/.vim/bundle
} }
##################################################################### #####################################################################
CONFIG__SYSTEM() { setup.config._.system() {
SCWRYPTS dotwryn system setup SCWRYPTS dotwryn system setup
} }
##################################################################### #####################################################################
CONFIG__ENV() { setup.config._.env() {
local DEFAULT_CONFIG="${DOTWRYN_PATH}/$1/env.$1" local config_type="${1}"
local LOCAL_CONFIG="${HOME}/.config/wryn/env.$1" local default_config="${DOTWRYN_PATH}/${config_type}/env.${config_type}"
local local_config="${HOME}/.config/wryn/env.${config_type}"
[ -f ${LOCAL_CONFIG} ] && { [ -f "${local_config}" ] && {
case ${OVERWRITE_EXISTING} in case "${OVERWRITE_EXISTING}" in
0 ) return 0 ;; ( false ) return 0 ;;
1 ) ( true )
WARNING "local $1 configuration exists (${LOCAL_CONFIG})" echo.warning "local ${config_type} configuration exists (${local_config})"
yN 'overwrite this configuration?' || return 0 utils.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)" && echo.status "created backup of local configuration (${local_config}.bak)"
;;
esac esac
} }
STATUS "setting up $1 configuration (${LOCAL_CONFIG})" echo.status "setting up ${config_type} configuration (${local_config})"
case $1 in local comment
zsh ) COMMENT='#' ;; case "${config_type}" in
( zsh ) comment='#' ;;
esac esac
{ {
echo "source ${DEFAULT_CONFIG}" echo "source ${default_config}"
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" \ && echo.success "created ${config_type} configuration" \
|| FAIL 1 "unable to create $1 configuration" \ || utils.fail 1 "unable to create ${config_type} configuration" \
; ;
EDITOR=vim VISUAL=vim EDIT "${LOCAL_CONFIG}" EDITOR=vim VISUAL=vim utils.io.edit "${local_config}"
} }
CONFIG__RC() { setup.config._.rc() {
local TYPE="$1" local config_type="${1}"
local RC local rc
case ${TYPE} in case "${config_type}" in
vim ) ( vim )
RC="${XDG_CONFIG_HOME:-${HOME}/.config}/vim/vimrc" rc="${XDG_CONFIG_HOME:-${HOME}/.config}/vim/vimrc"
mkdir -p -- "$(dirname -- "${RC}")" mkdir -p -- "$(dirname -- "${rc}")"
[ -f "${HOME}/.vimrc" ] \ [ -f "${HOME}/.vimrc" ] \
&& cat "${HOME}/.vimrc" >> "${XDG_CONFIG_HOME:-${HOME}/.config}/vim/vimrc" \ && cat "${HOME}/.vimrc" >> "${XDG_CONFIG_HOME:-${HOME}/.config}/vim/vimrc" \
&& rm "${HOME}/.vimrc" \ && rm "${HOME}/.vimrc" \
; ;
;; ;;
* ) RC="${HOME}/.${TYPE}rc"; ( * ) rc="${HOME}/.${config_type}rc" ;;
;;
esac esac
local SOURCE_LINE local source_line
case ${TYPE} in case "${config_type}" in
zsh ) SOURCE_LINE="source ${DOTWRYN_PATH}/zsh/rc" ;; ( zsh ) source_line="source ${DOTWRYN_PATH}/zsh/rc" ;;
vim ) SOURCE_LINE="source ${DOTWRYN_PATH}/vim/rc.vim" ;; ( vim ) source_line="source ${DOTWRYN_PATH}/vim/rc.vim" ;;
esac esac
grep -q "^${source_line}$" "${rc}" \
|| echo "${source_line}" >> "${rc}"
grep -q "^${SOURCE_LINE}$" "${RC}" \ grep -q "^${source_line}$" "${rc}" \
|| echo "${SOURCE_LINE}" >> ${RC} && echo.success "${config_type}rc is configured correctly" \
|| utils.fail 1 "failed to configure ${config_type}rc" \
grep -q "^${SOURCE_LINE}$" "${RC}" \
&& SUCCESS "${TYPE}rc is configured correctly" \
|| FAIL 1 "failed to configure ${TYPE}rc" \
; ;
} }
+25 -25
View File
@@ -1,74 +1,74 @@
##################################################################### #####################################################################
SETUP__GIT() { setup.git() {
local SOURCES_DIR="${XDG_DATA_HOME:-${HOME}/.local/share}/project-source-code" local sources_dir="${XDG_DATA_HOME:-${HOME}/.local/share}/project-source-code"
SOURCE_DIR="${DOTWRYN_PATH}" \ SOURCE_DIR="${DOTWRYN_PATH}" \
TARGET_DIR="${SOURCES_DIR}/yage/dotwryn" \ TARGET_DIR="${sources_dir}/yage/dotwryn" \
REMOTE_UPSTREAMS=( REMOTE_UPSTREAMS=(
'git@github.com:wrynegade/dotwryn.git' 'git@github.com:wrynegade/dotwryn.git'
'git@yage.io:wrynegade/dotwryn.git' 'git@yage.io:wrynegade/dotwryn.git'
'git@bitbucket.org:wrynegade/dotwryn.git' 'git@bitbucket.org:wrynegade/dotwryn.git'
) SETUP__GIT__REMOTES '.wryn' ) setup.git._.remotes '.wryn'
SOURCE_DIR="${DOTWRYN_PATH}/zsh/plugins/code-activator" \ SOURCE_DIR="${DOTWRYN_PATH}/zsh/plugins/code-activator" \
TARGET_DIR="${SOURCES_DIR}/zsh/code-activator" \ TARGET_DIR="${sources_dir}/zsh/code-activator" \
REMOTE_UPSTREAMS=( REMOTE_UPSTREAMS=(
'git@yage.io:zsh/code-activator.git' 'git@yage.io:zsh/code-activator.git'
'git@github.com:wrynegade/code-activator.git' 'git@github.com:wrynegade/code-activator.git'
) SETUP__GIT__REMOTES 'zsh-plugins/code-activator' ) setup.git._.remotes 'zsh-plugins/code-activator'
SOURCE_DIR="${DOTWRYN_PATH}/zsh/plugins/scwrypts" \ SOURCE_DIR="${DOTWRYN_PATH}/zsh/plugins/scwrypts" \
TARGET_DIR="${SOURCES_DIR}/zsh/scwrypts" \ TARGET_DIR="${sources_dir}/zsh/scwrypts" \
REMOTE_UPSTREAMS=( REMOTE_UPSTREAMS=(
'git@yage.io:zsh/scwrypts' 'git@yage.io:zsh/scwrypts'
'git@github.com:wrynegade/scwrypts' 'git@github.com:wrynegade/scwrypts'
) SETUP__GIT__REMOTES 'zsh-plugins/scwrypts' ) setup.git._.remotes 'zsh-plugins/scwrypts'
return 0 return 0
} }
SETUP__GIT__REMOTES() { setup.git._.remotes() {
: \ : \
&& [ "${SOURCE_DIR}" ] \ && [ "${SOURCE_DIR}" ] \
&& [ "${TARGET_DIR}" ] \ && [ "${TARGET_DIR}" ] \
&& [[ ${#REMOTE_UPSTREAMS[@]} -gt 0 ]] \ && [[ ${#REMOTE_UPSTREAMS[@]} -gt 0 ]] \
|| return 1 || return 1
[ "$1" ] && STATUS "updating remotes for '$1'" [ "$1" ] && echo.status "updating remotes for '$1'"
git -C "${SOURCE_DIR}" remote rm upstream 2>/dev/null git -C "${SOURCE_DIR}" remote rm upstream 2>/dev/null
git -C "${SOURCE_DIR}" remote add upstream ${REMOTE_UPSTREAMS[1]} git -C "${SOURCE_DIR}" remote add upstream "${REMOTE_UPSTREAMS[1]}"
local REMOTE_UPSTREAM local remote_upstream
for REMOTE_UPSTREAM in ${REMOTE_UPSTREAMS[@]} for remote_upstream in "${REMOTE_UPSTREAMS[@]}"
do do
git -C "${SOURCE_DIR}" remote set-url --add --push upstream "${REMOTE_UPSTREAM}" git -C "${SOURCE_DIR}" remote set-url --add --push upstream "${remote_upstream}"
case ${REMOTE_UPSTREAM} in case "${remote_upstream}" in
git@github.com:* ) ( git@github.com:* )
git -C "${SOURCE_DIR}" remote rm github 2>/dev/null git -C "${SOURCE_DIR}" remote rm github 2>/dev/null
git -C "${SOURCE_DIR}" remote add github "${REMOTE_UPSTREAM}" git -C "${SOURCE_DIR}" remote add github "${remote_upstream}"
;; ;;
git@yage.io:* ) ( git@yage.io:* )
git -C "${SOURCE_DIR}" remote rm yage 2>/dev/null git -C "${SOURCE_DIR}" remote rm yage 2>/dev/null
git -C "${SOURCE_DIR}" remote add yage "${REMOTE_UPSTREAM}" git -C "${SOURCE_DIR}" remote add yage "${remote_upstream}"
;; ;;
git@bitbucket.org:* ) ( git@bitbucket.org:* )
git -C "${SOURCE_DIR}" remote rm bitbucket 2>/dev/null git -C "${SOURCE_DIR}" remote rm bitbucket 2>/dev/null
git -C "${SOURCE_DIR}" remote add bitbucket "${REMOTE_UPSTREAM}" git -C "${SOURCE_DIR}" remote add bitbucket "${remote_upstream}"
;; ;;
esac esac
done done
unset remote_upstream
SOURCE_DIR="${SOURCE_DIR}" TARGET_DIR="${TARGET_DIR}" SETUP__GIT__LINK_TO_PROJECTS || { SOURCE_DIR="${SOURCE_DIR}" TARGET_DIR="${TARGET_DIR}" setup.git._.link-to-projects \
WARNING "failed to link '${TARGET_DIR}'" || echo.warning "failed to link '${TARGET_DIR}'"
}
return 0 return 0
} }
SETUP__GIT__LINK_TO_PROJECTS() { setup.git._.link-to-projects() {
[ "${TARGET_DIR}" ] && [ "${SOURCE_DIR}" ] \ [ "${TARGET_DIR}" ] && [ "${SOURCE_DIR}" ] \
|| return 1 || return 1
+1
View File
@@ -6,6 +6,7 @@ figlet
fzf fzf
go-yq go-yq
htop htop
jo
jq jq
lolcat lolcat
ncurses ncurses
+2 -1
View File
@@ -18,12 +18,13 @@ google-chrome
htop htop
i3-wm i3-wm
jdk-openjdk jdk-openjdk
jo
jq jq
lolcat lolcat
lxappearance lxappearance
mono mono
ncurses ncurses
neofetch fastfetch
nodejs nodejs
noto-fonts-emoji noto-fonts-emoji
npm npm
+12
View File
@@ -0,0 +1,12 @@
bsdextrautils
build-essential
cmake
cowsay
figlet
fzf
jo
jq
ncurses-dev
ripgrep
tmux
uuid-runtime
+4
View File
@@ -1,4 +1,5 @@
awscli awscli
bsdextrautils
build-essential build-essential
cmake cmake
cowsay cowsay
@@ -6,6 +7,8 @@ default-jdk
figlet figlet
fzf fzf
golang golang
jo
jq
lolcat lolcat
mono-devel mono-devel
ncurses-dev ncurses-dev
@@ -14,3 +17,4 @@ npm
python3-dev python3-dev
ripgrep ripgrep
tmux tmux
uuid-runtime
+15
View File
@@ -0,0 +1,15 @@
bat
cmake
cowsay
figlet
fzf
htop
jo
jq
lolcat
ncurses
python3-devel
ripgrep
tmux
vim-enhanced
yq
+2 -1
View File
@@ -21,12 +21,13 @@ gnupg2
go go
htop htop
java-latest-openjdk java-latest-openjdk
jo
jq jq
libtool libtool
lolcat lolcat
mono-complete mono-complete
ncurses ncurses
neofetch fastfetch
nodejs nodejs
npm npm
openssh openssh
+1
View File
@@ -5,6 +5,7 @@ figlet
fzf fzf
go go
java java
jo
jq jq
lolcat lolcat
ncurses ncurses
+14
View File
@@ -0,0 +1,14 @@
bat
cmake
cowsay
figlet
fzf
htop
jo
jq
lolcat
ncurses
python
ripgrep
tmux
vim
+3
View File
@@ -6,6 +6,7 @@ bison
cmake cmake
coreutils coreutils
cowsay cowsay
fastfetch
feh feh
figlet figlet
findutils findutils
@@ -21,6 +22,7 @@ grep
gsed gsed
htop htop
iproute2mac iproute2mac
jo
jq jq
libtool libtool
lolcat lolcat
@@ -34,6 +36,7 @@ pkg-config
pylint pylint
python python
python-setuptools python-setuptools
redis
ripgrep ripgrep
rust rust
tmux tmux
+168 -90
View File
@@ -1,45 +1,90 @@
##################################################################### #####################################################################
SETUP__OS() { setup.os() {
OS__MAKE_REQUIRED_RESOURCES || return 1 setup.os._.make-required-resources || return 1
[ ${CI} ] && { STATUS 'detected CI; skipping os setup'; return 0; } [[ "${CI}" == true ]] && { echo.status 'detected CI; skipping os setup'; return 0; }
GETSUDO utils.io.getsudo
local OS_NAME=$(OS__GET_OS) local OS_NAME="$(setup.os._.get-os)"
[ ! ${OS_NAME} ] && ABORT [ ! "${OS_NAME}" ] && utils.abort
OS__INSTALL_SOURCE_DEPENDENCIES || return 2 setup.os._.install-source-dependencies || return 2
OS__INSTALL_MANAGED_DEPENDENCIES || return 3 setup.os._.install-managed-dependencies || return 3
} }
OS__GET_OS() { setup.os._.get-os() {
local OS_NAME=$(lsb_release -is 2>/dev/null | tr '[:upper:]' '[:lower:]') local OS_NAME="$(lsb_release -is 2>/dev/null | tr '[:upper:]' '[:lower:]')"
[ ! ${OS_NAME} ] \ [ ! "${OS_NAME}" ] \
&& OS_NAME=$(cat /etc/os-release 2>/dev/null | sed -n 's/^ID=//p') && OS_NAME="$(sed -n 's/^ID=//p' /etc/os-release 2>/dev/null)"
uname -s | grep -q Darwin \ uname -s | grep -q Darwin \
&& OS_NAME=macos && OS_NAME=macos
[ ! ${OS_NAME} ] \ [ ! "${OS_NAME}" ] \
&& WARNING 'failed to detect operating system' \ && echo.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" | utils.fzf 'select an operating system')" \
; ;
[[ ${OS_NAME} =~ ^ubuntu$ ]] && OS_NAME=debian [[ "${OS_NAME}" =~ ^ubuntu$ ]] && OS_NAME=debian
[[ ${OS_NAME} =~ ^[Ee]ndeavour[Oo][Ss]$ ]] && OS_NAME=arch [[ "${OS_NAME}" =~ ^[Ee]ndeavour[Oo][Ss]$ ]] && OS_NAME=arch
echo ${OS_NAME} echo "${OS_NAME}"
} }
##################################################################### #####################################################################
OS__INSTALL_SOURCE_DEPENDENCIES() { setup.os._.install-from-source() { # clone + build/install a git-hosted package (AUR PKGBUILD or Makefile)
case ${OS_NAME} in local target_url="${1}"
local name="${2:-$(echo "${target_url}" | sed 's/.*\///; s/\.git$//')}"
local install_dir="${HOME}/.local/share/source-packages"
mkdir -p "${install_dir}"
if [ -d "${install_dir}/${name}" ]
then
echo.status "updating '${name}'"
( cd "${install_dir}/${name}" && git pull origin "$(git rev-parse --abbrev-ref HEAD)" ) \
&& echo.success "successfully updated '${name}'" \
|| { echo.error "failed to update '${name}'"; return 1; }
else
echo.status "downloading '${name}'"
git clone "${target_url}" "${install_dir}/${name}" \
&& echo.success "successfully downloaded '${name}'" \
|| { echo.error "failed to download '${name}'"; return 2; }
fi
cd "${install_dir}/${name}"
if [ -f ./PKGBUILD ]
then
echo.status "installing '${name}'"
yes | makepkg -si \
&& echo.success "successfully installed '${name}'" \
|| { echo.error "failed to install '${name}'"; return 3; }
elif [ -f ./Makefile ]
then
echo.status "building '${name}'"
make \
&& echo.success "finished building '${name}'" \
|| { echo.error "build failed for '${name}'"; return 4; }
echo.status "installing '${name}'"
utils.io.getsudo
sudo make install \
&& echo.success "successfully installed '${name}'" \
|| { echo.error "failed to install '${name}'"; return 5; }
else
echo.warning 'could not detect supported installation method'
echo.reminder "complete manual installation in the directory below:"
echo.reminder "${install_dir}/${name}"
fi
}
setup.os._.install-source-dependencies() {
case "${OS_NAME}" in
( arch ) ( arch )
command -v yay >/dev/null 2>&1 \ command -v yay >/dev/null 2>&1 \
|| SCWRYPTS packages/install -- 'https://aur.archlinux.org/yay.git' --local-name 'yay' \ || setup.os._.install-from-source 'https://aur.archlinux.org/yay.git' 'yay' \
; ;
;; ;;
@@ -48,59 +93,80 @@ OS__INSTALL_SOURCE_DEPENDENCIES() {
( debian ) ;; ( debian ) ;;
( macos ) ( macos )
command -v brew &>/dev/null \ xcode-select -p &>/dev/null || { # brew requires the xcode command line tools
|| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" echo.status 'installing xcode command line tools'
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
local clt_package="$(softwareupdate -l | grep '\*.*Command Line' | tail -n1 | sed 's/^[^C]*\(C.*\)/\1/')"
sudo softwareupdate -i "${clt_package}" --verbose \
&& echo.success 'successfully installed xcode command line tools' \
|| echo.error 'failed to install xcode command line tools' \
;
rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
}
command -v brew &>/dev/null || {
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv 2>/dev/null || /usr/local/bin/brew shellenv 2>/dev/null)"
}
;; ;;
( * ) ;; ( * ) ;;
esac esac
[ ${COMPILE_DMENU} ] && [[ ${COMPILE_DMENU} -eq 1 ]] \ [[ "${OS_NAME}" != macos ]] && [[ "${COMPILE_DMENU}" == true ]] \
&& SCWRYPTS packages/install -- 'https://github.com/tiyn/dmenu' --local-name 'patched-dmenu' && setup.os._.install-from-source 'https://github.com/tiyn/dmenu' 'patched-dmenu'
return 0 return 0
} }
##################################################################### #####################################################################
OS__INSTALL_MANAGED_DEPENDENCIES() { setup.os._.install-managed-dependencies() {
local ERRORS=0 local ERRORS=0
STATUS 'checking os dependencies' echo.status 'checking os dependencies'
case ${OS_NAME} in case "${OS_NAME}" in
( arch | fedora | debian | macos ) ( arch | fedora | debian | macos )
;; ;;
( * ) ( * )
OS_NAME='generic' OS_NAME='generic'
WARNING "no automated installer available for '${OS_NAME}'" echo.warning "no automated installer available for '${OS_NAME}'"
;; ;;
esac esac
[ ${MIN} ] && [[ ${MIN} -eq 1 ]] && [ -f "${DOTWRYN_PATH}/setup/os-dependencies/${OS_NAME}.min.txt" ] \ local dependencies_file
&& DEPENDENCIES="${DOTWRYN_PATH}/setup/os-dependencies/${OS_NAME}.min.txt" \ [[ "${MIN}" == true ]] && [ -f "${DOTWRYN_PATH}/setup/os-dependencies/${OS_NAME}.min.txt" ] \
|| DEPENDENCIES="${DOTWRYN_PATH}/setup/os-dependencies/${OS_NAME}.txt" \ && dependencies_file="${DOTWRYN_PATH}/setup/os-dependencies/${OS_NAME}.min.txt" \
|| dependencies_file="${DOTWRYN_PATH}/setup/os-dependencies/${OS_NAME}.txt" \
; ;
[ ! ${CI} ] && { [[ "${CI}" != true ]] && {
STATUS 'updating system, repositories, and mirrors' echo.status 'updating system, repositories, and mirrors'
UPDATE_REPOSITORIES__${OS_NAME} "setup.os._.update-repositories.${OS_NAME}"
} }
for DEPENDENCY in $(cat "${DEPENDENCIES}") local dependency
for dependency in $(cat "${dependencies_file}")
do do
INSTALL_MANAGED__${OS_NAME} ${DEPENDENCY} "setup.os._.install-managed.${OS_NAME}" "${dependency}"
done done
unset dependency
[[ ${ERRORS} -ne 0 ]] && { [[ "${ERRORS}" -ne 0 ]] && {
WARNING "detected ${ERRORS} errors; double check warnings before proceeding!" echo.warning "detected ${ERRORS} errors; double check warnings before proceeding!"
yN 'continue with install?' && return 0 || ABORT utils.yN 'continue with install?' && return 0 || utils.abort
} }
case ${OS_NAME} in case "${OS_NAME}" in
( macos ) ( macos )
local P local shellenv_line='eval "$(/opt/homebrew/bin/brew shellenv 2>/dev/null || /usr/local/bin/brew shellenv 2>/dev/null)"'
for P in "$(brew --prefix)"/opt/*/libexec/gnubin(N); do export PATH="${P}:${PATH}"; done grep -qF "${shellenv_line}" "${HOME}/.zprofile" 2>/dev/null \
|| echo "${shellenv_line}" >> "${HOME}/.zprofile"
local gnubin_path
for gnubin_path in "$(brew --prefix)"/opt/*/libexec/gnubin(N); do export PATH="${gnubin_path}:${PATH}"; done
unset gnubin_path
local gnubin_line='for P in "$(brew --prefix)"/opt/*/libexec/gnubin(N); do export PATH="${P}:${PATH}"; done' local gnubin_line='for P in "$(brew --prefix)"/opt/*/libexec/gnubin(N); do export PATH="${P}:${PATH}"; done'
grep -qF "${gnubin_line}" "${HOME}/.zprofile" 2>/dev/null \ grep -qF "${gnubin_line}" "${HOME}/.zprofile" 2>/dev/null \
@@ -108,108 +174,120 @@ OS__INSTALL_MANAGED_DEPENDENCIES() {
;; ;;
esac esac
SUCCESS 'all dependencies satisfied' echo.success 'all dependencies satisfied'
return 0 return 0
} }
########################################## ##########################################
UPDATE_REPOSITORIES__arch() { yay -Syu; } setup.os._.update-repositories.arch() { yay -Syu; }
INSTALL_MANAGED__arch() { setup.os._.install-managed.arch() {
local TARGET="$1" local target="${1}"
[[ ${TARGET} =~ aws-cli-v2 ]] && { [[ "${target}" =~ aws-cli-v2 ]] && {
STATUS "skipping aws-cli-v2 checks since they are bad right now" echo.status "skipping aws-cli-v2 checks since they are bad right now"
return 0 return 0
} }
yay -Qq 2>/dev/null | grep -q "^${TARGET}$\|^${TARGET}-git$" && { yay -Qq 2>/dev/null | grep -q "^${target}$\|^${target}-git$" && {
SUCCESS "found '${TARGET}'" echo.success "found '${target}'"
} || { } || {
STATUS "installing '${TARGET}'" echo.status "installing '${target}'"
yay -Syu --noconfirm ${TARGET} \ yay -Syu --noconfirm "${target}" \
&& SUCCESS "successfully installed '${TARGET}'" \ && echo.success "successfully installed '${target}'" \
|| ERROR "failed to install '${TARGET}'" \ || echo.error "failed to install '${target}'" \
; ;
} }
} }
########################################## ##########################################
UPDATE_REPOSITORIES__debian() { sudo apt-get update && sudo apt-get upgrade; } setup.os._.update-repositories.debian() { sudo apt-get update && sudo apt-get upgrade; }
INSTALL_MANAGED__debian() { setup.os._.install-managed.debian() {
STATUS "checking / installing '$1'" local target="${1}"
sudo apt-get install --yes $1 \ echo.status "checking / installing '${target}'"
&& SUCCESS "'$1' installed" \ sudo apt-get install --yes "${target}" \
|| ERROR "failed to install $1" \ && echo.success "'${target}' installed" \
|| echo.error "failed to install ${target}" \
; ;
} }
########################################## ##########################################
UPDATE_REPOSITORIES__fedora() { setup.os._.update-repositories.fedora() {
: \ : \
&& sudo dnf update \ && sudo dnf update \
&& sudo dnf upgrade \ && sudo dnf upgrade \
&& sudo dnf install -y dnf-plugins-core \ && sudo dnf install -y dnf-plugins-core \
&& sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo \ && sudo dnf config-manager addrepo --from-repofile=https://download.docker.com/linux/fedora/docker-ce.repo \
; ;
} }
INSTALL_MANAGED__fedora() { setup.os._.install-managed.fedora() {
STATUS "checking / installing '$1'" local target="${1}"
sudo dnf install -y $1 \ echo.status "checking / installing '${target}'"
&& SUCCESS "'$1' installed" \ sudo dnf install -y "${target}" \
|| ERROR "failed to install $1" \ && echo.success "'${target}' installed" \
|| echo.error "failed to install ${target}" \
; ;
} }
########################################## ##########################################
UPDATE_REPOSITORIES__macos() { brew update && brew upgrade; } setup.os._.update-repositories.macos() { brew update && brew upgrade; }
INSTALL_MANAGED__macos() { setup.os._.install-managed.macos() {
STATUS "checking / installing '$1'" local target="${1}"
yes | brew install $1 \ brew list --versions "${target}" &>/dev/null && {
&& SUCCESS "'$1' installed" \ echo.success "found '${target}'"
|| ERROR "failed to install $1" \ } || {
echo.status "installing '${target}'"
yes | brew install "${target}" \
&& echo.success "'${target}' installed" \
|| echo.error "failed to install ${target}" \
; ;
}
} }
########################################## ##########################################
UPDATE_REPOSITORIES__generic() { return 0; } setup.os._.update-repositories.generic() { return 0; }
INSTALL_MANAGED__generic() { setup.os._.install-managed.generic() {
command -v $1 >/dev/null 2>&1 \ local target="${1}"
|| ERROR "could not find '$1'; it's up to you to install this one!" command -v "${target}" >/dev/null 2>&1 \
|| echo.error "could not find '${target}'; it's up to you to install this one!"
} }
##################################################################### #####################################################################
OS__MAKE_REQUIRED_RESOURCES() { setup.os._.make-required-resources() {
local ERRORS=0 local ERRORS=0
local DIRECTORIES=( local directories=(
"${XDG_CONFIG_HOME:-${HOME}/.config}/wryn" "${XDG_CONFIG_HOME:-${HOME}/.config}/wryn"
"${HOME}/.local/bin" "${HOME}/.local/bin"
) )
local FILES=( local files=(
"${HOME}/.zshrc" "${HOME}/.zshrc"
) )
STATUS 'making required system resources' echo.status 'making required system resources'
for D in ${DIRECTORIES} local directory
for directory in "${directories[@]}"
do do
[ ! -d ${D} ] && { mkdir -p ${D} || ERROR "failed to create directory '${D}'"; } [ ! -d "${directory}" ] && { mkdir -p "${directory}" || echo.error "failed to create directory '${directory}'"; }
done done
unset directory
for F in ${FILES} local file
for file in "${files[@]}"
do do
[ ! -f ${F} ] && { touch ${F} || ERROR "failed to create file '${F}'"; } [ ! -f "${file}" ] && { touch "${file}" || echo.error "failed to create file '${file}'"; }
done done
unset file
[[ ${ERRORS} -eq 0 ]] \ [[ "${ERRORS}" -eq 0 ]] \
&& SUCCESS 'finished creating system resources' \ && echo.success 'finished creating system resources' \
|| ERROR 'failed to create system resources' \ || echo.error 'failed to create system resources' \
; ;
return ${ERRORS} return "${ERRORS}"
} }
+29 -12
View File
@@ -1,4 +1,4 @@
[[ $EUID -eq 0 ]] && [ ! $FORCE_ROOT ] \ [[ "${EUID}" -eq 0 ]] && [[ "${FORCE_ROOT}" != true ]] \
&& { echo 'ERROR::Setup cannot be run as root'; exit 1; } && { echo 'ERROR::Setup cannot be run as root'; exit 1; }
##################################################################### #####################################################################
@@ -6,7 +6,7 @@
# normally "DOTWRYN", but uses "DOTWRYN_PATH" to avoid conflict during setup # normally "DOTWRYN", but uses "DOTWRYN_PATH" to avoid conflict during setup
cd "${0:a:h}" cd "${0:a:h}"
export DOTWRYN_PATH="$(git rev-parse --show-toplevel)" export DOTWRYN_PATH="$(git rev-parse --show-toplevel)"
cd "$DOTWRYN_PATH" cd "${DOTWRYN_PATH}"
printf 'initializing required submodules...' >&2 printf 'initializing required submodules...' >&2
git submodule update --init --remote --recursive >/dev/null 2>&1 || { git submodule update --init --remote --recursive >/dev/null 2>&1 || {
@@ -17,30 +17,47 @@ git submodule update --init --remote --recursive >/dev/null 2>&1 || {
##################################################################### #####################################################################
_DEPENDENCIES+=(zsh) DEPENDENCIES+=(zsh)
_REQUIRED_ENV+=() REQUIRED_ENV+=()
command -v fzf &>/dev/null || fzf() { head -n1; } command -v fzf &>/dev/null || fzf() { head -n1; }
command -v jo &>/dev/null || jo() { :; }
command -v jq &>/dev/null || jq() { :; }
source "$DOTWRYN_PATH/zsh/plugins/scwrypts/zsh/lib/utils/utils.module.zsh" || exit 3 source "${DOTWRYN_PATH}/zsh/plugins/scwrypts/zsh/utils/utils.module.zsh" || exit 3
unset -f fzf &>/dev/null unset -f fzf &>/dev/null
unset -f jo &>/dev/null
unset -f jq &>/dev/null
# register the '.wryn' dotwryn scwrypts group; scwrypts only discovers groups
# listed in SCWRYPTS_GROUP_DIRS inside this file, and this file doesn't exist
# yet on a fresh machine
scwrypts_user_config_dir="${XDG_CONFIG_HOME:-${HOME}/.config}/scwrypts"
scwrypts_user_config="${scwrypts_user_config_dir}/config.zsh"
mkdir -p "${scwrypts_user_config_dir}"
[ -f "${scwrypts_user_config}" ] \
|| cp "${DOTWRYN_PATH}/zsh/plugins/scwrypts/zsh/config.user.zsh" "${scwrypts_user_config}"
grep -qF "${DOTWRYN_PATH}/scwrypts" "${scwrypts_user_config}" \
|| echo "SCWRYPTS_GROUP_DIRS+=(\"${DOTWRYN_PATH}/scwrypts\")" >> "${scwrypts_user_config}"
unset scwrypts_user_config_dir scwrypts_user_config
SCWRYPTS() { SCWRYPTS() {
CI=1 \ CI=1 \
CONFIG__USER_SETTINGS="$DOTWRYN_PATH/config/scwrypts/dotfiles.zsh" \ CONFIG__USER_SETTINGS="${DOTWRYN_PATH}/config/scwrypts/dotfiles.zsh" \
DOTWRYN=$DOTWRYN_PATH \ DOTWRYN="${DOTWRYN_PATH}" \
"$DOTWRYN_PATH/zsh/plugins/scwrypts/scwrypts" -n $@ "${DOTWRYN_PATH}/zsh/plugins/scwrypts/scwrypts" -n "${@}"
} }
##################################################################### #####################################################################
source "$DOTWRYN_PATH/setup/os.zsh" source "${DOTWRYN_PATH}/setup/os.zsh"
source "$DOTWRYN_PATH/setup/git.zsh" source "${DOTWRYN_PATH}/setup/git.zsh"
source "$DOTWRYN_PATH/setup/config.zsh" source "${DOTWRYN_PATH}/setup/config.zsh"
##################################################################### #####################################################################
clear clear
# shhh don't worry about it # shhh don't worry about it
[[ $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=$(printf "\\033[1;3$((1+$RANDOM%5))m") && continue;printf "$M${C:$i:1}" none;sleep 0.01;done;echo;unset C M;} [[ "${CI}" == true ]] || {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=$(printf "\\033[1;3$((1+$RANDOM%5))m") && continue;printf "$M${C:$i:1}" none;sleep 0.01;done;echo;unset C M;}
+27 -21
View File
@@ -1,19 +1,25 @@
#!/bin/zsh #!/bin/zsh
cd "${0:a:h}" cd "${0:a:h}"
OVERWRITE_EXISTING=0
while [[ $# -gt 0 ]] FORCE_ROOT=false
CI=false
OVERWRITE_EXISTING=false
COMPILE_DMENU=true
MIN=false
while [[ "${#}" -gt 0 ]]
do do
case $1 in case "${1}" in
--force-root ) FORCE_ROOT=1 ;; ( --force-root ) FORCE_ROOT=true ;;
--ci ) export CI=1 ;; ( --ci ) export CI=true ;;
--overwrite ) OVERWRITE_EXISTING=1 ;; ( --overwrite ) OVERWRITE_EXISTING=true ;;
--no-compile-dmenu ) COMPILE_DMENU=0 ;; ( --no-compile-dmenu ) COMPILE_DMENU=false ;;
--min ) ( --min )
MIN=1 MIN=true
COMPILE_DMENU=0 COMPILE_DMENU=false
;; ;;
esac esac
shift 1 shift 1
@@ -21,22 +27,22 @@ done
source ./requirements.zsh || exit 1 source ./requirements.zsh || exit 1
################################################################################ ################################################################################
LOGFILE="${HOME}/dotwryn-install.txt" logfile="${HOME}/dotwryn-install.txt"
STATUS "installation start : $(date)" 2>> "${LOGFILE}" echo.status "installation start : $(date)" 2>> "${logfile}"
{ {
SETUP__OS || FAIL 1 'failed to set up os-dependencies (see above)' setup.os || utils.fail 1 'failed to set up os-dependencies (see above)'
SETUP__GIT || FAIL 2 'failed to set up git (see above)' setup.git || utils.fail 2 'failed to set up git (see above)'
SETUP__CONFIG || FAIL 3 'failed to set up program configuration (see above)' setup.config || utils.fail 3 'failed to set up program configuration (see above)'
} 2>&1 | tee -a "${LOGFILE}" } 2>&1 | tee -a "${logfile}"
STATUS "installation complete: $(date)" 2>> "${LOGFILE}" echo.status "installation complete: $(date)" 2>> "${logfile}"
################################################################################ ################################################################################
[[ ${ERRORS} -eq 0 ]] || { [[ "${ERRORS}" -eq 0 ]] || {
yN 'keep logfile?' \ utils.yN 'keep logfile?' \
|| { rm "${LOGFILE}" || ERROR "unable to remove '${LOGFILE}'" } || { rm "${logfile}" || echo.error "unable to remove '${logfile}'" }
} }
SUCCESS "\n.wryn setup complete; have a nice day :)\n " echo.success "\n.wryn setup complete; have a nice day :)\n "