Split omarchy-migrate into its own command

So it can be updated independently and apply quicker
This commit is contained in:
David Heinemeier Hansson
2025-08-02 22:07:42 +02:00
parent d0c93e3b8a
commit e923be3f0b
2 changed files with 32 additions and 22 deletions

26
bin/omarchy-migrate Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Create the migrations state directory, we will store an empty file for each migration that has already been performed.
STATE_DIR="$HOME/.local/state/omarchy/migrations"
mkdir -p "$STATE_DIR"
# Run any pending migrations
cd ~/.local/share/omarchy
for file in migrations/*.sh; do
filename=$(basename "$file")
migrate_at="${filename%.sh}"
# Migration already applied, to re-run it simply delete the state file and try again
[ -e "${STATE_DIR}/$filename" ] && continue
echo -e "\e[32m\nRunning migration (${filename%.sh})\e[0m"
source $file
touch "${STATE_DIR}/$filename"
done
# Back to where we came from
cd - >/dev/null

View File

@ -3,30 +3,17 @@
# Exit immediately if a command exits with a non-zero status # Exit immediately if a command exits with a non-zero status
set -e set -e
# Show logo
clear clear
cat <~/.local/share/omarchy/logo.txt cat <~/.local/share/omarchy/logo.txt
cd ~/.local/share/omarchy
# Create the migrations state directory, we will store an empty file for each migration that has already been performed.
STATE_DIR="$HOME/.local/state/omarchy/migrations"
mkdir -p "$STATE_DIR"
# Get the latest while trying to preserve any modifications # Get the latest while trying to preserve any modifications
git pull --autostash omarchy_path=~/.local/share/omarchy
git diff --check || git reset --merge git -C $omarchy_path pull --autostash
git -C $omarchy_path diff --check || git -C $omarchy_path reset --merge
# Run any pending migrations # Run migrations
for file in migrations/*.sh; do "$HOME/.local/share/omarchy/bin/omarchy-migrate"
filename=$(basename "$file")
migrate_at="${filename%.sh}"
# Migration already applied, to re-run it simply delete the state file and try again
[ -e "${STATE_DIR}/$filename" ] && continue
echo -e "\e[32m\nRunning migration (${filename%.sh})\e[0m"
source $file
touch "${STATE_DIR}/$filename"
done
# Update system packages # Update system packages
echo -e "\e[32m\nUpdate system packages\e[0m" echo -e "\e[32m\nUpdate system packages\e[0m"
@ -36,6 +23,3 @@ yay -Syu --noconfirm
if [ "$(uname -r | sed 's/-arch/\.arch/')" != "$(pacman -Q linux | awk '{print $2}')" ]; then if [ "$(uname -r | sed 's/-arch/\.arch/')" != "$(pacman -Q linux | awk '{print $2}')" ]; then
gum confirm "Linux kernel has been updated. Reboot?" && sudo reboot now gum confirm "Linux kernel has been updated. Reboot?" && sudo reboot now
fi fi
# Back to where we came from
cd - >/dev/null