From dab1d11fb2bca3b7ef96fa6d4ad0eefa8e0b782b Mon Sep 17 00:00:00 2001 From: Typas Liao Date: Thu, 2 Jul 2026 16:59:22 +0800 Subject: [PATCH] fix(init): default to no system upgrade to protect shared servers Bootstrap ran a full system upgrade every time (dnf update, apt-get upgrade, zypper dup, pacman -Syu), disrupting other users on shared servers. Flip the justfile `update` default to "false" so `just init` skips upgrade blocks, and reduce init.sh to a package-index refresh instead of a full upgrade. Full upgrade stays opt-in via `just update=true init`. Co-Authored-By: Claude Opus 4.8 --- init.sh | 89 +++++++++++++++++++++++++++++--------------------------- justfile | 2 +- 2 files changed, 47 insertions(+), 44 deletions(-) diff --git a/init.sh b/init.sh index 7947733..7a98c56 100644 --- a/init.sh +++ b/init.sh @@ -8,56 +8,59 @@ OS="unknown" # detect OS KERNEL=$(uname -s) case $KERNEL in - Darwin) - OS=mac ;; - Linux) - OS="$(grep "^ID=" /etc/os-release | sed 's/ID=//;s/^"//;s/"$//')" ;; - *) - echo "unsupported system ($KERNEL)" - exit 1 +Darwin) + OS=mac + ;; +Linux) + OS="$(grep "^ID=" /etc/os-release | sed 's/ID=//;s/^"//;s/"$//')" + ;; +*) + echo "unsupported system ($KERNEL)" + exit 1 + ;; esac -# update package manager and install just +# refresh package index and install just case "$OS" in - mac) - if ! command -v nix &>/dev/null; then - sh <(curl -L https://nixos.org/nix/install) --daemon - if [ -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]; then - . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh - fi - fi - mkdir -p "$HOME/.config/nix" - if ! grep -q "experimental-features" "$HOME/.config/nix/nix.conf" 2>/dev/null; then - echo "experimental-features = nix-command flakes" >> "$HOME/.config/nix/nix.conf" - fi - ;; - fedora) - sudo dnf update -y - ;; - opensuse-tumbleweed) - sudo zypper dup -y - ;; - cachyos) - sudo pacman -Syu --noconfirm - ;; - ubuntu|debian) - sudo apt-get update - sudo apt-get upgrade -y - ;; - *) - echo "unsupported system ($OS)" - exit 1 +mac) + if ! command -v nix &>/dev/null; then + sh <(curl -L https://nixos.org/nix/install) --daemon + if [ -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]; then + . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh + fi + fi + mkdir -p "$HOME/.config/nix" + if ! grep -q "experimental-features" "$HOME/.config/nix/nix.conf" 2>/dev/null; then + echo "experimental-features = nix-command flakes" >>"$HOME/.config/nix/nix.conf" + fi + ;; +fedora) + sudo dnf makecache + ;; +opensuse-tumbleweed) + sudo zypper refresh + ;; +cachyos) + sudo pacman -Sy --noconfirm + ;; +ubuntu | debian) + sudo apt-get update + ;; +*) + echo "unsupported system ($OS)" + exit 1 + ;; esac # install just if not present if ! command -v just &>/dev/null; then - case "$OS" in - mac) nix profile add nixpkgs#just ;; - fedora) sudo dnf install -y just ;; - opensuse-tumbleweed) sudo zypper in -y just ;; - cachyos) sudo pacman -S --noconfirm just ;; - ubuntu|debian) sudo apt-get install -y just ;; - esac + case "$OS" in + mac) nix profile add nixpkgs#just ;; + fedora) sudo dnf install -y just ;; + opensuse-tumbleweed) sudo zypper in -y just ;; + cachyos) sudo pacman -S --noconfirm just ;; + ubuntu | debian) sudo apt-get install -y just ;; + esac fi # hand off to justfile diff --git a/justfile b/justfile index 8c5bd9c..ca43a5d 100644 --- a/justfile +++ b/justfile @@ -3,7 +3,7 @@ root := justfile_directory() os := if os() == "macos" { "mac" } else { `grep "^ID=" /etc/os-release | sed 's/ID=//;s/^"//;s/"$//'` } -update := "true" +update := "false" # Show available recipes help: