aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tools/cli.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-01-28 11:07:23 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-01-28 11:35:26 +0100
commit26fcf2efebc681104d8e181da42b9ec112a8d28e (patch)
tree1d2a4a5c8c5547659274a765238b6b58839493eb /server/tools/cli.ts
parentb764380ac23f4e9d4677d08acdc3474c2931a16d (diff)
downloadPeerTube-26fcf2efebc681104d8e181da42b9ec112a8d28e.tar.gz
PeerTube-26fcf2efebc681104d8e181da42b9ec112a8d28e.tar.zst
PeerTube-26fcf2efebc681104d8e181da42b9ec112a8d28e.zip
Add redundancy CLI
Diffstat (limited to 'server/tools/cli.ts')
-rw-r--r--server/tools/cli.ts19
1 files changed, 18 insertions, 1 deletions
diff --git a/server/tools/cli.ts b/server/tools/cli.ts
index 58e2445ac..ba80872fb 100644
--- a/server/tools/cli.ts
+++ b/server/tools/cli.ts
@@ -6,6 +6,8 @@ import { getVideoChannel } from '../../shared/extra-utils/videos/video-channels'
6import { Command } from 'commander' 6import { Command } from 'commander'
7import { VideoChannel, VideoPrivacy } from '../../shared/models/videos' 7import { VideoChannel, VideoPrivacy } from '../../shared/models/videos'
8import { createLogger, format, transports } from 'winston' 8import { createLogger, format, transports } from 'winston'
9import { getAccessToken, getMyUserInformation } from '@shared/extra-utils'
10import { User, UserRole } from '@shared/models'
9 11
10let configName = 'PeerTube/CLI' 12let configName = 'PeerTube/CLI'
11if (isTestInstance()) configName += `-${getAppNumber()}` 13if (isTestInstance()) configName += `-${getAppNumber()}`
@@ -14,6 +16,19 @@ const config = require('application-config')(configName)
14 16
15const version = require('../../../package.json').version 17const version = require('../../../package.json').version
16 18
19async function getAdminTokenOrDie (url: string, username: string, password: string) {
20 const accessToken = await getAccessToken(url, username, password)
21 const resMe = await getMyUserInformation(url, accessToken)
22 const me: User = resMe.body
23
24 if (me.role !== UserRole.ADMINISTRATOR) {
25 console.error('You must be an administrator.')
26 process.exit(-1)
27 }
28
29 return accessToken
30}
31
17interface Settings { 32interface Settings {
18 remotes: any[], 33 remotes: any[],
19 default: number 34 default: number
@@ -222,5 +237,7 @@ export {
222 getServerCredentials, 237 getServerCredentials,
223 238
224 buildCommonVideoOptions, 239 buildCommonVideoOptions,
225 buildVideoAttributesFromCommander 240 buildVideoAttributesFromCommander,
241
242 getAdminTokenOrDie
226} 243}