#!/bin/bash # ParticleOS Installer Script # Installs ParticleOS to disk using bootc set -e # Colors GREEN='\033[0;32m' BLUE='\033[0;34m' RED='\033[0;31m' YELLOW='\033[1;33m' NC='\033[0m' print_status() { echo -e "${BLUE}[INFO]${NC} $1" } print_success() { echo -e "${GREEN}[SUCCESS]${NC} $1" } print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1" } print_error() { echo -e "${RED}[ERROR]${NC} $1" } print_header() { echo "" echo -e "${BLUE}================================${NC}" echo -e "${BLUE}$1${NC}" echo -e "${BLUE}================================${NC}" } # Configuration PARTICLEOS_IMAGE="git.raines.xyz/robojerk/particleos-desktop:v1.0" # Check if running as root check_root() { if [ "$EUID" -ne 0 ]; then print_error "This script must be run as root (use sudo)" exit 1 fi } # Check prerequisites check_prerequisites() { print_header "Phase 1: Check Prerequisites" # Check for bootc if ! command -v bootc &> /dev/null; then print_error "bootc not found. Please install bootc first." exit 1 fi # Check for ostree if ! command -v ostree &> /dev/null; then print_error "ostree not found. Please install ostree first." exit 1 fi print_success "All prerequisites satisfied" } # Detect target disk detect_target() { print_header "Phase 2: Detect Target Disk" print_status "Available disks:" lsblk -d -o NAME,SIZE,MODEL echo "" read -p "Enter target disk (e.g., /dev/sda): " TARGET_DISK if [ ! -b "$TARGET_DISK" ]; then print_error "Invalid disk: $TARGET_DISK" exit 1 fi print_warning "WARNING: This will erase all data on $TARGET_DISK" read -p "Are you sure? (yes/no): " CONFIRM if [ "$CONFIRM" != "yes" ]; then print_status "Installation cancelled" exit 0 fi } # Install ParticleOS install_system() { print_header "Phase 3: Install ParticleOS" print_status "Installing ParticleOS to $TARGET_DISK..." # Use bootc to install the system bootc install to-disk "$TARGET_DISK" --source-imgref "oci:$PARTICLEOS_IMAGE" if [ $? -eq 0 ]; then print_success "ParticleOS installed successfully" else print_error "Failed to install ParticleOS" exit 1 fi } # Configure bootloader configure_bootloader() { print_header "Phase 4: Configure Bootloader" print_status "Configuring bootloader..." # Mount the installed system mkdir -p /mnt/particleos mount "${TARGET_DISK}1" /mnt/particleos # Install GRUB grub-install --root-directory=/mnt/particleos "$TARGET_DISK" # Update GRUB configuration grub-mkconfig -o /mnt/particleos/boot/grub/grub.cfg # Unmount umount /mnt/particleos rmdir /mnt/particleos print_success "Bootloader configured" } # Finalize installation finalize() { print_header "Phase 5: Finalize Installation" print_success "ParticleOS installation complete!" echo "" echo "🎉 Installation Summary:" echo " Target Disk: $TARGET_DISK" echo " System: ParticleOS v1.0" echo " Package Manager: apt-ostree" echo "" echo "🔄 Next Steps:" echo " 1. Reboot your system" echo " 2. Boot into ParticleOS" echo " 3. Create your user account" echo " 4. Start using apt-ostree!" echo "" echo "📚 Useful Commands:" echo " apt-ostree status # Check system status" echo " apt-ostree list # List installed packages" echo " apt-ostree upgrade # Update system" echo " apt-ostree rollback # Rollback if needed" echo "" read -p "Reboot now? (yes/no): " REBOOT if [ "$REBOOT" = "yes" ]; then print_status "Rebooting in 5 seconds..." sleep 5 reboot fi } # Main installation process main() { echo "🚀 ParticleOS Installer" echo "=======================" echo "Installing ParticleOS to disk" echo "" # Run installation phases check_root check_prerequisites detect_target install_system configure_bootloader finalize } # Run main function main "$@"