version/update system: version.sh, --update flag, UPDATE_MODULES, auto-detect existing install

This commit is contained in:
2026-05-30 17:44:38 +02:00
parent dc7ef3cc51
commit d367c4edd0
4 changed files with 122 additions and 7 deletions

View File

@@ -182,3 +182,30 @@ tui_fs_confirm_start() {
[[ "$response" =~ ^[yY](es)?$ ]]
return $?
}
tui_fs_ask_update() {
local date="$1"
[[ "$TUI_FS_ACTIVE" -eq 0 ]] && return 1
tput cup 4 0 2>/dev/null || true
tput ed 2>/dev/null || true
printf ' \033[1;36m┌─\033[0m \033[1;37mExisting Installation Found\033[0m\n'
printf ' \033[1;36m│\033[0m\n'
printf ' \033[1;36m│\033[0m Installed: \033[1;37m%s\033[0m\n' "$date"
printf ' \033[1;36m│\033[0m Update applies new dotfiles, packages and config\n'
printf ' \033[1;36m│\033[0m without re-running GPU/fresh-install setup.\n'
printf ' \033[1;36m└─\033[0m\n'
printf '\n'
printf ' \033[1;36m?\033[0m Update existing installation? \033[1m[Y/n]\033[0m '
if ((OMERON_HAS_GUM)); then
gum confirm "Update existing installation?"
return $?
fi
read -r response
response="${response:-Y}"
[[ "$response" =~ ^[yY](es)?$ ]]
return $?
}

39
lib/version.sh Normal file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/env bash
OMERON_VERSION_DIR="${OMERON_VERSION_DIR:-$HOME/.local/share/omeron}"
OMERON_VERSION_FILE="$OMERON_VERSION_DIR/version"
version_read() {
if [[ -f "$OMERON_VERSION_FILE" ]]; then
source "$OMERON_VERSION_FILE"
return 0
fi
return 1
}
version_write() {
mkdir -p "$OMERON_VERSION_DIR"
cat > "$OMERON_VERSION_FILE" <<VERSION
# Omeron Version File
OMERON_VERSION=1
OMERON_INSTALL_DATE="$(date '+%Y-%m-%d %H:%M:%S')"
OMERON_LAST_UPDATE="$(date '+%Y-%m-%d %H:%M:%S')"
VERSION
}
version_update() {
mkdir -p "$OMERON_VERSION_DIR"
if [[ -f "$OMERON_VERSION_FILE" ]]; then
local tmp
tmp="$(mktemp)"
while IFS= read -r line; do
case "$line" in
OMERON_LAST_UPDATE=*) printf 'OMERON_LAST_UPDATE="%s"\n' "$(date '+%Y-%m-%d %H:%M:%S')" ;;
*) printf '%s\n' "$line" ;;
esac
done < "$OMERON_VERSION_FILE" > "$tmp"
mv "$tmp" "$OMERON_VERSION_FILE"
else
version_write
fi
}