Refactor work
This commit is contained in:
1 parent
4ded01b207
commit
76699b4de0
9 files changed
+730
-142
No files matched your search
@@ -1,3 +1,3 @@
|
||||
[Daemon]
|
||||
Theme=omarchy
|
||||
ShowDelay=0
|
||||
ShowDelay=0
|
||||
Regular → Executable
+102
-86
@@ -2,40 +2,122 @@
|
||||
set -euo pipefail
|
||||
|
||||
use_omarchy_helpers() {
|
||||
export OMARCHY_PATH="/root/omarchy"
|
||||
export OMARCHY_INSTALL="/root/omarchy/install"
|
||||
export OMARCHY_INSTALL_LOG_FILE="/var/log/omarchy-install.log"
|
||||
source /root/omarchy/install/helpers/all.sh
|
||||
# Use omarchy-settings package location (installed in ISO)
|
||||
export OMARCHY_PATH="/usr/share/omarchy"
|
||||
export OMARCHY_INSTALL="/usr/share/omarchy/install"
|
||||
export OMARCHY_INSTALL_LOG_FILE="/var/log/archinstall/install.log"
|
||||
|
||||
# Load presentation helpers (clear_logo, etc.) and logging helpers (start_log_output, etc.)
|
||||
source /usr/share/omarchy/install/helpers/all.sh
|
||||
}
|
||||
|
||||
run_configurator() {
|
||||
set_tokyo_night_colors
|
||||
./configurator
|
||||
export OMARCHY_USER="$(jq -r '.users[0].username' user_credentials.json)"
|
||||
export OMARCHY_USER="$(jq -r '.username' user_info.json)"
|
||||
export OMARCHY_USER_PASSWORD_HASH="$(jq -r '.password_hash' user_info.json)"
|
||||
export OMARCHY_USER_NAME="$(cat user_full_name.txt)"
|
||||
export OMARCHY_USER_EMAIL="$(cat user_email_address.txt)"
|
||||
}
|
||||
|
||||
install_arch() {
|
||||
install_omarchy() {
|
||||
clear_logo
|
||||
gum style --foreground 3 --padding "1 0 0 $PADDING_LEFT" "Installing..."
|
||||
echo
|
||||
|
||||
# Copy user info to /tmp on the ISO side
|
||||
# omarchy-install will copy these into the chroot at the right time
|
||||
cp user_full_name.txt /tmp/omarchy-user-name.txt 2>/dev/null || true
|
||||
cp user_email_address.txt /tmp/omarchy-user-email.txt 2>/dev/null || true
|
||||
|
||||
# Check if advanced disk mode (partition TUI)
|
||||
EDIT_PARTITIONS_FLAG=""
|
||||
if [[ -f edit_partitions_flag.txt ]]; then
|
||||
EDIT_PARTITIONS_FLAG=$(cat edit_partitions_flag.txt | tr -d '\n' | xargs)
|
||||
fi
|
||||
|
||||
# ADVANCED MODE: Run disk configuration TUI before installation
|
||||
if [[ -n "$EDIT_PARTITIONS_FLAG" ]]; then
|
||||
clear_logo
|
||||
gum style --foreground 3 --padding "1 0 0 $PADDING_LEFT" "Configuring disk layout..."
|
||||
echo
|
||||
|
||||
# Run omarchy-disk-config to show partition TUI and validate
|
||||
# This updates user_configuration.json in place
|
||||
/usr/share/omarchy/bin/omarchy-disk-config \
|
||||
--config user_configuration.json \
|
||||
--creds user_credentials.json
|
||||
|
||||
disk_config_exit_code=$?
|
||||
|
||||
if [[ $disk_config_exit_code -ne 0 ]]; then
|
||||
echo "ERROR: Disk configuration failed or was cancelled"
|
||||
exit $disk_config_exit_code
|
||||
fi
|
||||
|
||||
clear_logo
|
||||
gum style --foreground 3 --padding "1 0 0 $PADDING_LEFT" "Disk configuration complete!"
|
||||
echo
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
# Run installation with the configuration (possibly updated by disk-config)
|
||||
|
||||
# Create backup log file for raw output (with ANSI codes stripped)
|
||||
touch /var/log/omarchy-install.log
|
||||
|
||||
start_log_output
|
||||
|
||||
# Set CURRENT_SCRIPT for the trap to display better when nothing is returned for some reason
|
||||
CURRENT_SCRIPT="install_base_system"
|
||||
install_base_system > >(sed -u 's/\x1b\[[0-9;]*[a-zA-Z]//g' >>/var/log/omarchy-install.log) 2>&1
|
||||
unset CURRENT_SCRIPT
|
||||
|
||||
# Ensure archinstall log directory exists
|
||||
sudo mkdir -p /var/log/archinstall
|
||||
|
||||
# Start tailing our backup log to show user what's happening
|
||||
start_log_output "/var/log/omarchy-install.log"
|
||||
|
||||
# Run omarchy-install and capture output
|
||||
# archinstall writes to /var/log/archinstall/install.log internally
|
||||
# We also capture stdout/stderr to our backup log (stripping ANSI codes for clean viewing)
|
||||
/usr/share/omarchy/bin/omarchy-install \
|
||||
--config user_configuration.json \
|
||||
--creds user_credentials.json \
|
||||
2>&1 | sed -u 's/\x1b\[[0-9;]*[a-zA-Z]//g' | tee -a /var/log/omarchy-install.log >/dev/null
|
||||
|
||||
install_exit_code=$?
|
||||
|
||||
stop_log_output
|
||||
}
|
||||
|
||||
# Check if omarchy-install failed
|
||||
if [[ $install_exit_code -ne 0 ]]; then
|
||||
echo
|
||||
echo "ERROR: Installation failed (exit code $install_exit_code)"
|
||||
echo "Check /var/log/omarchy-install.log for details"
|
||||
exit $install_exit_code
|
||||
fi
|
||||
|
||||
install_omarchy() {
|
||||
chroot_bash -lc "sudo pacman -S --noconfirm --needed gum" >/dev/null
|
||||
chroot_bash -lc "source /home/$OMARCHY_USER/.local/share/omarchy/install.sh || bash"
|
||||
|
||||
# Reboot if requested by installer
|
||||
if [[ -f /mnt/var/tmp/omarchy-install-completed ]]; then
|
||||
# Installation succeeded - copy logs to installed system for user access
|
||||
echo "Copying installation logs to installed system..."
|
||||
sudo mkdir -p /mnt/var/log
|
||||
sudo cp /var/log/omarchy-install.log /mnt/var/log/omarchy-install.log 2>/dev/null || true
|
||||
sudo cp /var/log/archinstall/install.log /mnt/var/log/archinstall-install.log 2>/dev/null || true
|
||||
|
||||
# Show completion screen
|
||||
clear
|
||||
echo
|
||||
tte -i /usr/share/omarchy/logo.txt --canvas-width 0 --anchor-text c --frame-rate 920 laseretch
|
||||
echo
|
||||
|
||||
# Display installation time if available
|
||||
if [[ -f /mnt/tmp/omarchy-install-time.txt ]]; then
|
||||
TOTAL_TIME=$(cat /mnt/tmp/omarchy-install-time.txt)
|
||||
echo "Installed in $TOTAL_TIME" | tte --canvas-width 0 --anchor-text c --frame-rate 640 print
|
||||
else
|
||||
echo "Finished installing" | tte --canvas-width 0 --anchor-text c --frame-rate 640 print
|
||||
fi
|
||||
echo
|
||||
|
||||
# Prompt for reboot (centered)
|
||||
BUTTON_WIDTH=12 # "Reboot Now" + padding
|
||||
BUTTON_PADDING=$(( (TERM_WIDTH - BUTTON_WIDTH) / 2 ))
|
||||
if gum confirm --padding "0 0 0 $BUTTON_PADDING" --show-help=false --default --affirmative "Reboot Now" --negative "" ""; then
|
||||
clear
|
||||
reboot
|
||||
fi
|
||||
}
|
||||
@@ -67,74 +149,8 @@ set_tokyo_night_colors() {
|
||||
fi
|
||||
}
|
||||
|
||||
install_base_system() {
|
||||
# Initialize and populate the keyring
|
||||
pacman-key --init
|
||||
pacman-key --populate archlinux
|
||||
pacman-key --populate omarchy
|
||||
|
||||
# Sync the offline database so pacman can find packages
|
||||
pacman -Sy --noconfirm
|
||||
|
||||
# Ensure that no mounts exist from past install attempts
|
||||
findmnt -R /mnt >/dev/null && umount -R /mnt
|
||||
|
||||
# Install using files generated by the ./configurator
|
||||
# Skip NTP and WKD sync since we're offline (keyring is pre-populated in ISO)
|
||||
archinstall \
|
||||
--config user_configuration.json \
|
||||
--creds user_credentials.json \
|
||||
--silent \
|
||||
--skip-ntp \
|
||||
--skip-wkd
|
||||
|
||||
# After archinstall sets up the base system but before our installer runs,
|
||||
# we need to ensure the offline pacman.conf is in place
|
||||
cp /etc/pacman.conf /mnt/etc/pacman.conf
|
||||
|
||||
# Mount the offline mirror so it's accessible in the chroot
|
||||
mkdir -p /mnt/var/cache/omarchy/mirror/offline
|
||||
mount --bind /var/cache/omarchy/mirror/offline /mnt/var/cache/omarchy/mirror/offline
|
||||
|
||||
# Mount the packages dir so it's accessible in the chroot
|
||||
mkdir -p /mnt/opt/packages
|
||||
mount --bind /opt/packages /mnt/opt/packages
|
||||
|
||||
# No need to ask for sudo during the installation (omarchy itself responsible for removing after install)
|
||||
mkdir -p /mnt/etc/sudoers.d
|
||||
cat >/mnt/etc/sudoers.d/99-omarchy-installer <<EOF
|
||||
root ALL=(ALL:ALL) NOPASSWD: ALL
|
||||
%wheel ALL=(ALL:ALL) NOPASSWD: ALL
|
||||
$OMARCHY_USER ALL=(ALL:ALL) NOPASSWD: ALL
|
||||
EOF
|
||||
chmod 440 /mnt/etc/sudoers.d/99-omarchy-installer
|
||||
|
||||
# Copy the local omarchy repo to the user's home directory
|
||||
mkdir -p /mnt/home/$OMARCHY_USER/.local/share/
|
||||
cp -r /root/omarchy /mnt/home/$OMARCHY_USER/.local/share/
|
||||
|
||||
chown -R 1000:1000 /mnt/home/$OMARCHY_USER/.local/
|
||||
|
||||
# Ensure all necessary scripts are executable
|
||||
find /mnt/home/$OMARCHY_USER/.local/share/omarchy -type f -path "*/bin/*" -exec chmod +x {} \;
|
||||
chmod +x /mnt/home/$OMARCHY_USER/.local/share/omarchy/boot.sh 2>/dev/null || true
|
||||
chmod +x /mnt/home/$OMARCHY_USER/.local/share/omarchy/default/waybar/indicators/screen-recording.sh 2>/dev/null || true
|
||||
}
|
||||
|
||||
chroot_bash() {
|
||||
HOME=/home/$OMARCHY_USER \
|
||||
arch-chroot -u $OMARCHY_USER /mnt/ \
|
||||
env OMARCHY_CHROOT_INSTALL=1 \
|
||||
OMARCHY_USER_NAME="$(<user_full_name.txt)" \
|
||||
OMARCHY_USER_EMAIL="$(<user_email_address.txt)" \
|
||||
USER="$OMARCHY_USER" \
|
||||
HOME="/home/$OMARCHY_USER" \
|
||||
/bin/bash "$@"
|
||||
}
|
||||
|
||||
if [[ $(tty) == "/dev/tty1" ]]; then
|
||||
use_omarchy_helpers
|
||||
run_configurator
|
||||
install_arch
|
||||
install_omarchy
|
||||
fi
|
||||
@@ -6,6 +6,27 @@ source "$OMARCHY_INSTALL/helpers/all.sh"
|
||||
# Ensure tzupdate is available for guessing timezone
|
||||
command -v tzupdate >/dev/null || sudo pacman -Sy --noconfirm tzupdate
|
||||
|
||||
# Build the package list for archinstall from omarchy-base.packages
|
||||
build_package_json() {
|
||||
local packages=("base-devel" "git" "omarchy-keyring" "omarchy-settings")
|
||||
|
||||
# Read omarchy-base.packages and add to array
|
||||
while IFS= read -r pkg; do
|
||||
[[ -z "$pkg" || "$pkg" =~ ^# ]] && continue
|
||||
packages+=("$pkg")
|
||||
done < "$OMARCHY_INSTALL/omarchy-base.packages"
|
||||
|
||||
# Format as JSON array
|
||||
local json="["
|
||||
for i in "${!packages[@]}"; do
|
||||
json+="\"${packages[$i]}\""
|
||||
[[ $i -lt $((${#packages[@]} - 1)) ]] && json+=", "
|
||||
done
|
||||
json+="]"
|
||||
|
||||
echo "$json"
|
||||
}
|
||||
|
||||
abort() {
|
||||
gum style "${1:-Aborted installation}"
|
||||
echo
|
||||
@@ -214,23 +235,54 @@ disk_form() {
|
||||
disk_options="$disk_options$disk_info"$'\n'
|
||||
fi
|
||||
done <<<"$available_disks"
|
||||
|
||||
# Add "Advanced Disk Config" option at the bottom
|
||||
disk_options="${disk_options}Advanced Disk Config (custom partitioning)"
|
||||
|
||||
selected_display=$(echo "$disk_options" | gum choose --header "Select install disk") || abort
|
||||
disk=$(echo "$selected_display" | awk '{print $1}')
|
||||
|
||||
# Check if user selected advanced config
|
||||
if echo "$selected_display" | grep -q "Advanced Disk Config"; then
|
||||
USE_ADVANCED_DISK_CONFIG=1
|
||||
EDIT_PARTITIONS="--edit-partitions"
|
||||
disk="" # Will be determined by TUI
|
||||
else
|
||||
USE_ADVANCED_DISK_CONFIG=0
|
||||
disk=$(echo "$selected_display" | awk '{print $1}')
|
||||
fi
|
||||
}
|
||||
|
||||
disk_form
|
||||
|
||||
while true; do
|
||||
gum style "Everything will be overwritten. There is no recovery possible."
|
||||
|
||||
# If user selected advanced config, skip to partition editor
|
||||
if [[ $USE_ADVANCED_DISK_CONFIG -eq 1 ]]; then
|
||||
gum style --foreground 3 "Advanced disk configuration selected."
|
||||
gum style "You'll configure partitions in the archinstall TUI."
|
||||
echo
|
||||
if gum confirm --affirmative "Yes, format disk" --negative "No, change it" "Confirm overwriting ${disk}"; then
|
||||
break
|
||||
else
|
||||
disk_form
|
||||
fi
|
||||
done
|
||||
EDIT_PARTITIONS="--edit-partitions"
|
||||
else
|
||||
# Normal flow: confirm disk wipe and use default layout
|
||||
while true; do
|
||||
gum style "Everything will be overwritten. There is no recovery possible."
|
||||
|
||||
echo
|
||||
if gum confirm --affirmative "Yes, format disk" --negative "No, change it" "Confirm overwriting ${disk}"; then
|
||||
break
|
||||
else
|
||||
disk_form
|
||||
# Check again if user switched to advanced config
|
||||
if [[ $USE_ADVANCED_DISK_CONFIG -eq 1 ]]; then
|
||||
gum style --foreground 3 "Advanced disk configuration selected."
|
||||
gum style "You'll configure partitions in the archinstall TUI."
|
||||
echo
|
||||
EDIT_PARTITIONS="--edit-partitions"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
# Normal flow always uses default layout (no editing)
|
||||
EDIT_PARTITIONS=""
|
||||
fi
|
||||
|
||||
clear
|
||||
|
||||
@@ -239,6 +291,9 @@ clear
|
||||
echo "$full_name" >user_full_name.txt
|
||||
echo "$email_address" >user_email_address.txt
|
||||
|
||||
# Save partition editing preference
|
||||
echo "$EDIT_PARTITIONS" >edit_partitions_flag.txt
|
||||
|
||||
# Escape username and password for safe inclusion
|
||||
password_escaped=$(echo -n "$password" | jq -Rsa)
|
||||
password_hash_escaped=$(echo -n "$password_hash" | jq -Rsa)
|
||||
@@ -250,27 +305,36 @@ cat <<-_EOF_ >user_credentials.json
|
||||
"root_enc_password": $password_hash_escaped,
|
||||
"users": [
|
||||
{
|
||||
"username": $username_escaped,
|
||||
"enc_password": $password_hash_escaped,
|
||||
"groups": [],
|
||||
"sudo": true,
|
||||
"username": $username_escaped
|
||||
"sudo": true
|
||||
}
|
||||
]
|
||||
}
|
||||
_EOF_
|
||||
|
||||
# Setup partition layout
|
||||
disk_size=$(lsblk -bdno SIZE "$disk")
|
||||
mib=$((1024 * 1024))
|
||||
gib=$((mib * 1024))
|
||||
disk_size_in_mib=$((disk_size / mib * mib)) # Rounds to nearest MiB
|
||||
# Save user info separately so we can create the user after packages are installed
|
||||
cat <<-_EOF_ >user_info.json
|
||||
{
|
||||
"username": $username_escaped,
|
||||
"password_hash": $password_hash_escaped
|
||||
}
|
||||
_EOF_
|
||||
|
||||
gpt_backup_reserve=$((mib))
|
||||
boot_partition_start=$((mib))
|
||||
boot_partition_size=$((2 * gib))
|
||||
# Setup partition layout (only for non-advanced config)
|
||||
if [[ $USE_ADVANCED_DISK_CONFIG -eq 0 ]]; then
|
||||
disk_size=$(lsblk -bdno SIZE "$disk")
|
||||
mib=$((1024 * 1024))
|
||||
gib=$((mib * 1024))
|
||||
disk_size_in_mib=$((disk_size / mib * mib)) # Rounds to nearest MiB
|
||||
|
||||
main_partition_start=$((boot_partition_size + boot_partition_start))
|
||||
main_partition_size=$((disk_size_in_mib - main_partition_start - gpt_backup_reserve))
|
||||
gpt_backup_reserve=$((mib))
|
||||
boot_partition_start=$((mib))
|
||||
boot_partition_size=$((2 * gib))
|
||||
|
||||
main_partition_start=$((boot_partition_size + boot_partition_start))
|
||||
main_partition_size=$((disk_size_in_mib - main_partition_start - gpt_backup_reserve))
|
||||
fi
|
||||
|
||||
# Detect T2 Mac and set appropriate kernel
|
||||
if lspci -nn 2>/dev/null | grep -q "106b:180[12]"; then
|
||||
@@ -279,14 +343,67 @@ else
|
||||
kernel_choice="linux"
|
||||
fi
|
||||
|
||||
cat <<-_EOF_ >user_configuration.json
|
||||
# Build the complete package list including all Omarchy packages
|
||||
packages_json=$(build_package_json)
|
||||
|
||||
# Generate configuration based on mode
|
||||
if [[ $USE_ADVANCED_DISK_CONFIG -eq 1 ]]; then
|
||||
# Minimal config for advanced mode - user will configure disk in TUI
|
||||
cat <<-_EOF_ >user_configuration.json
|
||||
{
|
||||
"app_config": null,
|
||||
"archinstall-language": "English",
|
||||
"auth_config": {},
|
||||
"audio_config": { "audio": "pipewire" },
|
||||
"bootloader": "Limine",
|
||||
"custom_commands": [],
|
||||
"custom_commands": [
|
||||
"/usr/share/omarchy/bin/omarchy-install-final-configurations.sh"
|
||||
],
|
||||
"hostname": "$hostname",
|
||||
"kernels": [ "$kernel_choice" ],
|
||||
"network_config": { "type": "iso" },
|
||||
"ntp": true,
|
||||
"parallel_downloads": 8,
|
||||
"script": null,
|
||||
"services": [],
|
||||
"swap": true,
|
||||
"timezone": "$timezone",
|
||||
"locale_config": {
|
||||
"kb_layout": "$keyboard",
|
||||
"sys_enc": "UTF-8",
|
||||
"sys_lang": "en_US.UTF-8"
|
||||
},
|
||||
"mirror_config": {
|
||||
"custom_repositories": [],
|
||||
"custom_servers": [
|
||||
{"url": "https://mirror.omarchy.org/\$repo/os/\$arch"},
|
||||
{"url": "https://mirror.rackspace.com/archlinux/\$repo/os/\$arch"},
|
||||
{"url": "https://geo.mirror.pkgbuild.com/\$repo/os/\$arch"}
|
||||
],
|
||||
"mirror_regions": {},
|
||||
"optional_repositories": []
|
||||
},
|
||||
"packages": $packages_json,
|
||||
"profile_config": {
|
||||
"gfx_driver": null,
|
||||
"greeter": null,
|
||||
"profile": {}
|
||||
},
|
||||
"version": "3.0.9"
|
||||
}
|
||||
_EOF_
|
||||
else
|
||||
# Full config with default partition layout
|
||||
cat <<-_EOF_ >user_configuration.json
|
||||
{
|
||||
"app_config": null,
|
||||
"archinstall-language": "English",
|
||||
"auth_config": {},
|
||||
"audio_config": { "audio": "pipewire" },
|
||||
"bootloader": "Limine",
|
||||
"custom_commands": [
|
||||
"/usr/share/omarchy/bin/omarchy-install-final-configurations.sh"
|
||||
],
|
||||
"disk_config": {
|
||||
"btrfs_options": {
|
||||
"snapshot_config": {
|
||||
@@ -353,8 +470,7 @@ cat <<-_EOF_ >user_configuration.json
|
||||
"encryption_type": "luks",
|
||||
"lvm_volumes": [],
|
||||
"iter_time": 2000,
|
||||
"partitions": [ "8c2c2b92-1070-455d-b76a-56263bab24aa" ],
|
||||
"encryption_password": $password_escaped
|
||||
"partitions": [ "8c2c2b92-1070-455d-b76a-56263bab24aa" ]
|
||||
}
|
||||
},
|
||||
"hostname": "$hostname",
|
||||
@@ -381,11 +497,7 @@ cat <<-_EOF_ >user_configuration.json
|
||||
"mirror_regions": {},
|
||||
"optional_repositories": []
|
||||
},
|
||||
"packages": [
|
||||
"base-devel",
|
||||
"git",
|
||||
"omarchy-keyring"
|
||||
],
|
||||
"packages": $packages_json,
|
||||
"profile_config": {
|
||||
"gfx_driver": null,
|
||||
"greeter": null,
|
||||
@@ -394,6 +506,7 @@ cat <<-_EOF_ >user_configuration.json
|
||||
"version": "3.0.9"
|
||||
}
|
||||
_EOF_
|
||||
fi
|
||||
|
||||
if [[ $1 == "dry" ]]; then
|
||||
echo -e "User Configuration:"
|
||||
|
||||
@@ -22,5 +22,4 @@ file_permissions=(
|
||||
["/usr/local/bin/choose-mirror"]="0:0:755"
|
||||
["/root/configurator"]="0:0:755"
|
||||
["/var/cache/omarchy/mirror/offline/"]="0:0:775"
|
||||
["/usr/local/bin/omarchy-upload-log"]="0:0:755"
|
||||
)
|
||||
Reference in new issue
Block a user