aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/installer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/installer.ts')
-rw-r--r--server/initializers/installer.ts16
1 files changed, 15 insertions, 1 deletions
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts
index f48f348a7..2406a5936 100644
--- a/server/initializers/installer.ts
+++ b/server/initializers/installer.ts
@@ -2,7 +2,9 @@ import { ensureDir, readdir, remove } from 'fs-extra'
2import passwordGenerator from 'password-generator' 2import passwordGenerator from 'password-generator'
3import { join } from 'path' 3import { join } from 'path'
4import { isTestOrDevInstance } from '@server/helpers/core-utils' 4import { isTestOrDevInstance } from '@server/helpers/core-utils'
5import { generateRunnerRegistrationToken } from '@server/helpers/token-generator'
5import { getNodeABIVersion } from '@server/helpers/version' 6import { getNodeABIVersion } from '@server/helpers/version'
7import { RunnerRegistrationTokenModel } from '@server/models/runner/runner-registration-token'
6import { UserRole } from '@shared/models' 8import { UserRole } from '@shared/models'
7import { logger } from '../helpers/logger' 9import { logger } from '../helpers/logger'
8import { buildUser, createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user' 10import { buildUser, createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user'
@@ -22,7 +24,8 @@ async function installApplication () {
22 return Promise.all([ 24 return Promise.all([
23 createApplicationIfNotExist(), 25 createApplicationIfNotExist(),
24 createOAuthClientIfNotExist(), 26 createOAuthClientIfNotExist(),
25 createOAuthAdminIfNotExist() 27 createOAuthAdminIfNotExist(),
28 createRunnerRegistrationTokenIfNotExist()
26 ]) 29 ])
27 }), 30 }),
28 31
@@ -183,3 +186,14 @@ async function createApplicationIfNotExist () {
183 186
184 return createApplicationActor(application.id) 187 return createApplicationActor(application.id)
185} 188}
189
190async function createRunnerRegistrationTokenIfNotExist () {
191 const total = await RunnerRegistrationTokenModel.countTotal()
192 if (total !== 0) return undefined
193
194 const token = new RunnerRegistrationTokenModel({
195 registrationToken: generateRunnerRegistrationToken()
196 })
197
198 await token.save()
199}