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

@@ -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'