#!/bin/sh set -e : ${target_dev='sda'} : ${target_iso='/home/liveuser/Downloads/Win10_1809Oct_English_x64.iso'} : ${exfat_dependencies='exfat-utils fuse-exfat'} : ${bios_dst='/usr/lib/syslinux/bios'} : ${bios_src='/usr/share/syslinux'} : ${bootiso_url='https://git.io/bootiso'} : ${bootiso='/tmp/bootiso'} : ${bootiso_args="--mrsync -t exfat -d ${target_dev} ${target_iso}"} name='win10-usb'; esc='\\e'; reset="${esc}[0m" green() { local string="${1}"; echo -e "${esc}[32m${string}${reset}"; } blue() { local string="${1}"; echo -e "${esc}[34m${string}${reset}"; } magenta() { local string="${1}"; echo -e "${esc}[35m${string}${reset}"; } log() { local string="${1}"; echo -e "[$(blue $name)] ${string}"; } install_exfat_dependencies() { # Fedora does not have these installed by default. log "Enabling $(magenta "RPM Fusion repos")..." sudo dnf install -y "https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm" "https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm" log "Installing $(magenta "exFAT") dependencies..." sudo dnf install -y ${exfat_dependencies} } patch_bios() { # Fedora does not put c32 bios module files in the expected location. log "Patching $(magenta "c32 bios module files") into the expected location..." sudo mkdir -pv $bios_dst sudo rsync -av $bios_src $bios_dst } download_bootiso() { # Download the bootiso script and make it executable. log "Downloading $(green "bootiso") script from $(magenta "${bootiso_url}") to $(magenta "${bootiso}")..." curl -L $bootiso_url > $bootiso chmod +x $bootiso } main() { # Do the thing. patch_bios install_exfat_dependencies download_bootiso log "Executing $(magenta "${bootiso} ${bootiso_args}")..." $bootiso $bootiso_args log "$(green "Hopefully everything worked out!") 🤞" } main