diff options
author | Chocobozzz <me@florianbigard.com> | 2023-07-11 09:52:14 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-07-11 09:52:14 +0200 |
commit | c57ad141a9ffb67f8e7d087b92eaacd2b653b562 (patch) | |
tree | bddd5d4457cb9c922275cc1d8bb71cd88b1d0293 /server/initializers/checker-after-init.ts | |
parent | 784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428 (diff) | |
download | PeerTube-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.ts | 38 |
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 @@ | |||
1 | import config from 'config' | 1 | import config from 'config' |
2 | import { readFileSync, writeFileSync } from 'fs-extra' | ||
2 | import { URL } from 'url' | 3 | import { URL } from 'url' |
3 | import { uniqify } from '@shared/core-utils' | 4 | import { uniqify } from '@shared/core-utils' |
4 | import { getFFmpegVersion } from '@shared/ffmpeg' | 5 | import { getFFmpegVersion } from '@shared/ffmpeg' |
@@ -10,7 +11,7 @@ import { logger } from '../helpers/logger' | |||
10 | import { ApplicationModel, getServerActor } from '../models/application/application' | 11 | import { ApplicationModel, getServerActor } from '../models/application/application' |
11 | import { OAuthClientModel } from '../models/oauth/oauth-client' | 12 | import { OAuthClientModel } from '../models/oauth/oauth-client' |
12 | import { UserModel } from '../models/user/user' | 13 | import { UserModel } from '../models/user/user' |
13 | import { CONFIG, isEmailEnabled } from './config' | 14 | import { CONFIG, getLocalConfigFilePath, isEmailEnabled, reloadConfig } from './config' |
14 | import { WEBSERVER } from './constants' | 15 | import { WEBSERVER } from './constants' |
15 | 16 | ||
16 | async function checkActivityPubUrls () { | 17 | async 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 | ||
105 | function 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 | |||
107 | function checkSecretsConfig () { | 133 | function 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 | ||
199 | function checkTranscodingConfig () { | 225 | function 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 | ||