Skip to content

Commit

Permalink
server: Add minimal headscale support
Browse files Browse the repository at this point in the history
  • Loading branch information
antialize committed May 12, 2024
1 parent 4b95f6e commit 91bf52d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions server/src/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ import * as Mustache from 'mustache';
import { DeployJob } from './jobs/deployJob';
import { errorHandler, descript } from './error';

import { promisify } from 'util';


//Type only import
import { HostClient } from './hostclient';
import nullCheck from './shared/nullCheck';
import {exec} from 'child_process';

interface IDeployContent {
script: string | null;
Expand Down Expand Up @@ -902,6 +906,13 @@ export class Deployment {
if (type && type.content.kind == 'trigger') {
ans = await this.deploySingle(hostClient, o.script, o.nextContent);
} else if (!type || type.content.kind == 'delta') {
if (o.title == "headscale" && o.nextContent != null) {
const exec2 = promisify(exec);
const { stdout, stderr } = await exec2("headscale -o json --force --user scadmin preauthkeys create --reusable --expiration 1h");
const output = JSON.parse(stdout);
o.nextContent['scaleAuthKey'] = output['key'];
}

ans = await this.deploySingle(hostClient, o.script, {
old: o.prevContent,
new: o.nextContent,
Expand Down

0 comments on commit 91bf52d

Please sign in to comment.