aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/checker-after-init.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-07-11 09:52:14 +0200
committerChocobozzz <me@florianbigard.com>2023-07-11 09:52:14 +0200
commitc57ad141a9ffb67f8e7d087b92eaacd2b653b562 (patch)
treebddd5d4457cb9c922275cc1d8bb71cd88b1d0293 /server/initializers/checker-after-init.ts
parent784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428 (diff)
downloadPeerTube-c57ad141a9ffb67f8e7d087b92eaacd2b653b562.tar.gz
PeerTube-c57ad141a9ffb67f8e7d087b92eaacd2b653b562.tar.zst
PeerTube-c57ad141a9ffb67f8e7d087b92eaacd2b653b562.zip
Rename webtorrent config to web_videos
Diffstat (limited to 'server/initializers/checker-after-init.ts')
-rw-r--r--server/initializers/checker-after-init.ts38
1 files changed, 32 insertions, 6 deletions
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts
index 21bc5911c..906a918e3 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`')
@@ -198,7 +224,7 @@ function checkStorageConfig () {
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 Web Video transcoding or HLS transcoding.') 228 throw new Error('You need to enable at least Web Video transcoding or HLS transcoding.')
203 } 229 }
204 230