Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated vanilla image creation via VNC #55

Merged
merged 9 commits into from
Sep 30, 2022
2 changes: 1 addition & 1 deletion templates/base.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
packer {
required_plugins {
tart = {
version = ">= 0.3.1"
version = ">= 0.5.1"
source = "github.com/cirruslabs/tart"
}
}
Expand Down
41 changes: 41 additions & 0 deletions templates/disable-sip.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
packer {
required_plugins {
tart = {
version = ">= 0.5.2"
source = "github.com/cirruslabs/tart"
}
}
}

variable "vm_name" {
type = string
}

source "tart-cli" "tart" {
vm_name = "${var.vm_name}"
recovery = true
cpu_count = 4
memory_gb = 8
disk_size_gb = 50
communicator = "none"
boot_command = [
# Skip over "Macintosh" and select "Options"
# to boot into macOS Recovery
"<wait60s><right><right><enter>",
# Select default language
"<wait10s><enter>",
# Open Terminal
"<wait10s><leftCtrlOn><f2><leftCtrlOff>",
"<right><right><right><right><down><down><down><enter>",
# Disable SIP
"<wait10s>csrutil disable<enter>",
"<wait10s>y<enter>",
"<wait10s>admin<enter>",
# Shutdown
"<wait10s>halt<enter>"
]
}

build {
sources = ["source.tart-cli.tart"]
}
80 changes: 80 additions & 0 deletions templates/vanilla-monterey.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
packer {
required_plugins {
tart = {
version = ">= 0.5.1"
source = "github.com/cirruslabs/tart"
}
}
}

source "tart-cli" "tart" {
from_ipsw = "latest"
vm_name = "monterey-vanilla"
cpu_count = 4
memory_gb = 8
disk_size_gb = 40
ssh_password = "admin"
ssh_username = "admin"
ssh_timeout = "120s"
boot_command = [
# hello, hola, bonjour, etc.
"<wait60s><spacebar>",
# Language
"<wait30s><enter>",
# Select Your Country and Region
"<wait10s>united states<leftShiftOn><tab><leftShiftOff><spacebar>",
# Written and Spoken Languages
"<wait10s><leftShiftOn><tab><leftShiftOff><spacebar>",
# Accessibility
"<wait10s><leftShiftOn><tab><leftShiftOff><spacebar>",
# Data & Privacy
"<wait10s><leftShiftOn><tab><leftShiftOff><spacebar>",
# Migration Assistant
"<wait10s><tab><tab><tab><spacebar>",
# Sign In with Your Apple ID
"<wait10s><leftShiftOn><tab><leftShiftOff><leftShiftOn><tab><leftShiftOff><spacebar>",
# Are you sure you want to skip signing in with an Apple ID?
"<wait10s><tab><spacebar>",
# Terms and Conditions
"<wait10s><leftShiftOn><tab><leftShiftOff><spacebar>",
# I have read and agree to the macOS Software License Agreement
"<wait10s><tab><spacebar>",
# Create a Computer Account
"<wait10s>admin<tab><tab>admin<tab>admin<tab><tab><tab><spacebar>",
# Enable Location Services
"<wait10s><leftShiftOn><tab><leftShiftOff><spacebar>",
# Are you sure you don't want to use Location Services?
"<wait10s><tab><spacebar>",
# Select Your Time Zone
"<wait10s><tab>UTC<enter><leftShiftOn><tab><leftShiftOff><spacebar>",
# Analytics
"<wait10s><tab><spacebar><leftShiftOn><tab><leftShiftOff><spacebar>",
# Screen Time
"<wait10s><tab><spacebar>",
# Siri
"<wait10s><tab><spacebar><leftShiftOn><tab><leftShiftOff><spacebar>",
# Choose Your Look
"<wait10s><leftShiftOn><tab><leftShiftOff><spacebar>",
# Enable Voice Over
"<wait10s><leftAltOn><f5><leftAltOff><wait5s>v",
# Now that the installation is done, open "System Preferences"
"<wait10s><leftAltOn><spacebar><leftAltOff>System Preferences<enter>",
# Navigate to "Sharing"
"<wait10s>sharing<enter>",
# Enable Remote Login
"<wait10s><tab><tab><tab><down><down><down><down><spacebar><tab><tab><spacebar>",
# Disable Voice Over
"<leftAltOn><f5><leftAltOff>",
]
}

build {
sources = ["source.tart-cli.tart"]

provisioner "shell" {
inline = [
// Enable passwordless sudo
"echo admin | sudo -S sh -c \"echo 'admin ALL=(ALL) NOPASSWD: ALL' | EDITOR=tee visudo /etc/sudoers.d/admin-nopasswd\"",
]
}
}
88 changes: 88 additions & 0 deletions templates/vanilla-ventura.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
packer {
required_plugins {
tart = {
version = ">= 0.5.1"
source = "github.com/cirruslabs/tart"
}
}
}

source "tart-cli" "tart" {
# You can find macOS IPSW URLs on various websites like https://ipsw.me/
# and https://www.theiphonewiki.com/wiki/Beta_Firmware/Mac/13.x
from_ipsw = "https://updates.cdn-apple.com/2022SummerSeed/fullrestores/012-70113/6F1F08B7-9A1B-48A9-93DB-55EE21121C87/UniversalMac_13.0_22A5352e_Restore.ipsw"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment about where to find the URL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 57792c0.

vm_name = "ventura-vanilla"
cpu_count = 4
memory_gb = 8
disk_size_gb = 40
ssh_password = "admin"
ssh_username = "admin"
ssh_timeout = "120s"
boot_command = [
# hello, hola, bonjour, etc.
"<wait60s><spacebar>",
# Language
"<wait30s><enter>",
# Select Your Country and Region
"<wait10s>united states<leftShiftOn><tab><leftShiftOff><spacebar>",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you're still refining this approach, but in my testing today I was able to reliably navigate through all the setup screens with 2s waits.

# Written and Spoken Languages
"<wait10s><leftShiftOn><tab><leftShiftOff><spacebar>",
# Accessibility
"<wait10s><leftShiftOn><tab><leftShiftOff><spacebar>",
# Data & Privacy
"<wait10s><leftShiftOn><tab><leftShiftOff><spacebar>",
# Migration Assistant
"<wait10s><tab><tab><tab><spacebar>",
# Sign In with Your Apple ID
"<wait10s><leftShiftOn><tab><leftShiftOff><leftShiftOn><tab><leftShiftOff><spacebar>",
# Are you sure you want to skip signing in with an Apple ID?
"<wait10s><tab><spacebar>",
# Terms and Conditions
"<wait10s><leftShiftOn><tab><leftShiftOff><spacebar>",
# I have read and agree to the macOS Software License Agreement
"<wait10s><tab><spacebar>",
# Create a Computer Account
"<wait10s>admin<tab><tab>admin<tab>admin<tab><tab><tab><spacebar>",
# Enable Location Services
"<wait10s><leftShiftOn><tab><leftShiftOff><spacebar>",
# Are you sure you don't want to use Location Services?
"<wait10s><tab><spacebar>",
# Select Your Time Zone
"<wait10s><tab>UTC<enter><leftShiftOn><tab><leftShiftOff><spacebar>",
# Analytics
"<wait10s><leftShiftOn><tab><leftShiftOff><spacebar>",
# Screen Time
"<wait10s><tab><spacebar>",
# Siri
"<wait10s><tab><spacebar><leftShiftOn><tab><leftShiftOff><spacebar>",
# Choose Your Look
"<wait10s><leftShiftOn><tab><leftShiftOff><spacebar>",
# Enable Voice Over
"<wait10s><leftAltOn><f5><leftAltOff><wait5s>v",
# Now that the installation is done, open "System Preferences"
"<wait10s><leftAltOn><spacebar><leftAltOff>System Preferences<enter>",
# Navigate to "Sharing"
"<wait10s><leftCtrlOn><f2><leftCtrlOff><right><right><right><right><down><down>sharing<enter>",
# Navigate to "Remote Login" and enable it
"<wait10s><tab><tab><tab><tab><tab><tab><tab><tab><spacebar>",
# Navigate to "Remote Login" once more and open its settings
"<wait10s><tab><tab><tab><tab><tab><tab><tab><tab><spacebar>",
# Enable "Full Disk Access"
"<wait10s><tab><spacebar>",
# Click "Done"
"<wait10s><leftShiftOn><tab><leftShiftOff><leftShiftOn><tab><leftShiftOff><spacebar>",
# Disable Voice Over
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is enabling automatic login no longer required?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I have for Ventura System Settings dance:

    
    # --- Remote login with full disk access
    # open "System Settings"
    "<wait5s><leftAltOn><spacebar><leftAltOff>System Settings<enter>",
    # Navigate to "Sharing"
    "<wait3s><leftAltOn>f<leftAltOff>sharing<return>",
    # Navigate to "Remote Login" and enable it
    "<wait3s><tab><tab><tab><tab><tab><tab><tab><tab><tab><tab><spacebar>",
    # Enable "Full Disk Access" for remote login
    "<wait3s><tab><tab><tab><tab><tab><tab><tab><tab><tab><tab><spacebar>",
    "<wait3s><tab><spacebar><leftShiftOn><tab><tab><leftShiftOff><spacebar>",
    # Close System Settings
    "<wait3s><leftAltOn>w<leftAltOff>",

    # --- Disable screen saver and lock screen
    # open "System Settings"
    "<wait5s><leftAltOn><spacebar><leftAltOff>System Settings<enter>",
    # Navigate to "lock screen"
    "<wait3s><leftAltOn>f<leftAltOff>lock screen<return>",
    # Select 'Never' for Start Screen Saver when inactive
    "<wait3s><tab><spacebar>Never<return>",
    # Select 'Never' and enter password for Require password after screen saver begins 
    "<wait3s><tab><tab><spacebar>Never<return>",
    "<wait3s>admin<return>",
    "<wait3s><spacebar>",
    # Close System Settings
    "<wait3s><leftAltOn>w<leftAltOff>",

    # --- Automatic login
    # open "System Settings"
    "<wait5s><leftAltOn><spacebar><leftAltOff>System Settings<enter>",
    # Navigate to "Users & Groups"
    "<wait3s><leftAltOn>f<leftAltOff>users groups<return>",
    # Select 'admin' and enter password for two dialogues for Automatically log in as...
    "<wait3s><tab><tab><tab><tab><tab><spacebar>",
    "<wait3s>admin<return>",
    "<wait3s>admin<return>",
    "<wait3s>admin<return>",
   # Close System Settings
    "<wait3s><leftAltOn>w<leftAltOff>",

Copy link
Contributor

@raven raven Sep 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding admin to sudoers:
There's probably a better way, as we have already enabled ssh access, but if doing it via VNC key commands 🤮

    # --- Adding admin to sudoers
    "<wait5s><leftAltOn><spacebar><leftAltOff>terminal<return>",
    "<wait3s>sudo visudo<return>",
    "<wait3s>admin<return>",
    "<wait3s><leftShiftOn>g<leftShiftOff>o",
    "<wait3s>admin<spacebar><leftShiftOn>all<leftShiftOff><spacebar>=<spacebar><leftShiftOn>9all0<spacebar>nopasswd;all<leftShiftOff><esc><leftShiftOn>;<leftShiftOff>wq<return>",
    "<wait3s>",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is enabling automatic login no longer required?

It is, it's just still WIP.

There's probably a better way, as we have already enabled ssh access, but if doing it via VNC key commands 🤮

You're right — no need for VNC for this one. Take a look at e9d0196.

"<leftAltOn><f5><leftAltOff>",
]
}

build {
sources = ["source.tart-cli.tart"]

provisioner "shell" {
inline = [
// Enable passwordless sudo
"echo admin | sudo -S sh -c \"echo 'admin ALL=(ALL) NOPASSWD: ALL' | EDITOR=tee visudo /etc/sudoers.d/admin-nopasswd\"",
]
}
}
2 changes: 1 addition & 1 deletion templates/xcode.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
packer {
required_plugins {
tart = {
version = ">= 0.3.1"
version = ">= 0.5.1"
source = "github.com/cirruslabs/tart"
}
}
Expand Down