grahampugh / erase-install

A script that automates downloading macOS installers, and optionally erasing or upgrading macOS in a single process. Watch the video!
https://grahamrpugh.com/2023/05/14/macaduk-presentation-eraseinstall.html
Apache License 2.0
834 stars 131 forks source link

[BUG] Running eraseinstall via SSH on Mac with no GUI login session results in various errors #484

Open carlashley opened 7 months ago

carlashley commented 7 months ago

Describe the bug When using erase-install to download a package version of OS installers via SSH on a Mac that has no active GUI login sessions, the script has a few errors that get returned during processing. This is not a fatal issue as the script proceeds to complete the download and creates a package.

To Reproduce

Expected behavior When using erase-install to only download a package, this should proceed without any errors.

Code/log output

[root@testhost]:~ # /Library/Management/erase-install/erase-install.sh --pkg --version 14.4 --beta --caching-server http://example.org:1234
id: : no such user
Unexpected character n at line 1
Print: Entry, "AppleLanguages:0", Does Not Exist
2024-02-08 09:51:26 | v32.0 | [log_rotate] Finished rotating logs in /Library/Management/erase-install/log

2024-02-08 09:51:26 | v32.0 | [erase-install] v32.0 script execution started: Thu  8 Feb 2024 09:51:26 AEST

2024-02-08 09:51:26 | v32.0 | [erase-install] Arguments provided: --pkg --version 14.4 --beta --caching-server http://example.org:1234
2024-02-08 09:51:26 | v32.0 | [erase-install] System version: 14.4 (Build: 23E5191e)
id: loginwindow: no such user
no user logged in
2024-02-08 09:51:26 | v32.0 | [check_for_swiftdialog_app] swiftDialog v is installed (/Library/Application Support/Dialog/Dialog.app)
2024-02-08 09:51:26 | v32.0 | [check_for_swiftdialog_app] Creating dialog log (/var/tmp/dialog.Yrm)...
2024-02-08 09:51:26 | v32.0 | [erase-install] Caffeinating this script (pid=35543)
2024-02-08 09:51:26 | v32.0 | [erase-install] Looking for existing installer app or pkg
2024-02-08 09:51:27 | v32.0 | [find_existing_installer] No valid installer found.
2024-02-08 09:51:27 | v32.0 | [erase-install] Running on architecture arm64
2024-02-08 09:51:27 | v32.0 | [check_for_mist] mist is installed (/usr/local/bin/mist)
2024-02-08 09:51:27 | v32.0 | [get_mist_list] Beta versions included
┌──────────────────┐
│ INPUT VALIDATION │
└──────────────────┘
  ├─ Search only for latest (first) result will be 'false'...
  ├─ Include betas in search results will be 'true'...
  ├─ Only include compatible installers will be 'true'...
  ├─ Export path will be '/Library/Management/erase-install/mist-list.json'...
  ├─ Export path file extension is valid...
  ├─ Output type will be 'ascii'...
┌────────┐
│ SEARCH │
└────────┘
  ├─ Searching for macOS Installer versions...
  ├─ Exported list as JSON: '/Library/Management/erase-install/mist-list.json'
  └─ Found 13 macOS Installer(s) available for download

┌────────────┬───────────────────┬─────────┬──────────┬──────────┬────────────┬────────────┐
│ IDENTIFIER │ NAME              │ VERSION │ BUILD    │ SIZE     │ DATE       │ COMPATIBLE │
├────────────┼───────────────────┼─────────┼──────────┼──────────┼────────────┼────────────┤
│ 052-45319  │ macOS Sonoma Beta │ 14.4    │ 23E5191e │ 13.45 GB │ 2024-02-08 │ True       │
│ 042-78233  │ macOS Sonoma      │ 14.3    │ 23D56    │ 13.40 GB │ 2024-01-23 │ True       │
│ 052-23678  │ macOS Sonoma      │ 14.2.1  │ 23C71    │ 13.39 GB │ 2024-01-11 │ True       │
│ 052-15153  │ macOS Sonoma      │ 14.2    │ 23C64    │ 13.39 GB │ 2023-12-12 │ True       │
│ 052-09398  │ macOS Sonoma      │ 14.1.2  │ 23B92    │ 12.92 GB │ 2023-12-01 │ True       │
│ 042-89627  │ macOS Sonoma      │ 14.1.1  │ 23B81    │ 12.92 GB │ 2023-11-17 │ True       │
│ 052-33049  │ macOS Ventura     │ 13.6.4  │ 22G513   │ 12.21 GB │ 2024-01-23 │ True       │
│ 052-14644  │ macOS Ventura     │ 13.6.3  │ 22G436   │ 12.21 GB │ 2024-01-11 │ True       │
│ 042-82952  │ macOS Ventura     │ 13.6.1  │ 22G313   │ 11.95 GB │ 2023-11-17 │ True       │
│ 052-33037  │ macOS Monterey    │ 12.7.3  │ 21H1015  │ 12.41 GB │ 2024-01-23 │ True       │
│ 052-14528  │ macOS Monterey    │ 12.7.2  │ 21G1974  │ 12.41 GB │ 2024-01-11 │ True       │
│ 042-82938  │ macOS Monterey    │ 12.7.1  │ 21G920   │ 12.41 GB │ 2023-11-17 │ True       │
│ 042-45246  │ macOS Big Sur     │ 11.7.10 │ 20G1427  │ 12.42 GB │ 2023-09-12 │ True       │
└────────────┴───────────────────┴─────────┴──────────┴──────────┴────────────┴────────────┘

Parse error: bad token
    <stdin>:1

2024-02-08 09:51:38 | v32.0 | [run_mist] Checking that selected version 14.4 is available
2024-02-08 09:51:38 | v32.0 | [run_mist] Setting mist to only list compatible installers
2024-02-08 09:51:38 | v32.0 | [run_mist] Setting mist to use Caching Server http://example.org:1234
2024-02-08 09:51:38 | v32.0 | [run_mist] Beta versions included

2024-02-08 09:51:38 | v32.0 | [run_mist] This command is now being run:

2024-02-08 09:51:38 | v32.0 | mist download installer 14.4 package --package-name InstallAssistant-%VERSION%-%BUILD%.pkg --package-identifier com.apple.InstallAssistant.%VERSION%.%BUILD%.pkg --output-directory /Library/Management/erase-install --compatible --no-ansi --caching-server http://example.org:1234 --include-betas
┌──────────────────┐
│ INPUT VALIDATION │
└──────────────────┘
  ├─ User is 'root'...
  ├─ Download search string will be '14.4'...
  ├─ Include betas in search results will be 'true'...
  ├─ Only include compatible installers will be 'true'...
  ├─ Cache downloads will be 'false'...
  ├─ Output directory will be '/Library/Management/erase-install'...
  ├─ Temporary directory will be '/private/tmp/com.ninxsoft.mist'...
  ├─ Content Caching Server URL will be 'http://example.org:1234'...
  ├─ Force flag has not been set, existing files will not be overwritten...
  ├─ Package name will be 'InstallAssistant-%VERSION%-%BUILD%.pkg'...
  ├─ Package identifier will be 'com.apple.InstallAssistant.%VERSION%.%BUILD%.pkg'...
┌────────┐
│ SEARCH │
└────────┘
  ├─ Searching for macOS download '14.4'...
  ├─ Found [052-45319] macOS Sonoma Beta 14.4 (23E5191e) [2024-02-08]
┌───────┐
│ SETUP │
└───────┘
  ├─ Creating new temporary directory '/private/tmp/com.ninxsoft.mist/052-45319'...
┌──────────┐
│ DOWNLOAD │
└──────────┘
  │
  ├ ...snipped...
  │
  ├─ [ 7 / 7 ] UpdateBrain.zip................. [ 03.80 MB / 03.80 MB (100.0%) ]
  │            Verifying...
  │            Verifying... ✓✓✓
┌─────────┐
│ PACKAGE │
└─────────┘
  ├─ Copying '/private/tmp/com.ninxsoft.mist/052-45319/InstallAssistant.pkg' to '/Library/Management/erase-install/InstallAssistant-14.4-23E5191e.pkg'...
┌──────────┐
│ TEARDOWN │
└──────────┘
  └─ Deleting temporary directory '/private/tmp/com.ninxsoft.mist/052-45319'...
2024-02-08 09:53:52 | v32.0 | [run_mist] InstallAssistant-14.4-23E5191e.pkg downloaded to /Library/Management/erase-install.
2024-02-08 09:53:52 | v32.0 | [erase-install] Sending quit message to dialog log (/var/tmp/dialog.Yrm)
/Library/Management/erase-install/erase-install.sh:3256: no matches found: /Volumes/*macOS*
2024-02-08 09:53:52 | v32.0 | [erase-install] Cleaning working directory '/Library/Management/erase-install/content'

2024-02-08 09:53:52 | v32.0 | [erase-install] attempting to terminate the 'caffeinate' process - Termination message indicates success

2024-02-08 09:53:52 | v32.0 | [finish] Script exit code: 0
[root@testhost]:~ # 

Screenshots output

Environment (please complete the following information):

grahampugh commented 6 months ago

Just as an FYI, the script is not tested via SSH. The download only is not gaining much over the mist command to be honest, you could just run that. Something like:

mist download installer 14.4 package --include-betas --compatible --caching-server <caching-server>

(your screenshot just clipped the actual command that erase-install ran)