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