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.ts26
1 files changed, 16 insertions, 10 deletions
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts
index b9a9da183..127449577 100644
--- a/server/initializers/installer.ts
+++ b/server/initializers/installer.ts
@@ -1,14 +1,15 @@
1import * as passwordGenerator from 'password-generator' 1import * as passwordGenerator from 'password-generator'
2import { UserRole } from '../../shared' 2import { UserRole } from '../../shared'
3import { logger } from '../helpers/logger' 3import { logger } from '../helpers/logger'
4import { createApplicationActor, createUserAccountAndChannel } from '../lib/user' 4import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user'
5import { UserModel } from '../models/account/user' 5import { UserModel } from '../models/account/user'
6import { ApplicationModel } from '../models/application/application' 6import { ApplicationModel } from '../models/application/application'
7import { OAuthClientModel } from '../models/oauth/oauth-client' 7import { OAuthClientModel } from '../models/oauth/oauth-client'
8import { applicationExist, clientsExist, usersExist } from './checker-after-init' 8import { applicationExist, clientsExist, usersExist } from './checker-after-init'
9import { CACHE, CONFIG, LAST_MIGRATION_VERSION } from './constants' 9import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION } from './constants'
10import { sequelizeTypescript } from './database' 10import { sequelizeTypescript } from './database'
11import { remove, ensureDir } from 'fs-extra' 11import { ensureDir, remove } from 'fs-extra'
12import { CONFIG } from './config'
12 13
13async function installApplication () { 14async function installApplication () {
14 try { 15 try {
@@ -24,7 +25,7 @@ async function installApplication () {
24 }), 25 }),
25 26
26 // Directories 27 // Directories
27 removeCacheDirectories() 28 removeCacheAndTmpDirectories()
28 .then(() => createDirectoriesIfNotExist()) 29 .then(() => createDirectoriesIfNotExist())
29 ]) 30 ])
30 } catch (err) { 31 } catch (err) {
@@ -41,9 +42,9 @@ export {
41 42
42// --------------------------------------------------------------------------- 43// ---------------------------------------------------------------------------
43 44
44function removeCacheDirectories () { 45function removeCacheAndTmpDirectories () {
45 const cacheDirectories = Object.keys(CACHE) 46 const cacheDirectories = Object.keys(FILES_CACHE)
46 .map(k => CACHE[k].DIRECTORY) 47 .map(k => FILES_CACHE[k].DIRECTORY)
47 48
48 const tasks: Promise<any>[] = [] 49 const tasks: Promise<any>[] = []
49 50
@@ -53,13 +54,15 @@ function removeCacheDirectories () {
53 tasks.push(remove(dir)) 54 tasks.push(remove(dir))
54 } 55 }
55 56
57 tasks.push(remove(CONFIG.STORAGE.TMP_DIR))
58
56 return Promise.all(tasks) 59 return Promise.all(tasks)
57} 60}
58 61
59function createDirectoriesIfNotExist () { 62function createDirectoriesIfNotExist () {
60 const storage = CONFIG.STORAGE 63 const storage = CONFIG.STORAGE
61 const cacheDirectories = Object.keys(CACHE) 64 const cacheDirectories = Object.keys(FILES_CACHE)
62 .map(k => CACHE[k].DIRECTORY) 65 .map(k => FILES_CACHE[k].DIRECTORY)
63 66
64 const tasks: Promise<void>[] = [] 67 const tasks: Promise<void>[] = []
65 for (const key of Object.keys(storage)) { 68 for (const key of Object.keys(storage)) {
@@ -73,6 +76,9 @@ function createDirectoriesIfNotExist () {
73 tasks.push(ensureDir(dir)) 76 tasks.push(ensureDir(dir))
74 } 77 }
75 78
79 // Playlist directories
80 tasks.push(ensureDir(HLS_STREAMING_PLAYLIST_DIRECTORY))
81
76 return Promise.all(tasks) 82 return Promise.all(tasks)
77} 83}
78 84
@@ -138,7 +144,7 @@ async function createOAuthAdminIfNotExist () {
138 } 144 }
139 const user = new UserModel(userData) 145 const user = new UserModel(userData)
140 146
141 await createUserAccountAndChannel(user, validatePassword) 147 await createUserAccountAndChannelAndPlaylist(user, validatePassword)
142 logger.info('Username: ' + username) 148 logger.info('Username: ' + username)
143 logger.info('User password: ' + password) 149 logger.info('User password: ' + password)
144} 150}