Consolidate some scripts; simplify unneeded logic; take OS as arg

This commit is contained in:
2025-08-28 23:14:42 -05:00
parent d4f05595d2
commit 759958b126
8 changed files with 78 additions and 88 deletions

View File

@@ -1,16 +1,14 @@
# repo containing configs and scripts to set up a box
### script run
- [prerequisites below are fulfilled]
- fulfill prerequisites below
- git clone this repo
- from the repo's root directory, run `./box_setup`
- from the repo's root directory, run `./box_setup <OS name>`
### prerequisites
- package manager is configured (i.e. source repos, mirrors, etc. configured)
- zsh is installed (scripts are written for zsh)
- sudo access is configured for current user (2025-01-27, not needed on macos)
- export the env var `BOX_SETUP_OS` to indicate the operating system
- options defined in `set_script_env_vars` file
- sudo access is configured for current user (as of 2025-01-27, not needed on macos)
- system-specific items below are fulfilled
##### prereqs, os specific, linux-placeholder
@@ -31,18 +29,15 @@
### todo items
- add logic to the main run script to handle cloning of this repo
- add logic to the main run script to set `BOX_SETUP_OS` var, either input param or detect
- config for ghostty
- config for window manager for linux (first, decide which wm to use)
- config for terminal emulator (currently ghostty)
- config for mpd, mpc, ncmpcpp
- config for mpv
- config for gimp, `src_files/.config/GIMP` (dir)
- set things in gtkrc only? still need to nest that within a sub dir?
- or maybe just configure in gimp's gui, copy the whole resulting dir into
`src_files/.config/GIMP` (edit out and delete what i don't need) and call it a day
- decide on window manager for linux, then do config
- look into xquartz for macos (x/xorg emulation or something?)
- build in flags/logic for skipping certain installs/builds (and maybe configs?) on a
given system (i.e. don't install on a company box, on a server, etc.)
- or configure in gimp, copy resulting dir to `src_files/.config/GIMP`, call it a day
- maybe build in flags/logic for skipping certain installs/builds (and maybe configs?)
on a given system (i.e. don't install on a company box, on a server, etc.)
- decide on and implement approach for languages and versioning
- asdf, or language-specific version managers?
- docker? or alternatives like podman? any license concerns?

View File

@@ -1,9 +1,42 @@
#!/bin/zsh
source set_script_env_vars
[[ -z $1 ]] &&
echo "OS must be passed as an arg (options: arch, artix, debian, macos)" &&
echo "example: ./box_setup arch" &&
exit 1
# set env vars for installs
local install_cmd=''
local update_pkg_manager_and_defs_cmd=''
local update_pkgs_cmd=''
case $1 in
(arch | artix)
install_cmd="sudo pacman -S"
update_pkg_manager_and_defs_cmd='' # don't; update system instead?
update_pkgs_cmd='sudo pacman -Syu'
;;
(debian)
install_cmd="sudo apt install"
update_pkg_manager_and_defs_cmd='sudo apt update'
update_pkgs_cmd='sudo apt upgrade'
;;
(macos)
install_cmd="brew install"
update_pkg_manager_and_defs_cmd='brew update'
update_pkgs_cmd='brew upgrade'
;;
esac
export BOX_SETUP_INSTALL_COMMAND="$install_cmd"
export BOX_SETUP_UPDATE_PKG_MANAGER_AND_DEFS_CMD="$update_pkg_manager_and_defs_cmd"
export BOX_SETUP_UPDATE_PKGS_CMD="$update_pkgs_cmd"
# make dirs and copy configs/dotfiles
source ./src_files/.config/zsh/.zshenv
./make_config_dirs
./make_dirs
./copy_configs
source $ZDOTDIR/.zshenv ; source $ZDOTDIR/.zshrc
./make_org_structure_dirs
./install_programs # TODO: do installs overwrite configs? if so, fix; worst case, re-copy
# install programs
source $ZDOTDIR/.zshenv
source $ZDOTDIR/.zshrc
./install_programs

View File

@@ -1,7 +1,6 @@
#!/bin/zsh
execute() { log "execute $@" && "$@" }
log() { echo "$@" }
execute() { echo "executing: $@" && "$@" }
copy_file() {
local from=$1
@@ -30,14 +29,13 @@ copy_dir() {
link_dir() {
local src_dir=$1
local link_dir=$2
log "deleting existing link/dir: $link_dir"
[[ -h "$link_dir" ]] && rm $link_dir
[[ -d "$link_dir" ]] && rm -rf $link_dir
log "sym-linking $link_dir -> $src_dir"
echo "sym-linking $link_dir -> $src_dir"
ln -s $src_dir $link_dir
}
log "---------------- dotfiles ----------------"
echo "---- copying dotfiles -------------------------"
copy_file src_files/.config/zsh/.zshenv $HOME # duplicate, copy anyway, ensures $ZDOTDIR

View File

@@ -1,31 +1,22 @@
#!/bin/zsh
local single_script_filter=""
local dry="0"
execute() {
log "execute $@"
[[ $dry != "1" ]] && "$@"
}
log() {
[[ $dry != "1" ]] && echo "$@" || echo "[DRY RUN]: $@"
}
while [[ $# > 0 ]]; do
[[ $1 == "--dry" ]] && dry="1" || single_script_filter="$1"
single_script_filter="$1" # if using param, export BOX_SETUP_OS first if needed
shift
done
log "install_programs // single_script_filter: $single_script_filter"
echo "---- installing programs ----------------------"
local scripts=$(find ./installs_and_builds -maxdepth 1 -mindepth 1 -type f | sort)
for script in ${=scripts}; do
if [[ -x $script ]]; then
if echo "$script" | grep -qv "$single_script_filter"; then
log "filter is $single_script_filter // ignoring: $script"
continue
continue # $single_script_filter set, ignore others
fi
execute ./$script
echo "executing: $script"
./$script
fi
done

View File

@@ -1,14 +0,0 @@
#!/bin/zsh
source ./src_files/.config/zsh/.zshenv # source these vars for use below
[[ ! -d "$DIR_LOCAL" ]] && mkdir "$DIR_LOCAL"
[[ ! -d "$DIR_BIN" ]] && mkdir "$DIR_BIN"
[[ ! -d "$DIR_BUILD" ]] && mkdir "$DIR_BUILD"
[[ ! -d "$DIR_SCRIPTS" ]] && mkdir "$DIR_SCRIPTS"
[[ ! -d "$DIR_TMP" ]] && mkdir "$DIR_TMP"
[[ ! -d "$XDG_CONFIG_HOME" ]] && mkdir "$XDG_CONFIG_HOME"
[[ ! -d "$XDG_CACHE_HOME" ]] && mkdir "$XDG_CACHE_HOME"
[[ ! -d "$XDG_DATA_HOME" ]] && mkdir "$XDG_DATA_HOME"
[[ ! -d "$XDG_STATE_HOME" ]] && mkdir "$XDG_STATE_HOME"

23
make_dirs Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/zsh
source ./src_files/.config/zsh/.zshenv # ensure env vars set for use below
# some standard/common dirs, some overlap/use in XDG dirs
[[ ! -d "$DIR_LOCAL" ]] && mkdir "$DIR_LOCAL"
[[ ! -d "$DIR_BIN" ]] && mkdir "$DIR_BIN"
[[ ! -d "$DIR_BUILD" ]] && mkdir "$DIR_BUILD"
[[ ! -d "$DIR_SCRIPTS" ]] && mkdir "$DIR_SCRIPTS"
[[ ! -d "$DIR_TMP" ]] && mkdir "$DIR_TMP"
# dirs related to XDG Base Directory specification
[[ ! -d "$XDG_CONFIG_HOME" ]] && mkdir "$XDG_CONFIG_HOME"
[[ ! -d "$XDG_CACHE_HOME" ]] && mkdir "$XDG_CACHE_HOME"
[[ ! -d "$XDG_DATA_HOME" ]] && mkdir "$XDG_DATA_HOME"
[[ ! -d "$XDG_STATE_HOME" ]] && mkdir "$XDG_STATE_HOME"
# dirs for how i'm organizing my system
[[ ! -d "$DIR_HOME_BOX" ]] && mkdir $DIR_HOME_BOX
[[ ! -d "$DIR_DEV" ]] && mkdir $DIR_DEV
[[ ! -d "$DIR_DEV/git" ]] && mkdir $DIR_DEV/git
[[ ! -d "$DIR_DEV/git/me" ]] && mkdir $DIR_DEV/git/me
[[ ! -d "$DIR_DEV/git/other" ]] && mkdir $DIR_DEV/git/other

View File

@@ -1,8 +0,0 @@
#!/bin/zsh
[[ ! -d "$DIR_HOME_BOX" ]] && mkdir $DIR_HOME_BOX
[[ ! -d "$DIR_DEV" ]] && mkdir $DIR_DEV
[[ ! -d "$DIR_DEV/git" ]] && mkdir $DIR_DEV/git
[[ ! -d "$DIR_DEV/git/me" ]] && mkdir $DIR_DEV/git/me
[[ ! -d "$DIR_DEV/git/other" ]] && mkdir $DIR_DEV/git/other

View File

@@ -1,28 +0,0 @@
[[ -z $BOX_SETUP_OS ]] &&
echo "BOX_SETUP_OS must be set; options: arch, artix, debian, macos" &&
exit 1
local install_cmd=''
local update_pkg_manager_and_defs_cmd=''
local update_pkgs_cmd=''
case $BOX_SETUP_OS in
(arch | artix)
install_cmd="sudo pacman -S"
update_pkg_manager_and_defs_cmd='' # don't; update system instead?
update_pkgs_cmd='sudo pacman -Syu'
;;
(debian)
install_cmd="sudo apt install"
update_pkg_manager_and_defs_cmd='sudo apt update'
update_pkgs_cmd='sudo apt upgrade'
;;
(macos)
install_cmd="brew install"
update_pkg_manager_and_defs_cmd='brew update'
update_pkgs_cmd='brew upgrade'
;;
esac
export BOX_SETUP_INSTALL_COMMAND="$install_cmd"
export BOX_SETUP_UPDATE_PKG_MANAGER_AND_DEFS_CMD="$update_pkg_manager_and_defs_cmd"
export BOX_SETUP_UPDATE_PKGS_CMD="$update_pkgs_cmd"