version/update system: version.sh, --update flag, UPDATE_MODULES, auto-detect existing install
This commit is contained in:
61
install.sh
61
install.sh
@@ -13,9 +13,12 @@ source "$OMERON_ROOT/lib/tui-fs.sh"
|
|||||||
source "$OMERON_ROOT/lib/utils.sh"
|
source "$OMERON_ROOT/lib/utils.sh"
|
||||||
source "$OMERON_ROOT/lib/config.sh"
|
source "$OMERON_ROOT/lib/config.sh"
|
||||||
source "$OMERON_ROOT/lib/modules.sh"
|
source "$OMERON_ROOT/lib/modules.sh"
|
||||||
|
source "$OMERON_ROOT/lib/version.sh"
|
||||||
|
|
||||||
OMERON_FRESH_INSTALL="${OMERON_FRESH_INSTALL:-0}"
|
OMERON_FRESH_INSTALL="${OMERON_FRESH_INSTALL:-0}"
|
||||||
export OMERON_FRESH_INSTALL
|
export OMERON_FRESH_INSTALL
|
||||||
|
OMERON_UPDATE_MODE="${OMERON_UPDATE_MODE:-0}"
|
||||||
|
export OMERON_UPDATE_MODE
|
||||||
|
|
||||||
DEFAULT_MODULES=(
|
DEFAULT_MODULES=(
|
||||||
"core/preflight"
|
"core/preflight"
|
||||||
@@ -40,6 +43,17 @@ FRESH_MODULES=(
|
|||||||
"core/sddm"
|
"core/sddm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
UPDATE_MODULES=(
|
||||||
|
"core/packages"
|
||||||
|
"core/ags"
|
||||||
|
"core/dotfiles"
|
||||||
|
"core/services"
|
||||||
|
"homelab/setup"
|
||||||
|
"optional/install"
|
||||||
|
"post/apply-theme"
|
||||||
|
"core/sddm"
|
||||||
|
)
|
||||||
|
|
||||||
RUN_MODULES=()
|
RUN_MODULES=()
|
||||||
SKIP_MODULES=()
|
SKIP_MODULES=()
|
||||||
WITH_SDDM=0
|
WITH_SDDM=0
|
||||||
@@ -52,6 +66,7 @@ Usage: ./install.sh [OPTIONS]
|
|||||||
|
|
||||||
Options:
|
Options:
|
||||||
--fresh Full system setup (Hyprland + GPU drivers + all deps)
|
--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)
|
--modules m1,m2 Run only specific modules (comma-separated)
|
||||||
--skip m1,m2 Skip specific modules (comma-separated)
|
--skip m1,m2 Skip specific modules (comma-separated)
|
||||||
--skip-packages Skip package installation
|
--skip-packages Skip package installation
|
||||||
@@ -62,6 +77,7 @@ Options:
|
|||||||
Examples:
|
Examples:
|
||||||
./install.sh Interactive (detects fresh install automatically)
|
./install.sh Interactive (detects fresh install automatically)
|
||||||
./install.sh --fresh Force full setup on a running system
|
./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 --modules core/dotfiles,post/apply-theme
|
||||||
./install.sh --skip core/packages
|
./install.sh --skip core/packages
|
||||||
EOF
|
EOF
|
||||||
@@ -85,7 +101,8 @@ list_modules() {
|
|||||||
parse_args() {
|
parse_args() {
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
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 ;;
|
--modules) IFS=',' read -ra RUN_MODULES <<< "$2"; shift 2 ;;
|
||||||
--skip) IFS=',' read -ra SKIP_MODULES <<< "$2"; shift 2 ;;
|
--skip) IFS=',' read -ra SKIP_MODULES <<< "$2"; shift 2 ;;
|
||||||
--skip-packages) SKIP_MODULES+=("core/packages"); shift ;;
|
--skip-packages) SKIP_MODULES+=("core/packages"); shift ;;
|
||||||
@@ -111,6 +128,11 @@ detect_environment() {
|
|||||||
fi
|
fi
|
||||||
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
|
if ((!OMERON_FRESH_INSTALL)) && ((${#RUN_MODULES[@]} == 0)); then
|
||||||
tui_fs_show_msg "Checking for fresh install..."
|
tui_fs_show_msg "Checking for fresh install..."
|
||||||
if is_fresh_install; then
|
if is_fresh_install; then
|
||||||
@@ -142,7 +164,9 @@ collect_modules() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local modules=()
|
local modules=()
|
||||||
if ((OMERON_FRESH_INSTALL)); then
|
if ((OMERON_UPDATE_MODE)); then
|
||||||
|
modules=("${UPDATE_MODULES[@]}")
|
||||||
|
elif ((OMERON_FRESH_INSTALL)); then
|
||||||
modules=("${FRESH_MODULES[@]}")
|
modules=("${FRESH_MODULES[@]}")
|
||||||
else
|
else
|
||||||
modules=("${DEFAULT_MODULES[@]}")
|
modules=("${DEFAULT_MODULES[@]}")
|
||||||
@@ -168,7 +192,9 @@ collect_all_interactive() {
|
|||||||
exec 1>&2
|
exec 1>&2
|
||||||
|
|
||||||
local modules=()
|
local modules=()
|
||||||
if ((OMERON_FRESH_INSTALL)); then
|
if ((OMERON_UPDATE_MODE)); then
|
||||||
|
modules=("${UPDATE_MODULES[@]}")
|
||||||
|
elif ((OMERON_FRESH_INSTALL)); then
|
||||||
modules=("${FRESH_MODULES[@]}")
|
modules=("${FRESH_MODULES[@]}")
|
||||||
else
|
else
|
||||||
modules=("${DEFAULT_MODULES[@]}")
|
modules=("${DEFAULT_MODULES[@]}")
|
||||||
@@ -233,6 +259,16 @@ main() {
|
|||||||
|
|
||||||
tui_fs_init
|
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
|
detect_environment
|
||||||
|
|
||||||
local modules_to_run=()
|
local modules_to_run=()
|
||||||
@@ -285,6 +321,12 @@ main() {
|
|||||||
|
|
||||||
tui_fs_exit
|
tui_fs_exit
|
||||||
|
|
||||||
|
if ((OMERON_UPDATE_MODE)); then
|
||||||
|
version_update
|
||||||
|
else
|
||||||
|
version_write
|
||||||
|
fi
|
||||||
|
|
||||||
printf '\n'
|
printf '\n'
|
||||||
tui_header "O M E R O N — Done"
|
tui_header "O M E R O N — Done"
|
||||||
tui_success "Installation Complete!"
|
tui_success "Installation Complete!"
|
||||||
@@ -292,17 +334,24 @@ main() {
|
|||||||
tui_info "Log: ${OMERON_LOG_FILE}"
|
tui_info "Log: ${OMERON_LOG_FILE}"
|
||||||
printf '\n'
|
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_bold "Your system is ready for Hyprland!"
|
||||||
tui_list \
|
tui_list \
|
||||||
"Start Hyprland: Hyprland" \
|
"Start Hyprland: Hyprland" \
|
||||||
"Or enable SDDM: sudo systemctl enable --now sddm" \
|
"Or enable SDDM: sudo systemctl enable --now sddm" \
|
||||||
"Reload config: hyprctl reload"
|
"Reload config: hyprctl reload" \
|
||||||
|
"Update later: ./install.sh --update"
|
||||||
else
|
else
|
||||||
tui_bold "What next?"
|
tui_bold "What next?"
|
||||||
tui_list \
|
tui_list \
|
||||||
"Reload config: hyprctl reload" \
|
"Reload config: hyprctl reload" \
|
||||||
"Re-run installer: ./install.sh"
|
"Re-run installer: ./install.sh" \
|
||||||
|
"Update later: ./install.sh --update"
|
||||||
fi
|
fi
|
||||||
printf '\n'
|
printf '\n'
|
||||||
|
|
||||||
|
|||||||
@@ -182,3 +182,30 @@ tui_fs_confirm_start() {
|
|||||||
[[ "$response" =~ ^[yY](es)?$ ]]
|
[[ "$response" =~ ^[yY](es)?$ ]]
|
||||||
return $?
|
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
39
lib/version.sh
Normal 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
|
||||||
|
}
|
||||||
@@ -83,7 +83,7 @@ module_main() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ((OMERON_FRESH_INSTALL)); then
|
if ((OMERON_FRESH_INSTALL || OMERON_UPDATE_MODE)); then
|
||||||
tui_info "Running system update first..."
|
tui_info "Running system update first..."
|
||||||
sudo_run pacman -Syu --noconfirm 2>&1 | tail -3 || true
|
sudo_run pacman -Syu --noconfirm 2>&1 | tail -3 || true
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user