-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for post-boot script (#77)
* Renames boot.sh to start-runner.sh * Runs post-boot.sh if it exists
- Loading branch information
Showing
4 changed files
with
48 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...ages/VirtualMachine/Sources/VirtualMachineDomain/PostBootScriptSSHConnectionHandler.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import SSHDomain | ||
|
||
public struct PostBootScriptSSHConnectionHandler: VirtualMachineSSHConnectionHandler { | ||
public init() {} | ||
|
||
public func didConnect(to virtualMachine: VirtualMachine, through connection: SSHConnection) async throws { | ||
try await connection.executeCommand(""" | ||
export RUNNER_NAME=\(virtualMachine.name) | ||
POST_BOOT_SCRIPT_PATH="$HOME/.tartelet/post-boot.sh" | ||
if [ -f "$POST_BOOT_SCRIPT_PATH" ]; then | ||
sh $POST_BOOT_SCRIPT_PATH | ||
fi | ||
""") | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...achine/Sources/VirtualMachineDomain/SSH/CompositeVirtualMachineSSHConnectionHandler.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import SSHDomain | ||
|
||
public struct CompositeVirtualMachineSSHConnectionHandler: VirtualMachineSSHConnectionHandler { | ||
private let handlers: [VirtualMachineSSHConnectionHandler] | ||
|
||
public init(_ handlers: [VirtualMachineSSHConnectionHandler]) { | ||
self.handlers = handlers | ||
} | ||
|
||
public func didConnect(to virtualMachine: VirtualMachine, through connection: SSHConnection) async throws { | ||
for handler in handlers { | ||
try await handler.didConnect(to: virtualMachine, through: connection) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters