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.ts24
1 files changed, 15 insertions, 9 deletions
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts
index c8f6b3bc2..c617b16c9 100644
--- a/server/initializers/installer.ts
+++ b/server/initializers/installer.ts
@@ -1,20 +1,21 @@
1import * as passwordGenerator from 'password-generator' 1import * as passwordGenerator from 'password-generator'
2import * as Bluebird from 'bluebird' 2import { UserRole } from '../../shared'
3import { logger, mkdirpPromise, rimrafPromise } from '../helpers'
4import { createPrivateAndPublicKeys } from '../helpers/peertube-crypto'
5import { createUserAccountAndChannel } from '../lib'
6import { clientsExist, usersExist } from './checker'
7import { CACHE, CONFIG, LAST_MIGRATION_VERSION } from './constants'
3 8
4import { database as db } from './database' 9import { database as db } from './database'
5import { CONFIG, LAST_MIGRATION_VERSION, CACHE } from './constants' 10import { createLocalAccount } from '../lib/user'
6import { clientsExist, usersExist } from './checker'
7import { logger, createCertsIfNotExist, mkdirpPromise, rimrafPromise } from '../helpers'
8import { createUserAccountAndChannel } from '../lib'
9import { UserRole } from '../../shared'
10 11
11async function installApplication () { 12async function installApplication () {
12 await db.sequelize.sync() 13 await db.sequelize.sync()
13 await removeCacheDirectories() 14 await removeCacheDirectories()
14 await createDirectoriesIfNotExist() 15 await createDirectoriesIfNotExist()
15 await createCertsIfNotExist()
16 await createOAuthClientIfNotExist() 16 await createOAuthClientIfNotExist()
17 await createOAuthAdminIfNotExist() 17 await createOAuthAdminIfNotExist()
18 await createApplicationIfNotExist()
18} 19}
19 20
20// --------------------------------------------------------------------------- 21// ---------------------------------------------------------------------------
@@ -28,7 +29,7 @@ export {
28function removeCacheDirectories () { 29function removeCacheDirectories () {
29 const cacheDirectories = CACHE.DIRECTORIES 30 const cacheDirectories = CACHE.DIRECTORIES
30 31
31 const tasks: Bluebird<any>[] = [] 32 const tasks: Promise<any>[] = []
32 33
33 // Cache directories 34 // Cache directories
34 for (const key of Object.keys(cacheDirectories)) { 35 for (const key of Object.keys(cacheDirectories)) {
@@ -120,7 +121,12 @@ async function createOAuthAdminIfNotExist () {
120 await createUserAccountAndChannel(user, validatePassword) 121 await createUserAccountAndChannel(user, validatePassword)
121 logger.info('Username: ' + username) 122 logger.info('Username: ' + username)
122 logger.info('User password: ' + password) 123 logger.info('User password: ' + password)
124}
123 125
126async function createApplicationIfNotExist () {
124 logger.info('Creating Application table.') 127 logger.info('Creating Application table.')
125 await db.Application.create({ migrationVersion: LAST_MIGRATION_VERSION }) 128 const applicationInstance = await db.Application.create({ migrationVersion: LAST_MIGRATION_VERSION })
129
130 logger.info('Creating application account.')
131 return createLocalAccount('peertube', null, applicationInstance.id, undefined)
126} 132}