From d367c4edd037a607673a1e0b529eb861576429fa Mon Sep 17 00:00:00 2001 From: Pepe44DEV Date: Sat, 30 May 2026 17:44:38 +0200 Subject: [PATCH] version/update system: version.sh, --update flag, UPDATE_MODULES, auto-detect existing install --- install.sh | 61 ++++++++++++++++++++++++++++++++++++---- lib/tui-fs.sh | 27 ++++++++++++++++++ lib/version.sh | 39 +++++++++++++++++++++++++ modules/core/packages.sh | 2 +- 4 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 lib/version.sh diff --git a/install.sh b/install.sh index 8b0ea0a..869534d 100755 --- a/install.sh +++ b/install.sh @@ -13,9 +13,12 @@ source "$OMERON_ROOT/lib/tui-fs.sh" source "$OMERON_ROOT/lib/utils.sh" source "$OMERON_ROOT/lib/config.sh" source "$OMERON_ROOT/lib/modules.sh" +source "$OMERON_ROOT/lib/version.sh" OMERON_FRESH_INSTALL="${OMERON_FRESH_INSTALL:-0}" export OMERON_FRESH_INSTALL +OMERON_UPDATE_MODE="${OMERON_UPDATE_MODE:-0}" +export OMERON_UPDATE_MODE DEFAULT_MODULES=( "core/preflight" @@ -40,6 +43,17 @@ FRESH_MODULES=( "core/sddm" ) +UPDATE_MODULES=( + "core/packages" + "core/ags" + "core/dotfiles" + "core/services" + "homelab/setup" + "optional/install" + "post/apply-theme" + "core/sddm" +) + RUN_MODULES=() SKIP_MODULES=() WITH_SDDM=0 @@ -52,6 +66,7 @@ Usage: ./install.sh [OPTIONS] Options: --fresh Full system setup (Hyprland + GPU drivers + all deps) + --update Update existing installation (skip preflight + GPU setup) --modules m1,m2 Run only specific modules (comma-separated) --skip m1,m2 Skip specific modules (comma-separated) --skip-packages Skip package installation @@ -62,6 +77,7 @@ Options: Examples: ./install.sh Interactive (detects fresh install automatically) ./install.sh --fresh Force full setup on a running system + ./install.sh --update Update existing installation ./install.sh --modules core/dotfiles,post/apply-theme ./install.sh --skip core/packages EOF @@ -85,7 +101,8 @@ list_modules() { parse_args() { while [[ $# -gt 0 ]]; do case "$1" in - --fresh) OMERON_FRESH_INSTALL=1; shift ;; + --fresh) OMERON_FRESH_INSTALL=1; OMERON_UPDATE_MODE=0; shift ;; + --update) OMERON_UPDATE_MODE=1; OMERON_FRESH_INSTALL=0; shift ;; --modules) IFS=',' read -ra RUN_MODULES <<< "$2"; shift 2 ;; --skip) IFS=',' read -ra SKIP_MODULES <<< "$2"; shift 2 ;; --skip-packages) SKIP_MODULES+=("core/packages"); shift ;; @@ -111,6 +128,11 @@ detect_environment() { fi fi + if ((OMERON_UPDATE_MODE)); then + tui_fs_show_ok "Update mode — existing installation detected" + return + fi + if ((!OMERON_FRESH_INSTALL)) && ((${#RUN_MODULES[@]} == 0)); then tui_fs_show_msg "Checking for fresh install..." if is_fresh_install; then @@ -142,7 +164,9 @@ collect_modules() { fi local modules=() - if ((OMERON_FRESH_INSTALL)); then + if ((OMERON_UPDATE_MODE)); then + modules=("${UPDATE_MODULES[@]}") + elif ((OMERON_FRESH_INSTALL)); then modules=("${FRESH_MODULES[@]}") else modules=("${DEFAULT_MODULES[@]}") @@ -168,7 +192,9 @@ collect_all_interactive() { exec 1>&2 local modules=() - if ((OMERON_FRESH_INSTALL)); then + if ((OMERON_UPDATE_MODE)); then + modules=("${UPDATE_MODULES[@]}") + elif ((OMERON_FRESH_INSTALL)); then modules=("${FRESH_MODULES[@]}") else modules=("${DEFAULT_MODULES[@]}") @@ -233,6 +259,16 @@ main() { tui_fs_init + if ((!OMERON_FRESH_INSTALL)) && ((!OMERON_UPDATE_MODE)) && ((${#RUN_MODULES[@]} == 0)); then + if version_read; then + if tui_fs_ask_update "${OMERON_INSTALL_DATE:-unknown}"; then + OMERON_UPDATE_MODE=1 + export OMERON_UPDATE_MODE + tui_fs_show_ok "Update mode activated" + fi + fi + fi + detect_environment local modules_to_run=() @@ -285,6 +321,12 @@ main() { tui_fs_exit + if ((OMERON_UPDATE_MODE)); then + version_update + else + version_write + fi + printf '\n' tui_header "O M E R O N — Done" tui_success "Installation Complete!" @@ -292,17 +334,24 @@ main() { tui_info "Log: ${OMERON_LOG_FILE}" printf '\n' - if ((OMERON_FRESH_INSTALL)); then + if ((OMERON_UPDATE_MODE)); then + tui_bold "Update complete!" + tui_list \ + "Reload config: hyprctl reload" \ + "Re-run updater: ./install.sh --update" + elif ((OMERON_FRESH_INSTALL)); then tui_bold "Your system is ready for Hyprland!" tui_list \ "Start Hyprland: Hyprland" \ "Or enable SDDM: sudo systemctl enable --now sddm" \ - "Reload config: hyprctl reload" + "Reload config: hyprctl reload" \ + "Update later: ./install.sh --update" else tui_bold "What next?" tui_list \ "Reload config: hyprctl reload" \ - "Re-run installer: ./install.sh" + "Re-run installer: ./install.sh" \ + "Update later: ./install.sh --update" fi printf '\n' diff --git a/lib/tui-fs.sh b/lib/tui-fs.sh index 7c37bea..9685e69 100644 --- a/lib/tui-fs.sh +++ b/lib/tui-fs.sh @@ -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 $? +} diff --git a/lib/version.sh b/lib/version.sh new file mode 100644 index 0000000..33986bf --- /dev/null +++ b/lib/version.sh @@ -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" < "$tmp" + mv "$tmp" "$OMERON_VERSION_FILE" + else + version_write + fi +} diff --git a/modules/core/packages.sh b/modules/core/packages.sh index 634b489..a7f5d52 100755 --- a/modules/core/packages.sh +++ b/modules/core/packages.sh @@ -83,7 +83,7 @@ module_main() { return 0 fi - if ((OMERON_FRESH_INSTALL)); then + if ((OMERON_FRESH_INSTALL || OMERON_UPDATE_MODE)); then tui_info "Running system update first..." sudo_run pacman -Syu --noconfirm 2>&1 | tail -3 || true fi