#!/usr/bin/env ruby require 'hackmac' include Hackmac include Utils $config = Hackmac::Config.load dev = ARGV.shift or fail "need usb device" mountpoint = '/Volumes/USB' mountpoint_efi = '/Volumes/USB_EFI' if File.directory?(mountpoint) puts " *** #{mountpoint} already mounted!".red exit 1 end if File.directory?(mountpoint_efi) puts " *** #{mountpoint_efi} already mounted!".red exit 1 end ask("Really erase #{dev.inspect} and install #{$config.usb.os.inspect}? (y/n) ") or exit x %{diskutil partitionDisk #{dev.inspect} GPT JHFS+ "USB" 100%} x %{sudo "#{$config.usb.os}/Contents/Resources/createinstallmedia" --volume #{mountpoint.inspect} --nointeraction} x %{sudo mkdir -p #{mountpoint_efi.inspect}} x %{sudo mount -t msdos #{('/dev/' + dev + 's1').inspect} #{mountpoint_efi.inspect}} cd mountpoint_efi do x %{sudo chown $USER .} x %{git init} x %{git remote add origin #{$config.efi.source.inspect}} x %{git pull origin master} end