From 9b8569e537c5f3dac5a199ccfaa6e5eb71a5e33f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 20 Jul 2025 17:36:29 -0500 Subject: [PATCH] Make migrations faster to skip if they've already been run --- migrations/1751225707.sh | 8 +++++--- migrations/1751510848.sh | 5 ++++- migrations/1751672984.sh | 5 ++++- migrations/1751679069.sh | 5 ++++- migrations/1751821819.sh | 5 ++++- migrations/1752082381.sh | 5 ++++- migrations/1752292967.sh | 31 ++++++++++++++++--------------- migrations/1752643269.sh | 8 -------- migrations/1752676402.sh | 2 -- migrations/1752678932.sh | 5 ++++- migrations/1752797704.sh | 14 ++++++++------ migrations/1752885858.sh | 5 ++++- migrations/1752897642.sh | 2 +- migrations/1752955912.sh | 5 ++++- migrations/1752981882.sh | 5 ++++- migrations/1752981883.sh | 2 +- 16 files changed, 67 insertions(+), 45 deletions(-) delete mode 100644 migrations/1752676402.sh diff --git a/migrations/1751225707.sh b/migrations/1751225707.sh index c1e8acf..7c9896c 100644 --- a/migrations/1751225707.sh +++ b/migrations/1751225707.sh @@ -1,4 +1,6 @@ echo "Fixing persistent workspaces in waybar config" -sed -i 's/"persistent_workspaces":/"persistent-workspaces":/' ~/.config/waybar/config -pkill waybar -setsid waybar >/dev/null 2>&1 & + +if [[ -f ~/.config/waybar/config ]]; then + sed -i 's/"persistent_workspaces":/"persistent-workspaces":/' ~/.config/waybar/config + pkill -SIGUSR2 waybar +fi diff --git a/migrations/1751510848.sh b/migrations/1751510848.sh index 4a4e93e..4888bb2 100644 --- a/migrations/1751510848.sh +++ b/migrations/1751510848.sh @@ -1,2 +1,5 @@ echo "Installing missing fd terminal tool for finding files" -yay -S --noconfirm --needed fd + +if ! command -v fd &>/dev/null; then + yay -S --noconfirm --needed fd +fi diff --git a/migrations/1751672984.sh b/migrations/1751672984.sh index 842df4a..056cff7 100644 --- a/migrations/1751672984.sh +++ b/migrations/1751672984.sh @@ -1,2 +1,5 @@ echo "Add LocalSend as new default application" -yay -S --noconfirm --needed localsend-bin + +if ! command -v localsend &>/dev/null; then + yay -S --noconfirm --needed localsend-bin +fi diff --git a/migrations/1751679069.sh b/migrations/1751679069.sh index e42dc62..57feb12 100644 --- a/migrations/1751679069.sh +++ b/migrations/1751679069.sh @@ -1,2 +1,5 @@ echo "Install ffmpegthumbnailer for video thumbnails in the file manager" -yay -S --noconfirm --needed ffmpegthumbnailer + +if ! command -v ffmpegthumbnailer &>/dev/null; then + yay -S --noconfirm --needed ffmpegthumbnailer +fi diff --git a/migrations/1751821819.sh b/migrations/1751821819.sh index 0978dc0..a34d82e 100644 --- a/migrations/1751821819.sh +++ b/migrations/1751821819.sh @@ -1,2 +1,5 @@ echo "Install bash-completion" -yay -S --noconfirm --needed bash-completion + +if ! pacman -Q bash-completion &>/dev/null; then + yay -S --noconfirm --needed bash-completion +fi diff --git a/migrations/1752082381.sh b/migrations/1752082381.sh index eb6df91..a3b937d 100644 --- a/migrations/1752082381.sh +++ b/migrations/1752082381.sh @@ -1,2 +1,5 @@ echo "Adding gnome-keyring to make 1password work with 2FA codes" -yay -S --noconfirm --needed gnome-keyring + +if ! command -v gnome-keyring &>/dev/null; then + yay -S --noconfirm --needed gnome-keyring +fi diff --git a/migrations/1752292967.sh b/migrations/1752292967.sh index 8a6cde3..54e8d4c 100644 --- a/migrations/1752292967.sh +++ b/migrations/1752292967.sh @@ -1,18 +1,19 @@ echo "Update to use UWSM and seamless login" -sudo rm /etc/systemd/system/getty@tty1.service.d/override.conf -sudo rmdir /etc/systemd/system/getty@tty1.service.d/ 2>/dev/null || true +if ! command -v uwsm &>/dev/null; then + sudo rm -f /etc/systemd/system/getty@tty1.service.d/override.conf + sudo rmdir /etc/systemd/system/getty@tty1.service.d/ 2>/dev/null || true -if [ -f "$HOME/.bash_profile" ]; then - # Remove the specific line - sed -i '/^\[\[ -z \$DISPLAY && \$(tty) == \/dev\/tty1 \]\] && exec Hyprland$/d' "$HOME/.bash_profile" - echo "Cleaned up .bash_profile" + if [ -f "$HOME/.bash_profile" ]; then + # Remove the specific line + sed -i '/^\[\[ -z \$DISPLAY && \$(tty) == \/dev\/tty1 \]\] && exec Hyprland$/d' "$HOME/.bash_profile" + echo "Cleaned up .bash_profile" + fi + + if [ -f "$HOME/.config/environment.d/fcitx.conf" ]; then + echo "Removing GTK_IM_MODULE from fcitx config for Wayland..." + sed -i 's/^GTK_IM_MODULE=fcitx$//' "$HOME/.config/environment.d/fcitx.conf" + fi + + omarchy-refresh-plymouth -y + source ~/.local/share/omarchy/install/login.sh fi - -if [ -f "$HOME/.config/environment.d/fcitx.conf" ]; then - echo "Removing GTK_IM_MODULE from fcitx config for Wayland..." - sed -i 's/^GTK_IM_MODULE=fcitx$//' "$HOME/.config/environment.d/fcitx.conf" -fi - -omarchy-refresh-plymouth -y - -source ~/.local/share/omarchy/install/login.sh diff --git a/migrations/1752643269.sh b/migrations/1752643269.sh index 30dad9e..55cb668 100644 --- a/migrations/1752643269.sh +++ b/migrations/1752643269.sh @@ -1,13 +1,5 @@ echo "Add new matte black theme" -BACKGROUNDS_DIR=~/.config/omarchy/backgrounds/ -download_background_image() { - local url="$1" - local path="$2" - gum spin --title "Downloading $url as $path..." -- curl -sL -o "$BACKGROUNDS_DIR/$path" "$url" -} - if [[ ! -L "~/.config/omarchy/themes/matte-black" ]]; then ln -snf ~/.local/share/omarchy/themes/matte-black ~/.config/omarchy/themes/ - source ~/.local/share/omarchy/themes/matte-black/backgrounds.sh fi diff --git a/migrations/1752676402.sh b/migrations/1752676402.sh deleted file mode 100644 index 5d75583..0000000 --- a/migrations/1752676402.sh +++ /dev/null @@ -1,2 +0,0 @@ -echo "Use latest Omarchy Waybar configuration" -omarchy-refresh-waybar diff --git a/migrations/1752678932.sh b/migrations/1752678932.sh index 2b1068d..29e1e49 100644 --- a/migrations/1752678932.sh +++ b/migrations/1752678932.sh @@ -1,2 +1,5 @@ echo "Install missing docker-buildx package for out-of-the-box Kamal compatibility" -yay -S --noconfirm --needed docker-buildx + +if ! docker buildx version &>/dev/null; then + yay -S --noconfirm --needed docker-buildx +fi diff --git a/migrations/1752797704.sh b/migrations/1752797704.sh index 0f74fbe..f51aa70 100644 --- a/migrations/1752797704.sh +++ b/migrations/1752797704.sh @@ -1,15 +1,17 @@ echo "Prevent docker from requiring network readiness on boot" -sudo mkdir -p /etc/systemd/system/docker.service.d/ -sudo tee /etc/systemd/system/docker.service.d/no-block-boot.conf <<'EOF' +if [[ ! -f /etc/systemd/system/docker.service.d/no-block-boot.conf ]]; then + sudo mkdir -p /etc/systemd/system/docker.service.d/ + sudo tee /etc/systemd/system/docker.service.d/no-block-boot.conf <<'EOF' [Unit] DefaultDependencies=no EOF -sudo mkdir -p /etc/systemd/system/plymouth-quit.service.d/ -sudo tee /etc/systemd/system/plymouth-quit.service.d/wait-for-graphical.conf <<'EOF' + sudo mkdir -p /etc/systemd/system/plymouth-quit.service.d/ + sudo tee /etc/systemd/system/plymouth-quit.service.d/wait-for-graphical.conf <<'EOF' [Unit] After=multi-user.target EOF -sudo systemctl daemon-reload -sudo systemctl mask plymouth-quit-wait.service + sudo systemctl daemon-reload + sudo systemctl mask plymouth-quit-wait.service +fi diff --git a/migrations/1752885858.sh b/migrations/1752885858.sh index b582c72..900d3cf 100644 --- a/migrations/1752885858.sh +++ b/migrations/1752885858.sh @@ -1,2 +1,5 @@ echo "Install slurp + wl-screenrec for new ALT+PrintScreen screen recorder" -yay -S --noconfirm --needed slurp wl-screenrec + +if ! command -v wl-screenrec &>/dev/null || ! command -v slurp &>/dev/null; then + yay -S --noconfirm --needed slurp wl-screenrec +fi diff --git a/migrations/1752897642.sh b/migrations/1752897642.sh index 5049e92..034b78f 100644 --- a/migrations/1752897642.sh +++ b/migrations/1752897642.sh @@ -1,4 +1,4 @@ echo "Remove needless fcitx5-configtool package" -if command -v fcitx5-configtool &>/dev/null; then +if yay -Qe fcitx5-configtool &>/dev/null; then yay -Rns --noconfirm fcitx5-configtool fi diff --git a/migrations/1752955912.sh b/migrations/1752955912.sh index 6b9e039..8c59fb2 100644 --- a/migrations/1752955912.sh +++ b/migrations/1752955912.sh @@ -1,2 +1,5 @@ echo "Install satty for the new screenshot flow" -yay -S --noconfirm --needed satty + +if ! command -v satty &>/dev/null; then + yay -S --noconfirm --needed satty +fi diff --git a/migrations/1752981882.sh b/migrations/1752981882.sh index f78d178..9a37ae1 100644 --- a/migrations/1752981882.sh +++ b/migrations/1752981882.sh @@ -1,2 +1,5 @@ echo "Add missing libappindicator-gtk3 for Dropbox icon tray to work right" -yay -S --noconfirm --needed libappindicator-gtk3 + +if ! pacman -Q libappindicator-gtk3 &>/dev/null; then + yay -S --noconfirm --needed libappindicator-gtk3 +fi diff --git a/migrations/1752981883.sh b/migrations/1752981883.sh index ae3f485..4fe1d4d 100644 --- a/migrations/1752981883.sh +++ b/migrations/1752981883.sh @@ -1,6 +1,6 @@ echo "Replace wofi with walker as the default launcher" -if [[ ! -d ~/.config/walker ]]; then +if ! command -v walker &>/dev/null; then yay -Sy --noconfirm --needed walker-bin libqalculate yay -Rns --noconfirm wofi