aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/checker-after-init.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/checker-after-init.ts')
-rw-r--r--server/initializers/checker-after-init.ts50
1 files changed, 38 insertions, 12 deletions
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts
index 68dea909d..5ef72058b 100644
--- a/server/initializers/checker-after-init.ts
+++ b/server/initializers/checker-after-init.ts
@@ -1,4 +1,5 @@
1import config from 'config' 1import config from 'config'
2import { readFileSync, writeFileSync } from 'fs-extra'
2import { URL } from 'url' 3import { URL } from 'url'
3import { uniqify } from '@shared/core-utils' 4import { uniqify } from '@shared/core-utils'
4import { getFFmpegVersion } from '@shared/ffmpeg' 5import { getFFmpegVersion } from '@shared/ffmpeg'
@@ -10,7 +11,7 @@ import { logger } from '../helpers/logger'
10import { ApplicationModel, getServerActor } from '../models/application/application' 11import { ApplicationModel, getServerActor } from '../models/application/application'
11import { OAuthClientModel } from '../models/oauth/oauth-client' 12import { OAuthClientModel } from '../models/oauth/oauth-client'
12import { UserModel } from '../models/user/user' 13import { UserModel } from '../models/user/user'
13import { CONFIG, isEmailEnabled } from './config' 14import { CONFIG, getLocalConfigFilePath, isEmailEnabled, reloadConfig } from './config'
14import { WEBSERVER } from './constants' 15import { WEBSERVER } from './constants'
15 16
16async function checkActivityPubUrls () { 17async function checkActivityPubUrls () {
@@ -37,10 +38,7 @@ function checkConfig () {
37 const configFiles = config.util.getConfigSources().map(s => s.name).join(' -> ') 38 const configFiles = config.util.getConfigSources().map(s => s.name).join(' -> ')
38 logger.info('Using following configuration file hierarchy: %s.', configFiles) 39 logger.info('Using following configuration file hierarchy: %s.', configFiles)
39 40
40 // Moved configuration keys 41 checkRemovedConfigKeys()
41 if (config.has('services.csp-logger')) {
42 logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.')
43 }
44 42
45 checkSecretsConfig() 43 checkSecretsConfig()
46 checkEmailConfig() 44 checkEmailConfig()
@@ -104,6 +102,34 @@ export {
104 102
105// --------------------------------------------------------------------------- 103// ---------------------------------------------------------------------------
106 104
105function checkRemovedConfigKeys () {
106 // Moved configuration keys
107 if (config.has('services.csp-logger')) {
108 logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.')
109 }
110
111 if (config.has('transcoding.webtorrent.enabled')) {
112 const localConfigPath = getLocalConfigFilePath()
113
114 const content = readFileSync(localConfigPath, { encoding: 'utf-8' })
115 if (!content.includes('"webtorrent"')) {
116 throw new Error('Please rename transcoding.webtorrent.enabled key to transcoding.web_videos.enabled in your configuration file')
117 }
118
119 try {
120 logger.info(
121 'Replacing "transcoding.webtorrent.enabled" key to "transcoding.web_videos.enabled" in your local configuration ' + localConfigPath
122 )
123
124 writeFileSync(localConfigPath, content.replace('"webtorrent"', '"web_videos"'), { encoding: 'utf-8' })
125
126 reloadConfig()
127 } catch (err) {
128 logger.error('Cannot write new configuration to file ' + localConfigPath, { err })
129 }
130 }
131}
132
107function checkSecretsConfig () { 133function checkSecretsConfig () {
108 if (!CONFIG.SECRETS.PEERTUBE) { 134 if (!CONFIG.SECRETS.PEERTUBE) {
109 throw new Error('secrets.peertube is missing in config. Generate one using `openssl rand -hex 32`') 135 throw new Error('secrets.peertube is missing in config. Generate one using `openssl rand -hex 32`')
@@ -191,15 +217,15 @@ function checkStorageConfig () {
191 } 217 }
192 } 218 }
193 219
194 if (CONFIG.STORAGE.VIDEOS_DIR === CONFIG.STORAGE.REDUNDANCY_DIR) { 220 if (CONFIG.STORAGE.WEB_VIDEOS_DIR === CONFIG.STORAGE.REDUNDANCY_DIR) {
195 logger.warn('Redundancy directory should be different than the videos folder.') 221 logger.warn('Redundancy directory should be different than the videos folder.')
196 } 222 }
197} 223}
198 224
199function checkTranscodingConfig () { 225function checkTranscodingConfig () {
200 if (CONFIG.TRANSCODING.ENABLED) { 226 if (CONFIG.TRANSCODING.ENABLED) {
201 if (CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false && CONFIG.TRANSCODING.HLS.ENABLED === false) { 227 if (CONFIG.TRANSCODING.WEB_VIDEOS.ENABLED === false && CONFIG.TRANSCODING.HLS.ENABLED === false) {
202 throw new Error('You need to enable at least WebTorrent transcoding or HLS transcoding.') 228 throw new Error('You need to enable at least Web Video transcoding or HLS transcoding.')
203 } 229 }
204 230
205 if (CONFIG.TRANSCODING.CONCURRENCY <= 0) { 231 if (CONFIG.TRANSCODING.CONCURRENCY <= 0) {
@@ -264,7 +290,7 @@ function checkLiveConfig () {
264function checkObjectStorageConfig () { 290function checkObjectStorageConfig () {
265 if (CONFIG.OBJECT_STORAGE.ENABLED === true) { 291 if (CONFIG.OBJECT_STORAGE.ENABLED === true) {
266 292
267 if (!CONFIG.OBJECT_STORAGE.VIDEOS.BUCKET_NAME) { 293 if (!CONFIG.OBJECT_STORAGE.WEB_VIDEOS.BUCKET_NAME) {
268 throw new Error('videos_bucket should be set when object storage support is enabled.') 294 throw new Error('videos_bucket should be set when object storage support is enabled.')
269 } 295 }
270 296
@@ -273,10 +299,10 @@ function checkObjectStorageConfig () {
273 } 299 }
274 300
275 if ( 301 if (
276 CONFIG.OBJECT_STORAGE.VIDEOS.BUCKET_NAME === CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS.BUCKET_NAME && 302 CONFIG.OBJECT_STORAGE.WEB_VIDEOS.BUCKET_NAME === CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS.BUCKET_NAME &&
277 CONFIG.OBJECT_STORAGE.VIDEOS.PREFIX === CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS.PREFIX 303 CONFIG.OBJECT_STORAGE.WEB_VIDEOS.PREFIX === CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS.PREFIX
278 ) { 304 ) {
279 if (CONFIG.OBJECT_STORAGE.VIDEOS.PREFIX === '') { 305 if (CONFIG.OBJECT_STORAGE.WEB_VIDEOS.PREFIX === '') {
280 throw new Error('Object storage bucket prefixes should be set when the same bucket is used for both types of video.') 306 throw new Error('Object storage bucket prefixes should be set when the same bucket is used for both types of video.')
281 } 307 }
282 308