2025-06-25 16:47:23 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
2025-07-30 18:43:10 +02:00
|
|
|
# Exit immediately if a command exits with a non-zero status
|
|
|
|
set -e
|
|
|
|
|
2025-07-30 12:40:59 -04:00
|
|
|
STATE_DIR="$HOME/.local/state/omarchy/migrations"
|
|
|
|
|
2025-06-25 16:47:23 -07:00
|
|
|
cd ~/.local/share/omarchy
|
2025-06-28 11:46:28 -07:00
|
|
|
|
2025-07-30 12:40:59 -04:00
|
|
|
# Create the migrations state directory, we will store an empty file for each migration that has already been performed.
|
|
|
|
mkdir -p "$STATE_DIR"
|
2025-06-28 11:46:28 -07:00
|
|
|
|
2025-07-17 09:39:31 -07:00
|
|
|
# Get the latest while trying to preserve any modifications
|
2025-07-17 19:13:35 -07:00
|
|
|
git pull --autostash
|
2025-07-17 23:06:25 -07:00
|
|
|
git diff --check || git reset --merge
|
2025-06-28 11:46:28 -07:00
|
|
|
|
|
|
|
# Run any pending migrations
|
2025-07-30 12:40:59 -04:00
|
|
|
for file in migrations/*.sh; do
|
2025-06-28 11:46:28 -07:00
|
|
|
filename=$(basename "$file")
|
|
|
|
migrate_at="${filename%.sh}"
|
|
|
|
|
2025-07-30 12:40:59 -04:00
|
|
|
# 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"
|
2025-07-30 18:43:10 +02:00
|
|
|
source $file
|
|
|
|
touch "${STATE_DIR}/$filename"
|
2025-06-28 11:46:28 -07:00
|
|
|
done
|
|
|
|
|
2025-07-20 21:24:10 -05:00
|
|
|
# Update system packages
|
2025-07-22 19:08:41 -04:00
|
|
|
echo -e "\e[32m\nUpdate system packages\e[0m"
|
2025-07-20 21:24:10 -05:00
|
|
|
yay -Syu --noconfirm
|
2025-07-22 19:09:09 -04:00
|
|
|
|
|
|
|
# Back to where we came from
|
2025-07-30 18:43:10 +02:00
|
|
|
cd - >/dev/null
|
|
|
|
|