diff options
Diffstat (limited to 'server/initializers/installer.ts')
-rw-r--r-- | server/initializers/installer.ts | 16 |
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' | |||
2 | import passwordGenerator from 'password-generator' | 2 | import passwordGenerator from 'password-generator' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { isTestOrDevInstance } from '@server/helpers/core-utils' | 4 | import { isTestOrDevInstance } from '@server/helpers/core-utils' |
5 | import { generateRunnerRegistrationToken } from '@server/helpers/token-generator' | ||
5 | import { getNodeABIVersion } from '@server/helpers/version' | 6 | import { getNodeABIVersion } from '@server/helpers/version' |
7 | import { RunnerRegistrationTokenModel } from '@server/models/runner/runner-registration-token' | ||
6 | import { UserRole } from '@shared/models' | 8 | import { UserRole } from '@shared/models' |
7 | import { logger } from '../helpers/logger' | 9 | import { logger } from '../helpers/logger' |
8 | import { buildUser, createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user' | 10 | import { 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 | |||
190 | async 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 | } | ||