From a07a76bd9ce99d82ce59dba85bdc814eac8a5b8f Mon Sep 17 00:00:00 2001 From: Preston Hunt Date: Fri, 28 Aug 2026 12:28:01 -0700 Subject: [PATCH] config: select steps via $SKIP and config.local instead of editing main() Customizing an install meant commenting out call sites inside main(), which puts every per-machine choice on the same lines that upstream changes -- so each 'git pull' conflicts, and the local diff can never be committed. Route every step through a 'run' wrapper that consults a $SKIP list of step names, and source an optional, gitignored config.local (looked up via $PRESTOBUNTU_CONFIG, ./config.local, then $XDG_CONFIG_HOME/prestobuntu/config.local) after user_config. Machine state then lives entirely outside the tracked script. run() splits $SKIP on any whitespace, so the list can span lines. Verified: multi-line SKIP, empty SKIP, unset SKIP, and that a partial name such as 'setup' does not skip 'setup_ssh'. Note the two 'remove_package' steps share the key 'remove_package', since skipping matches on the step name. Co-Authored-By: Claude Opus 5 (1M context) --- config.local.example | 22 ++++++++ setup | 117 ++++++++++++++++++++++++++++--------------- 2 files changed, 99 insertions(+), 40 deletions(-) create mode 100644 config.local.example diff --git a/config.local.example b/config.local.example new file mode 100644 index 0000000..22d55e0 --- /dev/null +++ b/config.local.example @@ -0,0 +1,22 @@ +# Per-machine prestobuntu settings. +# +# Copy to "config.local" next to the setup script (or to +# $XDG_CONFIG_HOME/prestobuntu/config.local) and edit. It is sourced by +# setup after user_config, so anything set here wins. +# +# Keeping machine-specific choices here rather than editing the setup +# script means "git pull" never conflicts with your customizations. +# config.local is gitignored. + +INSTALL_MODE="user-only" + +# Space-separated list of steps to skip; names are the function names +# listed in main(). +SKIP="setup_ssh install_rofi_greenclip install_tinyproxy + configure_gnome_settings disable_suspend_on_lid_closed + remap_capslock_to_control" + +# CHANGE_HOSTNAME_TO="my-laptop" +# SSH_REMOTE_ACCESS_PUBKEY="ssh-ed25519 AAAA... user@host" +# STATIC_IFACE="eno1" +# STATIC_ADDRESS="192.168.250.30/24" diff --git a/setup b/setup index df939ed..c684d7f 100755 --- a/setup +++ b/setup @@ -18,12 +18,49 @@ user_config() { # Set a static IP address for an Interface # STATIC_IFACE="eno1" # STATIC_ADDRESS="192.168.250.302/24" + + # Steps to skip, given as a space-separated list of the step names + # used in main() below. Prefer setting this in config.local so that + # per-machine choices do not conflict when this file is updated. + # SKIP="setup_ssh install_tinyproxy configure_gnome_settings" + SKIP="" +} + +load_local_config() { + : "source per-machine overrides, if any" + # Machine-specific settings belong outside version control: editing + # user_config directly makes every 'git pull' conflict. + local conf + for conf in "${PRESTOBUNTU_CONFIG:-}" ./config.local \ + "$XDG_CONFIG_HOME/prestobuntu/config.local"; do + if [[ -n $conf && -f $conf ]]; then + info "loading local config from $conf" + # shellcheck source=/dev/null + source "$conf" + return + fi + done +} + +run() { + : "run an install step unless its name appears in \$SKIP" + local step + # unquoted on purpose: splits on any whitespace, so SKIP may be + # written across several lines + for step in ${SKIP:-}; do + if [[ $step == "$1" ]]; then + info "skipping $1" + return + fi + done + "$@" } XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config} main() { user_config + load_local_config if [[ ! -v INSTALL_MODE || -z $INSTALL_MODE ]]; then die "must customize user_config before running; hint: ${EDITOR:-nano} $0" @@ -34,49 +71,49 @@ main() { if [[ $INSTALL_MODE == *system* ]]; then info "configuring system settings" - change_hostname - remove_package thunderbird - remove_package rhythmbox - setup_static_ip_address - make_journald_persistent - allow_user_to_view_journalctl - remove_update_messages_from_motd - remove_sudo_warning - pass_http_thru_sudo - disable_automatic_updates - disable_unwanted_services - disable_login_messages - disable_graphical_grub - cloudflare_dns - disable_sleep - create_environment_proxy_entries - install_tailscale + run change_hostname + run remove_package thunderbird + run remove_package rhythmbox + run setup_static_ip_address + run make_journald_persistent + run allow_user_to_view_journalctl + run remove_update_messages_from_motd + run remove_sudo_warning + run pass_http_thru_sudo + run disable_automatic_updates + run disable_unwanted_services + run disable_login_messages + run disable_graphical_grub + run cloudflare_dns + run disable_sleep + run create_environment_proxy_entries + run install_tailscale fi if [[ $INSTALL_MODE == *user* ]]; then - setup_git - setup_zsh_with_prezto - setup_ssh - setup_tmux - setup_nvim - install_development_packages - install_wireless_build_packages - install_ripgrep - install_fd - install_rofi_greenclip - install_kitty_terminfo - install_kitty - install_syncthing - install_tinyproxy - install_encrypted_home_packages - cleanup_user_home - configure_gnome_settings - disable_suspend_on_lid_closed - remap_capslock_to_control - setup_dialout_group - install_pscripts - enable_sudo_without_password - create_gruvbox_terminal_profile + run setup_git + run setup_zsh_with_prezto + run setup_ssh + run setup_tmux + run setup_nvim + run install_development_packages + run install_wireless_build_packages + run install_ripgrep + run install_fd + run install_rofi_greenclip + run install_kitty_terminfo + run install_kitty + run install_syncthing + run install_tinyproxy + run install_encrypted_home_packages + run cleanup_user_home + run configure_gnome_settings + run disable_suspend_on_lid_closed + run remap_capslock_to_control + run setup_dialout_group + run install_pscripts + run enable_sudo_without_password + run create_gruvbox_terminal_profile fi info "prestobuntu setup complete!"