]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - support/doc/tools.md
Add peertube-runner version info
[github/Chocobozzz/PeerTube.git] / support / doc / tools.md
CommitLineData
c141f68b
RK
1# CLI tools guide
2
12b119c0
RK
3<!-- START doctoc generated TOC please keep comment here to allow auto update -->
4<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
1f8ac024 5**Table of Contents**
c141f68b 6
c141f68b
RK
7- [Remote Tools](#remote-tools)
8 - [Dependencies](#dependencies)
9 - [Installation](#installation)
d639c3bf
C
10 - [CLI wrapper](#cli-wrapper)
11 - [peertube-import-videos.js](#peertube-import-videosjs)
12 - [peertube-upload.js](#peertube-uploadjs)
8dd2d050 13 - [peertube-plugins.js](#peertube-pluginsjs)
e669ff58 14 - [peertube-redundancy.js](#peertube-redundancyjs)
c141f68b
RK
15- [Server tools](#server-tools)
16 - [parse-log](#parse-log)
c2bd7a6f 17 - [regenerate-thumbnails.js](#regenerate-thumbnailsjs)
c141f68b 18 - [create-import-video-file-job.js](#create-import-video-file-jobjs)
e1ab52d7 19 - [create-move-video-storage-job.js](#create-move-video-storage-jobjs)
c141f68b 20 - [prune-storage.js](#prune-storagejs)
c141f68b 21 - [update-host.js](#update-hostjs)
31b48aad 22 - [reset-password.js](#reset-passwordjs)
13126d99 23 - [plugin install/uninstall](#plugin-installuninstall)
12b119c0
RK
24
25<!-- END doctoc generated TOC please keep comment here to allow auto update -->
26
d639c3bf
C
27## Remote Tools
28
29You need at least 512MB RAM to run the script.
30Scripts can be launched directly from a PeerTube server, or from a separate server, even a desktop PC.
31You need to follow all the following steps even if you are on a PeerTube server (including cloning the git repository in a different directory than your production installation because the scripts utilize non-production dependencies).
32
33### Dependencies
34
1ab94472 35Install the [PeerTube dependencies](/support/doc/dependencies.md) except PostgreSQL and Redis.
d639c3bf
C
36
37### Installation
38
39Clone the PeerTube repo to get the latest version (even if you are on your PeerTube server):
40
c83af8f9 41```bash
00ee545c
C
42git clone https://github.com/Chocobozzz/PeerTube.git
43CLONE="$(pwd)/PeerTube"
44cd ${CLONE}
d639c3bf
C
45```
46
7e9d3f25
C
47Install dependencies and build CLI tools:
48
c83af8f9 49```bash
00ee545c
C
50NOCLIENT=1 yarn install --pure-lockfile
51npm run setup:cli
d639c3bf
C
52```
53
54### CLI wrapper
8704acf4 55
bb8f7872
C
56The wrapper provides a convenient interface to the following scripts.
57You can access it as `peertube` via an alias in your `.bashrc` like `alias peertube="cd /your/peertube/directory/ && node ./dist/server/tools/peertube.js"` (you have to keep the `cd` command):
8704acf4
RK
58
59```
60 Usage: peertube [command] [options]
61
62 Options:
63
64 -v, --version output the version number
65 -h, --help output usage information
66
67 Commands:
68
69 auth [action] register your accounts on remote instances to use them with other commands
70 upload|up upload a video
71 import-videos|import import a video from a streaming platform
e669ff58
C
72 plugins|p [action] manage instance plugins
73 redundancy|r [action] manage video redundancies
8704acf4
RK
74 help [cmd] display help for [cmd]
75```
76
77The wrapper can keep track of instances you have an account on. We limit to one account per instance for now.
78
79```bash
00ee545c
C
80peertube auth add -u 'PEERTUBE_URL' -U 'PEERTUBE_USER' --password 'PEERTUBE_PASSWORD'
81peertube auth list
8704acf4
RK
82┌──────────────────────────────┬──────────────────────────────┐
83│ instance │ login │
84├──────────────────────────────┼──────────────────────────────┤
5b036b8e 85│ 'PEERTUBE_URL' │ 'PEERTUBE_USER' │
8704acf4
RK
86└──────────────────────────────┴──────────────────────────────┘
87```
88
89You can now use that account to upload videos without feeding the same parameters again.
90
91```bash
00ee545c 92peertube up <videoFile>
8704acf4
RK
93```
94
9b474844
C
95To list, install, uninstall dynamically plugins/themes of an instance:
96
97```bash
00ee545c
C
98peertube plugins list
99peertube plugins install --path /local/plugin/path
100peertube plugins install --npm-name peertube-plugin-myplugin
101peertube plugins uninstall --npm-name peertube-plugin-myplugin
9b474844
C
102```
103
d639c3bf 104#### peertube-import-videos.js
358770db 105
1f8ac024 106You can use this script to import videos from all [supported sites of youtube-dl](https://rg3.github.io/youtube-dl/supportedsites.html) into PeerTube.
358770db 107Be sure you own the videos or have the author's authorization to do so.
2519d9fe 108
a5f0521f 109```sh
00ee545c 110node dist/server/tools/peertube-import-videos.js \
5b036b8e
C
111 -u 'PEERTUBE_URL' \
112 -U 'PEERTUBE_USER' \
9024bece 113 --password 'PEERTUBE_PASSWORD' \
8a08bc1e 114 --target-url 'TARGET_URL'
2519d9fe
L
115```
116
a5f0521f
RK
117* `PEERTUBE_URL` : the full URL of your PeerTube server where you want to import, eg: https://peertube.cpy.re
118* `PEERTUBE_USER` : your PeerTube account where videos will be uploaded
e8a739e8 119* `PEERTUBE_PASSWORD` : password of your PeerTube account (if `--password PEERTUBE_PASSWORD` is omitted, you will be prompted for it)
a5f0521f
RK
120* `TARGET_URL` : the target url you want to import. Examples:
121 * YouTube:
122 * Channel: https://www.youtube.com/channel/ChannelId
123 * User https://www.youtube.com/c/UserName or https://www.youtube.com/user/UserName
124 * Video https://www.youtube.com/watch?v=blabla
125 * Vimeo: https://vimeo.com/xxxxxx
126 * Dailymotion: https://www.dailymotion.com/xxxxx
2519d9fe 127
2186386c
C
128The script will get all public videos from Youtube, download them and upload to PeerTube.
129Already downloaded videos will not be uploaded twice, so you can run and re-run the script in case of crash, disconnection...
130
131Videos will be publicly available after transcoding (you can see them before that in your account on the web interface).
132
1f8ac024
F
133**NB**: If you want to synchronize a Youtube channel to your PeerTube instance (ensure you have the agreement from the author),
134you can add a [crontab rule](https://help.ubuntu.com/community/CronHowto) (or an equivalent of your OS) and insert
135these rules (ensure to customize them to your needs):
136
137```
138# Update youtube-dl every day at midnight
1390 0 * * * /usr/bin/npm rebuild youtube-dl --prefix /PATH/TO/PEERTUBE/
140
141# Synchronize the YT channel every sunday at 22:00 all the videos published since last monday included
927d14bd 1420 22 * * 0 /usr/bin/node /PATH/TO/PEERTUBE/dist/server/tools/peertube-import-videos.js -u '__PEERTUBE_URL__' -U '__USER__' --password '__PASSWORD__' --target-url 'https://www.youtube.com/channel/___CHANNEL__' --since $(date --date="-6 days" +\%Y-\%m-\%d)
1f8ac024
F
143```
144
145Also you may want to subscribe to the PeerTube channel in order to manually check the synchronization is successful.
358770db 146
d639c3bf 147#### peertube-upload.js
358770db
C
148
149You can use this script to import videos directly from the CLI.
150
2186386c
C
151Videos will be publicly available after transcoding (you can see them before that in your account on the web interface).
152
c83af8f9 153```bash
00ee545c
C
154cd ${CLONE}
155node dist/server/tools/peertube-upload.js --help
358770db 156```
a5f0521f 157
8dd2d050
C
158#### peertube-plugins.js
159
160Install/update/uninstall or list local or NPM PeerTube plugins:
161
c83af8f9 162```bash
00ee545c
C
163cd ${CLONE}
164node dist/server/tools/peertube-plugins.js --help
165node dist/server/tools/peertube-plugins.js list --help
166node dist/server/tools/peertube-plugins.js install --help
167node dist/server/tools/peertube-plugins.js update --help
168node dist/server/tools/peertube-plugins.js uninstall --help
169
170node dist/server/tools/peertube-plugins.js install --path /my/plugin/path
171node dist/server/tools/peertube-plugins.js install --npm-name peertube-theme-example
8dd2d050
C
172```
173
e669ff58
C
174#### peertube-redundancy.js
175
176Manage (list/add/remove) video redundancies:
177
178To list your videos that are duplicated by remote instances:
179
c83af8f9 180```bash
00ee545c 181node dist/server/tools/peertube.js redundancy list-remote-redundancies
e669ff58
C
182```
183
184To list remote videos that your instance duplicated:
185
c83af8f9 186```bash
00ee545c 187node dist/server/tools/peertube.js redundancy list-my-redundancies
e669ff58
C
188```
189
190To duplicate a specific video in your redundancy system:
191
c83af8f9 192```bash
00ee545c 193node dist/server/tools/peertube.js redundancy add --video 823
e669ff58
C
194```
195
196To remove a video redundancy:
197
c83af8f9 198```bash
00ee545c 199node dist/server/tools/peertube.js redundancy remove --video 823
e669ff58
C
200```
201
54a3a12e
C
202## Server tools
203
204These scripts should be run on the server, in `peertube-latest` directory.
a5f0521f 205
0ee02734
C
206### parse-log
207
208To parse PeerTube last log file:
209
c83af8f9 210```bash
00ee545c
C
211# Basic installation
212cd /var/www/peertube/peertube-latest
213sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run parse-log -- --level info
cb6a78c2 214
00ee545c
C
215# Docker installation
216cd /var/www/peertube-docker
217docker-compose exec -u peertube peertube npm run parse-log -- --level info
0ee02734
C
218```
219
220`--level` is optional and could be `info`/`warn`/`error`
221
cb6a78c2 222You can also remove SQL or HTTP logs using `--not-tags` (PeerTube >= 3.2):
7992c9e1 223
cb6a78c2 224```bash
00ee545c
C
225# Basic installation
226cd /var/www/peertube/peertube-latest
227sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run parse-log -- --level debug --not-tags http sql
cb6a78c2 228
00ee545c
C
229# Docker installation
230cd /var/www/peertube-docker
231docker-compose exec -u peertube peertube npm run parse-log -- --level debug --not-tags http sql
7992c9e1
C
232```
233
c2bd7a6f
C
234### regenerate-thumbnails.js
235
cb6a78c2
C
236**PeerTube >= 3.2**
237
c2bd7a6f
C
238Regenerating local video thumbnails could be useful because new PeerTube releases may increase thumbnail sizes:
239
cb6a78c2 240```bash
00ee545c
C
241# Basic installation
242cd /var/www/peertube/peertube-latest
243sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run regenerate-thumbnails
cb6a78c2 244
00ee545c
C
245# Docker installation
246cd /var/www/peertube-docker
247docker-compose exec -u peertube peertube npm run regenerate-thumbnails
c2bd7a6f
C
248```
249
a5f0521f
RK
250### create-import-video-file-job.js
251
221ee1ad 252You can use this script to import a video file to replace an already uploaded file or to add a new webtorrent resolution to a video. PeerTube needs to be running.
b708c9e4 253You can then create a transcoding job using the web interface if you need to optimize your file or create an HLS version of it.
a5f0521f 254
c83af8f9 255```bash
00ee545c
C
256# Basic installation
257cd /var/www/peertube/peertube-latest
258sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile]
cb6a78c2 259
00ee545c
C
260# Docker installation
261cd /var/www/peertube-docker
262docker-compose exec -u peertube peertube npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile]
54a3a12e
C
263```
264
e1ab52d7 265### create-move-video-storage-job.js
266
9c391612
C
267**PeerTube >= 4.0**
268
e1ab52d7 269Use this script to move all video files or a specific video file to object storage.
270
271```bash
00ee545c
C
272# Basic installation
273cd /var/www/peertube/peertube-latest
274sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-move-video-storage-job -- --to-object-storage -v [videoUUID]
e1ab52d7 275
00ee545c
C
276# Docker installation
277cd /var/www/peertube-docker
278docker-compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage -v [videoUUID]
e1ab52d7 279```
280
281The script can also move all video files that are not already in object storage:
282
283```bash
00ee545c
C
284# Basic installation
285cd /var/www/peertube/peertube-latest
286sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-move-video-storage-job -- --to-object-storage --all-videos
e1ab52d7 287
00ee545c
C
288# Docker installation
289cd /var/www/peertube-docker
290docker-compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage --all-videos
e1ab52d7 291```
292
293
54a3a12e
C
294### prune-storage.js
295
296Some transcoded videos or shutdown at a bad time can leave some unused files on your storage.
7089e7b4 297Stop PeerTube and delete these files (a confirmation will be demanded first):
54a3a12e 298
c83af8f9 299```bash
00ee545c
C
300cd /var/www/peertube/peertube-latest
301sudo systemctl stop peertube && sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run prune-storage
23687332
C
302```
303
edb4ffc7 304
23687332
C
305### update-host.js
306
fffc7c08 307**Changing the hostname is unsupported and may be a risky operation, especially if you have already federated.**
12b119c0
RK
308If you started PeerTube with a domain, and then changed it you will have
309invalid torrent files and invalid URLs in your database. To fix this, you have
fffc7c08 310to run the command below (keep in mind your follower instances will NOT update their URLs).
23687332 311
c83af8f9 312```bash
00ee545c
C
313# Basic installation
314cd /var/www/peertube/peertube-latest
315sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run update-host
cb6a78c2 316
00ee545c
C
317# Docker installation
318cd /var/www/peertube-docker
319docker-compose exec -u peertube peertube npm run update-host
ecf06378 320```
1e59ca3b 321
31b48aad
C
322### reset-password.js
323
324To reset a user password from CLI, run:
325
c83af8f9 326```bash
00ee545c
C
327# Basic installation
328cd /var/www/peertube/peertube-latest
329sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run reset-password -- -u target_username
cb6a78c2 330
00ee545c
C
331# Docker installation
332cd /var/www/peertube-docker
333docker-compose exec -u peertube peertube npm run reset-password -- -u target_username
31b48aad
C
334```
335
9b474844
C
336
337### plugin install/uninstall
338
339The difference with `peertube plugins` CLI is that these scripts can be used even if PeerTube is not running.
340If PeerTube is running, you need to restart it for the changes to take effect (whereas with `peertube plugins` CLI, plugins/themes are dynamically loaded on the server).
341
8dd2d050 342To install/update a plugin or a theme from the disk:
9b474844 343
c83af8f9 344```bash
00ee545c
C
345cd /var/www/peertube/peertube-latest
346sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:install -- --plugin-path /local/plugin/path
cb6a78c2 347
00ee545c
C
348# Docker installation
349cd /var/www/peertube-docker
350docker-compose exec -u peertube peertube npm run plugin:install -- --plugin-path /local/plugin/path
9b474844
C
351```
352
353From NPM:
354
c83af8f9 355```bash
00ee545c
C
356cd /var/www/peertube/peertube-latest
357sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:install -- --npm-name peertube-plugin-myplugin
cb6a78c2 358
00ee545c
C
359# Docker installation
360cd /var/www/peertube-docker
361docker-compose exec -u peertube peertube npm run plugin:install -- --npm-name peertube-plugin-myplugin
9b474844
C
362```
363
364To uninstall a plugin or a theme:
365
c83af8f9 366```bash
00ee545c
C
367cd /var/www/peertube/peertube-latest
368sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin
cb6a78c2 369
00ee545c
C
370# Docker installation
371cd /var/www/peertube-docker
372docker-compose exec -u peertube peertube npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin
9b474844 373```