mirror of
https://github.com/cirruslabs/tart.git
synced 2026-10-19 15:53:40 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afbc2e0764 | ||
|
|
0229138bd5 | ||
|
|
4d08e6365e | ||
|
|
8cd68ea8ef |
@@ -4,7 +4,5 @@
|
|||||||
<dict>
|
<dict>
|
||||||
<key>com.apple.security.virtualization</key>
|
<key>com.apple.security.virtualization</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>com.apple.vm.networking</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -44,11 +44,12 @@ struct IP: AsyncParsableCommand {
|
|||||||
let waitUntil = Calendar.current.date(byAdding: .second, value: Int(secondsToWait), to: Date.now)!
|
let waitUntil = Calendar.current.date(byAdding: .second, value: Int(secondsToWait), to: Date.now)!
|
||||||
|
|
||||||
repeat {
|
repeat {
|
||||||
if let ip = try Leases().resolveMACAddress(macAddress: vmMACAddress) {
|
if let leases = try Leases(), let ip = try leases.resolveMACAddress(macAddress: vmMACAddress) {
|
||||||
return ip
|
return ip
|
||||||
}
|
}
|
||||||
|
|
||||||
try await Task.sleep(nanoseconds: 1_000_000)
|
// wait a second
|
||||||
|
try await Task.sleep(nanoseconds: 1_000_000_000)
|
||||||
} while Date.now < waitUntil
|
} while Date.now < waitUntil
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ struct Run: AsyncParsableCommand {
|
|||||||
discussion: "Useful for integrating Tart VMs into other tools.\nUse `tart ip` in order to get an IP for SSHing or VNCing into the VM."))
|
discussion: "Useful for integrating Tart VMs into other tools.\nUse `tart ip` in order to get an IP for SSHing or VNCing into the VM."))
|
||||||
var noGraphics: Bool = false
|
var noGraphics: Bool = false
|
||||||
|
|
||||||
|
@Flag(help: "Force open a UI window, even when VNC is enabled.")
|
||||||
|
var graphics: Bool = false
|
||||||
|
|
||||||
@Flag(help: "Boot into recovery mode")
|
@Flag(help: "Boot into recovery mode")
|
||||||
var recovery: Bool = false
|
var recovery: Bool = false
|
||||||
|
|
||||||
@@ -69,6 +72,10 @@ struct Run: AsyncParsableCommand {
|
|||||||
if withSoftnet && netBridged != nil {
|
if withSoftnet && netBridged != nil {
|
||||||
throw ValidationError("--with-softnet and --net-bridged are mutually exclusive")
|
throw ValidationError("--with-softnet and --net-bridged are mutually exclusive")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if graphics && noGraphics {
|
||||||
|
throw ValidationError("--graphics and --no-graphics are mutually exclusive")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
@@ -129,7 +136,8 @@ struct Run: AsyncParsableCommand {
|
|||||||
}
|
}
|
||||||
sigintSrc.activate()
|
sigintSrc.activate()
|
||||||
|
|
||||||
if noGraphics || vnc || vncExperimental {
|
let useVNCWithoutGraphics = (vnc || vncExperimental) && !graphics
|
||||||
|
if noGraphics || useVNCWithoutGraphics {
|
||||||
dispatchMain()
|
dispatchMain()
|
||||||
} else {
|
} else {
|
||||||
runUI()
|
runUI()
|
||||||
|
|||||||
@@ -19,14 +19,21 @@ enum LeasesError: Error {
|
|||||||
class Leases {
|
class Leases {
|
||||||
private let leases: [MACAddress : Lease]
|
private let leases: [MACAddress : Lease]
|
||||||
|
|
||||||
convenience init() throws {
|
convenience init?() throws {
|
||||||
try self.init(URL(fileURLWithPath: "/var/db/dhcpd_leases"))
|
try self.init(URL(fileURLWithPath: "/var/db/dhcpd_leases"))
|
||||||
}
|
}
|
||||||
|
|
||||||
convenience init(_ fromURL: URL) throws {
|
convenience init?(_ fromURL: URL) throws {
|
||||||
let fileContents = try String(contentsOf: fromURL, encoding: .utf8)
|
do {
|
||||||
|
let urlContents = try String(contentsOf: fromURL, encoding: .utf8)
|
||||||
|
try self.init(urlContents)
|
||||||
|
} catch {
|
||||||
|
if error.isFileNotFound() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
try self.init(fileContents)
|
throw error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init(_ fromString: String) throws {
|
init(_ fromString: String) throws {
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ struct Root: AsyncParsableCommand {
|
|||||||
}
|
}
|
||||||
sigintSrc.activate()
|
sigintSrc.activate()
|
||||||
|
|
||||||
|
// Set line-buffered output for stdout
|
||||||
|
setlinebuf(stdout)
|
||||||
|
|
||||||
// Parse and run command
|
// Parse and run command
|
||||||
do {
|
do {
|
||||||
var command = try parseAsRoot()
|
var command = try parseAsRoot()
|
||||||
|
|||||||
Reference in New Issue
Block a user