mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
* wip * initialize callbacks * wip * smtp * list_service_interfaces * wip * wip * fix domains * fix hostname handling in NetService * misc fixes * getInstalledPackages * misc fixes * publish v6 lib * refactor service effects * fix import * fix container runtime * fix tests * apply suggestions from review
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import { T } from ".."
|
|
import { Effects } from "../types"
|
|
|
|
export class GetSslCertificate {
|
|
constructor(
|
|
readonly effects: Effects,
|
|
readonly hostnames: string[],
|
|
readonly algorithm?: T.Algorithm,
|
|
) {}
|
|
|
|
/**
|
|
* Returns the system SMTP credentials. Restarts the service if the credentials change
|
|
*/
|
|
const() {
|
|
return this.effects.getSslCertificate({
|
|
hostnames: this.hostnames,
|
|
algorithm: this.algorithm,
|
|
callback: this.effects.restart,
|
|
})
|
|
}
|
|
/**
|
|
* Returns the system SMTP credentials. Does nothing if the credentials change
|
|
*/
|
|
once() {
|
|
return this.effects.getSslCertificate({
|
|
hostnames: this.hostnames,
|
|
algorithm: this.algorithm,
|
|
})
|
|
}
|
|
/**
|
|
* Watches the system SMTP credentials. Takes a custom callback function to run whenever the credentials change
|
|
*/
|
|
async *watch() {
|
|
while (true) {
|
|
let callback: () => void
|
|
const waitForNext = new Promise<void>((resolve) => {
|
|
callback = resolve
|
|
})
|
|
yield await this.effects.getSslCertificate({
|
|
hostnames: this.hostnames,
|
|
algorithm: this.algorithm,
|
|
callback: () => callback(),
|
|
})
|
|
await waitForNext
|
|
}
|
|
}
|
|
}
|