はじまりの大地

このコミットが含まれているのは:
2024-07-15 09:14:04 +09:00
コミット 6632905f32
3501個のファイルの変更1439465行の追加0行の削除
+330
ファイルの表示
@@ -0,0 +1,330 @@
# PeerTube Embed API
PeerTube lets you embed videos and programmatically control their playback. This documentation covers how to interact with the PeerTube Embed API.
## Playground
Any PeerTube embed URL (ie `https://my-instance.example.com/videos/embed/52a10666-3a18-4e73-93da-e8d3c12c305a`) can be viewed as an embedding playground which
allows you to test various aspects of PeerTube embeds. Simply replace `/embed` with `/test-embed` and visit the URL in a browser.
For instance, the playground URL for the above embed URL is `https://my-instance.example.com/videos/test-embed/52a10666-3a18-4e73-93da-e8d3c12c305a`.
## Quick Start
Given an existing PeerTube embed `<iframe>` **with API enabled** (`https://my-instance.example.com/videos/embed/52a10666-3a18-4e73-93da-e8d3c12c305a?api=1`),
one can use the PeerTube Embed API to control it by first including the library. You can include it via Yarn with:
```
yarn add @peertube/embed-api
```
Now just use the `PeerTubePlayer` class exported by the module:
```typescript
import { PeerTubePlayer } from '@peertube/embed-api.js'
...
```
Or use the minified build from NPM CDN in your HTML file:
```
<script src="https://unpkg.com/@peertube/embed-api/build/player.min.js"></script>
<script>
const PeerTubePlayer = window['PeerTubePlayer']
...
</script>
```
Then you can instantiate the player:
```typescript
let player = new PeerTubePlayer(document.querySelector('iframe'))
await player.ready // wait for the player to be ready
// now you can use it!
player.play()
player.seek(32)
player.pause()
```
## Embed URL parameters
You can customize PeerTube player by specifying URL query parameters.
For example `https://my-instance.example.com/videos/embed/52a10666-3a18-4e73-93da-e8d3c12c305a?start=1s&stop=18s&loop=1&autoplay=1&muted=1&warningTitle=0&controlBar=0&peertubeLink=0&p2p=0`
### start
Start the video at a specific time.
Value must be raw seconds or a duration (`3m4s`)
Default: starts at `0`
### stop
Stop the video at a specific time.
Value must be raw seconds or a duration (`54s`)
Default: ends at content end
### controls
Mimics video HTML element `controls` attribute, meaning that all controls (including big play button, control bar, etc.) will be removed.
It can be useful if you want to have a full control of the PeerTube player.
Value must be `0` or `1`.
Default: `1`
### controlBar
Hide control bar when the video is played.
Value must be `0` or `1`.
Default: `1`
### peertubeLink
Hide PeerTube instance link in control bar.
Value must be `0` or `1`.
Default: `1`
### muted
Mute the video by default.
Value must be `0` or `1`.
Default: tries to restore the last muted setting set by the user
### loop
Automatically start again the video when it ends.
Value must be `0` or `1`.
Default: `0`
### subtitle
Auto select a subtitle by default.
Value must be a valid subtitle ISO code (`fr`, `en`, etc.).
Default: no subtitle selected and then tries to restore the last subtitle set by the user
### autoplay
Try to automatically play the video.
Most web browsers disable video autoplay if the user did not interact with the video. You can try to bypass this limitation by muting the video
Value must be `0` or `1`.
Default: `0`
### playbackRate
Force the default playback rate (`0.75`, `1.5` etc).
Default: `1`
### title
Show/Hide embed title.
Value must be `0` or `1`.
Default: `1`
### warningTitle
Show/Hide P2P warning title.
Value must be `0` or `1`.
Default: `1`
### p2p
Enable/Disable P2P.
Value must be `0` or `1`.
Default: tries to use the user setting and fallbacks to instance setting if user setting is not found
### bigPlayBackgroundColor
Customize big play button background color.
Value must be a valid color (`red` or `rgba(100, 100, 100, 0.5)`).
Default: rgba(0, 0, 0, 0.8)
### foregroundColor
Customize embed font color.
Value must be a valid color (`red` or `rgba(100, 100, 100, 0.5)`).
Default: `white`
### mode
Force a specific player engine.
Value must be a valid mode (`web-video` or `p2p-media-loader`).
See behaviour description [here](https://docs.joinpeertube.org/admin/configuration#vod-transcoding)
Default: `p2p-media-loader` and fallback to `web-video` mode.
### api
Enable/Disable embed JavaScript API (see methods below).
Value must be `0` or `1`.
Default: `0`
### waitPasswordFromEmbedAPI
**PeerTube >= 6.0**
If the video requires a password, PeerTube will wait a password provided by `setVideoPassword` method before loading the video.
Until you provide a password, `player.ready` is not resolved.
Value must be `0` or `1`.
Default: `0`
## Embed attributes
### `ready: Promise<void>`
This promise is resolved when the video is loaded an the player is ready.
## Embed methods
### `play() : Promise<void>`
Starts playback, or resumes playback if it is paused.
### `pause() : Promise<void>`
Pauses playback.
### `seek(positionInSeconds : number)`
Seek to the given position, as specified in seconds into the video.
### `addEventListener(eventName : string, handler : Function)`
Add a listener for a specific event. See below for the available events.
### `removeEventListener(eventName : string, handler : Function)`
Remove a listener.
### `getResolutions() : Promise<PeerTubeResolution[]>`
Get the available resolutions. A `PeerTubeResolution` looks like:
```json
{
"id": 3,
"label": "720p",
"height": "720",
"active": true
}
```
`active` is true if the resolution is the currently selected resolution.
### `setResolution(resolutionId : number): Promise<void>`
Change the current resolution. Pass `-1` for automatic resolution (when available).
Otherwise, `resolutionId` should be the ID of an object returned by `getResolutions()`
### `getPlaybackRates() : Promise<number[]>`
Get the available playback rates, where `1` represents normal speed, `0.5` is half speed, `2` is double speed, etc.
### `getPlaybackRate() : Promise<number>`
Get the current playback rate. See `getPlaybackRates()` for more information.
### `setPlaybackRate(rate: number) : Promise<void>`
Set the current playback rate. The passed rate should be a value as returned by `getPlaybackRates()`.
### `setVolume(factor: number) : Promise<void>`
Set the playback volume. Value should be between `0` and `1`.
### `getVolume(): Promise<number>`
Get the playback volume. Returns a value between `0` and `1`.
### `setCaption(id: string) : Promise<void>`
Update current caption using the caption id.
### `getCaptions(): Promise<{ id: string, label: string, src: string, mode: 'disabled' | 'showing' }>`
Get video captions.
### `playNextVideo(): Promise<void>`
Play next video in playlist.
### `playPreviousVideo(): Promise<void>`
Play previous video in playlist.
### `getCurrentPosition(): Promise<void>`
Get current position in playlist (starts from 1).
### `setVideoPassword(): Promise<void>`
**PeerTube >= 6.0**
Set the video password so the user doesn't have to manually fill it.
`waitPasswordFromEmbedAPI=1` is required in embed URL.
### `getImageDataUrl(): Promise<string>`
**PeerTube >= 6.2**
Get the current frame as JPEG image data URL.
## Embed events
You can subscribe to events by using `addEventListener()`. See above for details.
### Event `playbackStatusUpdate`
Fired every half second to provide the current status of playback.
The parameter of the callback will resemble:
```json
{
"position": 22.3,
"volume": 0.9,
"duration": "171.37499",
"playbackState": "playing"
}
```
`duration` field and `ended` `playbackState` are available in PeerTube >= 2.2.
The `volume` field contains the volume from `0` (silent) to `1` (full volume).
The `playbackState` can be `unstarted`, `playing`, `paused` or `ended`. More states may be added later.
### Event `playbackStatusChange`
Fired when playback transitions between states, such as `paused` and `playing`. More states may be added later.
### Event `resolutionUpdate`
Fired when the available resolutions have changed, or when the currently selected resolution has changed. Listener should call `getResolutions()` to get the updated information.
### Event `volumeChange`
Fired when the player volume changed.
ファイル差分が大きすぎるため省略します 差分を読込み
+72
ファイルの表示
@@ -0,0 +1,72 @@
# REST API quick start
## Detect a PeerTube instance
There are several ways to know if a website uses the PeerTube software:
* The server exposes NodeInfo information: https://peertube2.cpy.re/nodeinfo/2.0.json
* The server sends a `x-powered-by: PeerTube` header response to API requests
* HTML pages include a `<meta property="og:platform" content="PeerTube">` tag
## Authentication
### Get client
Some endpoints need authentication. We use OAuth 2.0 so first fetch the client tokens:
```bash
curl https://peertube.example.com/api/v1/oauth-clients/local
```
Response example:
```json
{
"client_id": "v1ikx5hnfop4mdpnci8nsqh93c45rldf",
"client_secret": "AjWiOapPltI6EnsWQwlFarRtLh4u8tDt"
}
```
### Get user token
Now you can fetch the user token:
```bash
curl -X POST \
-d "client_id=v1ikx5hnfop4mdpnci8nsqh93c45rldf&client_secret=AjWiOapPltI6EnsWQwlFarRtLh4u8tDt&grant_type=password&response_type=code&username=your_user&password=your_password" \
https://peertube.example.com/api/v1/users/token
```
Response example:
```json
{
"access_token": "90286a0bdf0f7315d9d3fe8dabf9e1d2be9c97d0",
"token_type": "Bearer",
"expires_in": 14399,
"refresh_token": "2e0d675df9fc96d2e4ec8a3ebbbf45eca9137bb7"
}
```
Just use the `access_token` in the `Authorization` header:
```bash
curl -H 'Authorization: Bearer 90286a0bdf0f7315d9d3fe8dabf9e1d2be9c97d0' https://peertube.example.com/api/v1/jobs/completed
```
## List videos
```bash
curl https://peertube.example.com/api/v1/videos
```
## Libraries
[Convenience libraries](https://framagit.org/framasoft/peertube/clients) are generated automatically from the [OpenAPI specification](https://github.com/Chocobozzz/PeerTube/blob/develop/support/doc/api/openapi.yaml) for the following languages:
- [python](https://framagit.org/framasoft/peertube/clients/python)
- [go](https://framagit.org/framasoft/peertube/clients/go)
- [kotlin](https://framagit.org/framasoft/peertube/clients/kotlin)
Other [languages supported by the OpenAPI generator](https://openapi-generator.tech/docs/generators/#client-generators) can be added to the generation, provided they make a common enough use case.
+607
ファイルの表示
@@ -0,0 +1,607 @@
# Dependencies
:warning: **Warning**: dependencies guide is maintained by the community. Some parts may be outdated! :warning:
Main dependencies supported by PeerTube:
* `node` >=18.x
* `yarn` 1.x (**must not be >=2.x**)
* `postgres` >=10.x
* `redis-server` >=6.x
* `ffmpeg` >=4.3 (using a ffmpeg static build [is not recommended](https://github.com/Chocobozzz/PeerTube/issues/6308))
* `python` >=3.x
* `pip`
_note_: only **LTS** versions of external dependencies are supported. If no LTS version matching the version constraint is available, only **release** versions are supported.
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- [Debian / Ubuntu and derivatives](#debian-ubuntu-and-derivatives)
- [Arch Linux](#arch-linux)
- [CentOS 7](#centos-7)
- [Centos 8](#centos-8)
- [Rocky Linux 8.4](#rocky-linux-84)
- [Fedora](#fedora)
- [Red Hat Enterprise Linux 8](#red-hat-enterprise-linux-8)
- [FreeBSD](#freebsd)
- [macOS](#macos)
- [Gentoo](#gentoo)
- [OpenBSD](#openbsd)
- [Other distributions](#other-distributions)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## Debian / Ubuntu and derivatives
1. On a fresh Debian/Ubuntu, as root user, install basic utility programs needed for the installation
```
# apt-get install curl sudo unzip vim
```
2. It would be wise to disable root access and to continue this tutorial with a user with sudoers group access. You can see a guide for how to do this in Debian/Ubuntu [here](https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-ubuntu-20-04).
3. Install NodeJS 18.x:
[https://nodejs.org/en/download/package-manager/all#debian-and-ubuntu-based-linux-distributions](https://nodejs.org/en/download/package-manager/all#debian-and-ubuntu-based-linux-distributions)
4. Install yarn, and be sure to have [a recent version](https://github.com/yarnpkg/yarn/releases/latest):
[https://yarnpkg.com/en/docs/install#linux-tab](https://yarnpkg.com/en/docs/install#linux-tab)
5. Install Python:
On Ubuntu >= focal (20.04 LTS) or Debian >= Bullseye:
```
sudo apt update
sudo apt install python3-dev python3-pip python-is-python3
python --version # Should be >= 3.x
```
6. Install common dependencies:
```
sudo apt update
sudo apt install certbot nginx ffmpeg postgresql postgresql-contrib openssl g++ make redis-server git cron wget
ffmpeg -version # Should be >= 4.1
g++ -v # Should be >= 5.x
redis-server --version # Should be >= 6.x
```
Now that dependencies are installed, before running PeerTube you should start PostgreSQL and Redis:
```
sudo systemctl start redis postgresql
```
## Arch Linux
1. Run:
```
sudo pacman -S nodejs-lts-fermium yarn ffmpeg postgresql openssl redis git wget unzip python python-pip base-devel npm nginx
```
Now that dependencies are installed, before running PeerTube you should start PostgreSQL and Redis:
```
sudo systemctl start redis postgresql
```
## CentOS 7
1. Install NodeJS 18.x:
[https://nodejs.org/en/download/package-manager/all#centos-fedora-and-red-hat-enterprise-linux](https://nodejs.org/en/download/package-manager/all#centos-fedora-and-red-hat-enterprise-linux)
2. Install yarn:
[https://yarnpkg.com/en/docs/install](https://yarnpkg.com/en/docs/install)
3. Install or compile ffmpeg:
* Install - [https://linoxide.com/linux-how-to/install-ffmpeg-centos-7/](https://linoxide.com/linux-how-to/install-ffmpeg-centos-7/)
* Compile - [https://gist.github.com/mustafaturan/7053900#file-latest-ffmpeg-centos6-sh](https://gist.github.com/mustafaturan/7053900#file-latest-ffmpeg-centos6-sh)
4. Install Packages:
```
sudo yum update
sudo yum install epel-release centos-release-scl
sudo yum update
sudo yum install nginx postgresql postgresql-server postgresql-contrib openssl gcc-c++ make wget redis git devtoolset-7
```
5. You need to use a more up to date version of G++ in order to run the yarn install command, hence the installation of devtoolset-7.
```
sudo scl enable devtoolset-7 bash
```
Later when you invoke any node command, please prefix them with `CC=/opt/rh/devtoolset-7/root/usr/bin/gcc CXX=/opt/rh/devtoolset-7/root/usr/bin/g++`, such as with:
```
sudo -H -u peertube CC=/opt/rh/devtoolset-7/root/usr/bin/gcc CXX=/opt/rh/devtoolset-7/root/usr/bin/g++ yarn install --production --pure-lockfile
```
6. Initialize the PostgreSQL database:
```
sudo PGSETUP_INITDB_OPTIONS='--auth-host=md5' postgresql-setup --initdb --unit postgresql
```
Now that dependencies are installed, before running PeerTube you should enable and start PostgreSQL and Redis:
```
sudo systemctl enable --now redis
sudo systemctl enable --now postgresql
```
## Centos 8
1. Install NodeJS 18.x:
[https://nodejs.org/en/download/package-manager/all#centos-fedora-and-red-hat-enterprise-linux](https://nodejs.org/en/download/package-manager/all#centos-fedora-and-red-hat-enterprise-linux)
2. Install yarn:
[https://yarnpkg.com/en/docs/install](https://yarnpkg.com/en/docs/install)
3. Install or compile ffmpeg:
```
sudo dnf install epel-release dnf-utils
sudo yum-config-manager --set-enabled powertools
sudo yum-config-manager --add-repo=https://negativo17.org/repos/epel-multimedia.repo
sudo dnf install ffmpeg
```
4. Install packages:
```
sudo dnf update
sudo dnf install epel-release
sudo dnf update
sudo dnf install nginx postgresql postgresql-server postgresql-contrib openssl gcc-c++ make wget redis git unzip
```
5. You'll need a symlink for python3 to python for youtube-dl to work
```
sudo ln -s /usr/bin/python3 /usr/bin/python
```
6. Initialize the PostgreSQL database:
```
sudo PGSETUP_INITDB_OPTIONS='--auth-host=md5' postgresql-setup --initdb --unit postgresql
```
Now that dependencies are installed, before running PeerTube you should enable and start PostgreSQL and Redis:
```
sudo systemctl enable --now redis
sudo systemctl enable --now postgresql
```
## Rocky Linux 8.4
1. Pull the latest updates:
```
sudo dnf update -y
```
2. Install NodeJS 18.x:
```
sudo dnf module install -y nodejs:18
```
3. Install yarn:
```
sudo npm install --global yarn
```
4. Install or compile ffmpeg (if you want to compile... enjoy):
```
sudo dnf install -y epel-release
sudo dnf --enablerepo=powertools install -y SDL2 SDL2-devel
sudo dnf install -y --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm
sudo dnf install -y ffmpeg
sudo dnf update -y
```
5. Install PostgreSQL and Python3 and other stuff:
```
sudo dnf install -y nginx postgresql postgresql-server postgresql-contrib openssl gcc-c++ make wget redis git python3 python3-pip
sudo ln -s /usr/bin/python3 /usr/bin/python
sudo PGSETUP_INITDB_OPTIONS='--auth-host=md5' postgresql-setup --initdb --unit postgresql
sudo systemctl enable --now redis
sudo systemctl enable --now postgresql
```
6. Configure the peertube user:
```
sudo useradd -m -d /var/www/peertube -s /bin/bash -p peertube peertube
```
7. Unknown missing steps:
- Steps missing here... these were adapted from the CentOS 8 steps which abruptly ended.
- /var/www/peertube does not exist yet (expected? done in future steps? documentation?).
- Nothing about Certbot, NGINX, Firewall settings, and etc.
- Hopefully someone can suggest what is missing here with some hints so I can add it?
## Fedora
1. Upgrade your packages:
```
dnf upgrade
```
2. Add a user with sudoers group access:
```
useradd my-peertube-user
passwd my-peertube-user
usermod my-peertube-user -a -G wheel # Add my-peertube-user to sudoers
su my-peertube-user
```
3. (Optional) Install certbot (choose instructions for your distribution):
[https://certbot.eff.org/all-instructions](https://certbot.eff.org/all-instructions)
4. Install NodeJS 18.x:
[https://nodejs.org/en/download/package-manager/all#centos-fedora-and-red-hat-enterprise-linux](https://nodejs.org/en/download/package-manager/all#centos-fedora-and-red-hat-enterprise-linux)
5. Install yarn:
[https://yarnpkg.com/en/docs/install](https://yarnpkg.com/en/docs/install)
6. Enable [RPM Fusion](https://rpmfusion.org) for Fedora (available for x86, x86_64, armhfp)
```
sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
```
This is necessary because `ffmpeg` is not in the Fedora repos.
7. Run:
```
sudo dnf install nginx ffmpeg postgresql-server postgresql-contrib openssl gcc-c++ make redis git vim
ffmpeg -version # Should be >= 4.1
g++ -v # Should be >= 5.x
redis-server --version # Should be >= 6.x
```
8. Configure nginx
```
sudo mkdir /etc/nginx/sites-available
sudo mkdir /etc/nginx/sites-enabled
sudo ln -s /etc/nginx/sites-enabled/peertube /etc/nginx/conf.d/peertube.conf
```
9. Post-installation
_from [PostgreSQL documentation](https://www.postgresql.org/download/linux/redhat/):_
> Due to policies for Red Hat family distributions, the PostgreSQL installation will not be enabled for automatic start or have the database initialized automatically.
```
# PostgreSQL
sudo PGSETUP_INITDB_OPTIONS='--auth-host=md5' postgresql-setup --initdb --unit postgresql
sudo systemctl enable postgresql.service
sudo systemctl start postgresql.service
# Nginx
sudo systemctl enable nginx.service
sudo systemctl start nginx.service
# Redis
sudo systemctl enable redis.service
sudo systemctl start redis.service
```
10. Firewall
By default, you cannot access your server via public IP. To do so, you must configure firewall:
- Ports used by peertube dev setup:
```
sudo firewall-cmd --permanent --zone=public --add-port=3000/tcp
sudo firewall-cmd --permanent --zone=public --add-port=9000/tcp
```
- Optional
```
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
```
- Reload firewall
```
sudo firewall-cmd --reload
```
11. Configure max ports
This is necessary if you are running dev setup, otherwise you will have errors with `nodemon`
```
echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
```
[More info](https://stackoverflow.com/questions/34662574/node-js-getting-error-nodemon-internal-watch-failed-watch-enospc#34664097)
## Red Hat Enterprise Linux 8
1. Register system as root user to Red Hat Subscription Management (create a free Red Hat account if you don't have one yet).
```
# subscription-manager register --username <username> --password <password> --auto-attach
# dnf upgrade
# reboot
```
2. Install Node.JS
```
sudo dnf module install nodejs:18
```
3. Install Yarn
```
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo dnf install yarn
```
4. Install FFmpeg
```
sudo subscription-manager repos --enable "codeready-builder-for-rhel-8-$(arch)-rpms"
sudo dnf install --nogpgcheck https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf install --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm
sudo dnf upgrade
sudo dnf install ffmpeg
```
5. Run:
```
sudo dnf install nginx postgresql postgresql-server postgresql-contrib openssl gcc-c++ make wget redis git
```
6. You'll need a symlink for python3 to python for youtube-dl to work
```
sudo alternatives --set python3 /usr/bin/python
```
7. Initialize the PostgreSQL database:
```
sudo PGSETUP_INITDB_OPTIONS='--auth-host=md5' postgresql-setup --initdb --unit postgresql
```
Now that dependencies are installed, before running PeerTube you should enable and start PostgreSQL and Redis:
```
sudo systemctl enable --now redis
sudo systemctl enable --now postgresql
```
If you are running the production guide, you also need to slightly pre-configure nginx, because nginx is packaged differently in the Red Hat family distributions:
8. Configure nginx
```
sudo mkdir /etc/nginx/sites-available
sudo mkdir /etc/nginx/sites-enabled
sudo ln -s /etc/nginx/sites-enabled/peertube /etc/nginx/conf.d/peertube.conf
sudo systemctl enable --now nginx
```
9. Prepare directory
To add the 'peertube' user, you first have to create the 'www' folder and once the 'peertube' user is added, you have to set the access permissions.
```
sudo mkdir /var/www
sudo useradd -m -d /var/www/peertube -s /bin/bash -p peertube peertube
sudo passwd peertube
sudo chmod 755 /var/www/peertube/
```
10. Firewall
By default, you cannot access your server via public IP. To do so, you must configure firewall:
- Ports used by peertube dev setup:
```
sudo firewall-cmd --permanent --zone=public --add-port=3000/tcp
sudo firewall-cmd --permanent --zone=public --add-port=9000/tcp
```
- Optional
```
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
```
- Reload firewall
```
sudo firewall-cmd --reload
```
11. Configure max ports
This is necessary if you are running dev setup, otherwise you will have errors with `nodemon`
```
echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
```
[More info](https://stackoverflow.com/questions/34662574/node-js-getting-error-nodemon-internal-watch-failed-watch-enospc#34664097)
## FreeBSD
On a fresh install of [FreeBSD](https://www.freebsd.org), new system or new jail:
1. bootstrap pkg, initialize db and install peertube's dependencies, always as root (sudo not yet installed):
```
pkg
pkg update
pkg install -y sudo bash wget git python nginx pkgconf postgresql13-server postgresql13-contrib redis openssl node npm yarn ffmpeg unzip
```
2. Allow users in the wheel group (hope you don't forgot to add your user on wheel group!) to use sudo.
```
# visudo
```
Uncomment the line 90
```
%wheel ALL=(ALL) ALL
```
3. Enable nginx, redis, postgresql services and initialize database.
```
sysrc postgresql_enable="YES"
sysrc redis_enable="YES"
sysrc nginx_enable="YES"
```
Initialize database and start services
```
service postgresql initdb
service postgresql start
service redis start
service nginx start
```
## macOS
1. Add the packages:
```sh
brew install bash ffmpeg nginx postgresql openssl gcc make redis git yarn
```
You may need to update your default version of bash.
**How to change your default shell**
```sh
which -a bash # Check where bash is installed
bash --version # You need a version at least as recent as 4.0
sudo vim /etc/shells # Add in this file : /usr/local/bin/bash
chsh -s /usr/local/bin/bash # To set the brew-installed bash as default bash
```
In a new shell, type `bash --version` to assert your changes took effect and
correctly modified your default bash version.
2. Run the services:
```sh
brew services run postgresql
brew services run redis
```
On macOS, the `postgresql` user can be `_postgres` instead of `postgres`.
If `sudo -u postgres createuser -P peertube` gives you an `unknown user: postgres` error, you can try `sudo -u _postgres createuser -U peertube`.
## Gentoo
1. Add this to ``/etc/portage/sets/peertube``:
```
net-libs/nodejs
sys-apps/yarn
media-video/ffmpeg[x264] # Optionally add vorbis,vpx
dev-db/postgresql
dev-db/redis
dev-vcs/git
app-arch/unzip
dev-lang/python
dev-lang/python-exec
www-servers/nginx
# Optional, client for Lets Encrypt:
# app-crypt/certbot
```
2. If you are on a "stable" Gentoo you need to accept the testing keyword ~amd64 yarn:
```
mkdir -p /etc/portage/package.keywords
cat << EOF >> /etc/portage/package.keywords/peertube
# required by yarn (argument) for PeerTube
sys-apps/yarn ~amd64
EOF
```
3. Compile the peertube set:
```
emerge -a @peertube
```
4. Initialize the PostgreSQL database if you just merged it:
```
emerge --config postgresql
```
5. (For OpenRC) Enable and then start the services (replace with the correct PostgreSQL slot):
```
rc-update add redis
rc-update add postgresql-11
rc-service redis start
rc-service postgresql-11 start
```
6. Create Python version symlink for youtube-dl:
```
emerge -1 python-exec
```
## OpenBSD
1. Install Packages:
```
pkg_add sudo bash wget git python nginx pkgconf postgresql-server postgresql-contrib redis openssl
```
2. Install yarn:
```
npm install --global yarn
```
3. Allow users in the wheel group to use sudo
```
visudo
```
Uncomment line #43:
```
%wheel ALL=(ALL) ALL
```
4. Enable services:
```
rcctl enable postgresql redis nginx
```
## Other distributions
Feel free to update this file in a pull request!
+40
ファイルの表示
@@ -0,0 +1,40 @@
# Continuous integration
PeerTube uses Github Actions as a CI platform.
CI tasks are described in `.github/workflows`.
## benchmark.yml
*Scheduled*
Run various benchmarks (build, API etc) and upload results on https://builds.joinpeertube.org/peertube-stats/ to be publicly consumed.
## codeql.yml
*Scheduled, on push on develop and on pull request*
Run CodeQL task to throw code security issues in Github. https://lgtm.com/projects/g/Chocobozzz/PeerTube can also be used.
## docker.yml
*Scheduled and on push on master*
Build `chocobozzz/peertube-webserver:latest`, `chocobozzz/peertube:production-...`, `chocobozzz/peertube:v-...` (only latest PeerTube tag) and `chocobozzz/peertube:develop-...` Docker images. Scheduled to automatically upgrade image software (Debian security issues etc).
## nightly.yml
*Scheduled*
Build PeerTube nightly build (`develop` branch) and upload the release on https://builds.joinpeertube.org/nightly.
## stats.yml
*On push on develop*
Create various PeerTube stats (line of codes, build size, lighthouse report) and upload results on https://builds.joinpeertube.org/peertube-stats/ to be publicly consumed.
## test.yml
*Scheduled, on push and pull request*
Run PeerTube lint and tests.
+25
ファイルの表示
@@ -0,0 +1,25 @@
# Lib development documentation
## @peertube/embed-api
### Build & Publish
```
cd client/src/standalone/embed-player-api/
npm run build
npm publish --access=public
```
## @peertube/peertube-types
Typescript definition files generation is controlled by the various `tsconfig.types.json` files.
The complete types package is generated via:
```
npm run generate-types-package 4.x.x
cd packages/types-generator/dist
npm publish --access=public
```
> See [scripts/generate-types-package.ts](scripts/generate-types-package.ts) for details.
+35
ファイルの表示
@@ -0,0 +1,35 @@
# Application localization documentation
Source files are in `client/src/locale` and translated files merged from [Weblate](https://weblate.framasoft.org/translate/peertube).
## Generation
Will generate XLIFF base files for Angular (`angular.xlf`) and JSON files for the player (`player.en-US.json`) and the server (`server.en-US.json`).
Then, it will merge new translation keys into localized Angular files (`angular.fr-FR.xlf` etc).
```
npm run i18n:update
```
## Upload on Weblate
Nothing to do here, Github will automatically send a webhook to Weblate that will pull changes.
## Pull translation
* First, save translations on Weblate so it commits changes.
* Then, fetch these commits: `git fetch weblate && git merge weblate/develop`
## Support a new language
* Add it to [/packages/models/i18n/i18n.ts](/packages/core-utils/src/i18n/i18n.ts)
* Add it to [/scripts/build/client.sh](/scripts/build/client.sh)
* Add it to [/client/angular.json](/client/angular.json)
* Add it to [/scripts/i18n/update.sh](/scripts/i18n/update.sh)
* Lock [weblate project](https://weblate.framasoft.org/projects/peertube)
* Run `npm run i18n:update`
* Build the application and check the new language correctly works
+23
ファイルの表示
@@ -0,0 +1,23 @@
# Monitoring
## Client modules
To open a report of client build:
```
npm run build -- --analyze-bundle && npm run client-report
```
## API benchmark
To benchmark the REST API and save result in `benchmark.json`:
```
npm run benchmark-server -- -o benchmark.json
```
You can also grep on a specific test:
```
npm run benchmark-server -- --grep homepage
```
+39
ファイルの表示
@@ -0,0 +1,39 @@
# Release
## PeerTube
* Fix remaining important bugs
* Ensure French translation is 100% (for the screens in the JoinPeerTube blog post)
* Update [/CHANGELOG.md](/CHANGELOG.md)
* Check migrations:
```
npm run clean:server:test
git checkout master && rm -r ./node_modules && yarn install --pure-lockfile && npm run build:server
NODE_APP_INSTANCE=6 NODE_ENV=test node dist/server --benchmark-startup
git checkout develop && rm -r ./node_modules && yarn install --pure-lockfile && npm run build:server
NODE_APP_INSTANCE=6 NODE_ENV=test node dist/server --benchmark-startup
```
* Run `rm -rf node_modules && rm -rf client/node_modules && yarn install --pure-lockfile && npm run build` to see if all the supported languages compile correctly
* Update https://peertube2.cpy.re and check it works correctly
* Check CI tests are green
* Run BrowserStack **and** local E2E tests
* Release: `GITHUB_TOKEN=my_token npm run release -- 1.x.x`
* Update `openapi.yaml` version
* Upload `tar.xz` on https://builds.joinpeertube.org/release
* Create a dedicated branch: `git checkout -b release/1.x.x && git push origin release/1.x.x`
* Check the release is okay: https://github.com/Chocobozzz/PeerTube/releases
* Update https://peertube3.cpy.re and check it works correctly
* Update all other instances and check it works correctly
* After a couple of days, update https://joinpeertube.org/api/v1/versions.json
## @peertube/embed-api
At the root of PeerTube:
```
cd client/src/standalone/embed-player-api
npm version patch
cd ../../../../
npm run release-embed-api
```
+82
ファイルの表示
@@ -0,0 +1,82 @@
# Server code
## Database model typing
Sequelize models contain optional fields corresponding to table joins.
For example, `VideoModel` has a `VideoChannel?: VideoChannelModel` field. It can be filled if the SQL query joined with the `videoChannel` table or empty if not.
It can be difficult in TypeScript to understand if a function argument expects associations to be filled or not.
To improve clarity and reduce bugs, PeerTube defines multiple versions of a database model depending on its associations in `server/core/types/models/`.
These models start with `M` and by default do not include any association. `MVideo` for example corresponds to `VideoModel` without any association, where `VideoChannel` attribute doesn't exist. On the other hand, `MVideoWithChannel` is a `MVideo` that has a `VideoChannel` field. This way, a function that accepts `video: MVideoWithChannel` argument expects a video with channel populated. Main PeerTube code should never use `...Model` (`VideoModel`) database type, but always `M...` instead (`MVideo`, `MVideoChannel` etc).
## Add a new feature walkthrough
Here's a list of all the parts of the server to update if you want to add a new feature (new API REST endpoints for example) to the PeerTube server.
Some of these may be optional (for example your new endpoint may not need to send notifications) but this guide tries to be exhaustive.
* Configuration:
- Add you new configuration key in `config/default.yaml` and `config/production.yaml`
- If you configuration needs to be different in dev or tests environments, also update `config/dev.yaml` and `config/test.yaml`
- Load your configuration in `server/core/initializers/config.ts`
- Check new configuration keys are set in `server/core/initializers/checker-before-init.ts`
- You can also ensure configuration consistency in `server/core/initializers/checker-after-init.ts`
- If you want your configuration to be available in the client:
+ Add your field in `packages/models/src/server/core/server-config.model.ts`
+ Update `server/core/lib/server-config-manager.ts` to include your new configuration
- If you want your configuration to be updatable by the web admin in the client:
+ Add your field in `packages/models/src/server/core/custom-config.model.ts`
+ Add the configuration to the config object in the `server/core/controllers/api/config.ts` controller
* Controllers:
- Create the controller file and fill it with your REST API routes
- Import and use your controller in the parent controller
* Middlewares:
- Create your validator middleware in `server/core/middlewares/validators` that will be used by your controllers
- Add your new middleware file `server/core/middlewares/validators/index.ts` so it's easier to import
- Create the entry in `server/core/types/express.d.ts` to attach the database model loaded by your middleware to the express response
* Validators:
- Create your validators that will be used by your middlewares in `server/core/helpers/custom-validators`
* Typescript models:
- Create the API models (request parameters or response) in `packages/models`
- Add your models in `index.ts` of current directory to facilitate the imports
* Sequelize model (BDD):
- If you need to create a new table:
+ Create the Sequelize model in `server/core/models/`:
* Create the `@Column`
* Add some indexes if you need
* Create static methods to load a specific from the database `loadBy...`
* Create static methods to load a list of models from the database `listBy...`
* Create the instance method `toFormattedJSON` that creates the JSON to send to the REST API from the model
+ Add your new Sequelize model to `server/core/initializers/database.ts`
+ Create a new file in `server/core/types` to define multiple versions of your Sequelize model depending on database associations
+ Add this new file to `server/core/types/*/index.ts` to facilitate the imports
+ Create database migrations:
* Create the migration file in `server/core/initializers/migrations` using raw SQL (copy the same SQL query as at PeerTube startup)
* Update `LAST_MIGRATION_VERSION` in `server/core/initializers/constants.ts`
- If updating database schema (adding/removing/renaming a column):
+ Update the sequelize models in `server/core/models/`
+ Add migrations:
* Create the migration file in `initializers/migrations` using Sequelize Query Interface (`.addColumn`, `.dropTable`, `.changeColumn`)
* Update `LAST_MIGRATION_VERSION` in `server/core/initializers/constants.ts`
* Notifications:
- Create the new notification model in `packages/models/src/users/user-notification.model.ts`
- Create the notification logic in `server/core/lib/notifier/shared`:
+ Email subject has a common prefix (defined by the admin in PeerTube configuration)
- Add your notification to `server/core/lib/notifier/notifier.ts`
- Create the email template in `server/core/assets/email-templates`:
+ A text version is automatically generated from the HTML
+ The template usually extends `../common/grettings` that already says "Hi" and "Cheers". You just have to write the title and the content blocks that will be inserted in the appropriate places in the HTML template
- If you need to associate a new table with `userNotification`:
+ Associate the new table in `UserNotificationModel` (don't forget the index)
+ Add the object property in the API model definition (`packages/models/src/users/user-notification.model.ts`)
+ Add the object in `UserNotificationModel.toFormattedJSON`
+ Handle this new notification type in client (`UserNotificationsComponent`)
+ Handle the new object property in client model (`UserNotification`)
* Tests:
- Create your command class in `packages/server-commands/` that will wrap HTTP requests to your new endpoint
- Add your command file in `index.ts` of current directory
- Instantiate your command class in `packages/server-commands/src/server/core.ts`
- Create your test file in `server/core/tests/api/check-params` to test middleware validators/authentification/user rights (offensive tests)
- Add it to `server/core/tests/api/check-params/index.ts`
- Create your test file in `server/core/tests/api` to test your new endpoints
- Add it to `index.ts` of current directory
- Add your notification test in `server/core/tests/api/notifications`
* Update REST API documentation in `support/doc/api/openapi.yaml`
+127
ファイルの表示
@@ -0,0 +1,127 @@
# Tests
## Preparation
Prepare PostgreSQL user so PeerTube can delete/create the test databases:
```bash
sudo -u postgres createuser you_username --createdb --superuser
```
Prepare the databases:
```bash
npm run clean:server:test
```
Build PeerTube:
```bash
npm run build
```
## Server tests
### Dependencies
Run docker containers needed by some test files:
```bash
sudo docker run -p 9444:9000 chocobozzz/s3-ninja
sudo docker run -p 10389:10389 chocobozzz/docker-test-openldap
```
Ensure you also have these commands:
```bash
exiftool --help
parallel --help
# For transcription tests
whisper --help
whisper-ctranslate2 --help
jiwer --help
```
Otherwise, install the packages. On Debian-based systems (like Debian, Ubuntu or Mint):
```bash
sudo apt-get install parallel libimage-exiftool-perl
sudo pip install -r packages/tests/requirements.txt -r packages/transcription-devtools/requirements.txt
```
### Test
To run all test suites (can be long!):
```bash
npm run test # See scripts/test.sh to run a particular suite
```
To run a specific test:
```bash
npm run mocha -- --exit --bail packages/tests/src/your-test.ts
# For example
npm run mocha -- --exit --bail packages/tests/src/api/videos/single-server.ts
```
### Configuration
Some env variables can be defined to disable/enable some tests:
* `DISABLE_HTTP_IMPORT_TESTS=true`: disable import tests (because of youtube that could rate limit your IP)
* `ENABLE_OBJECT_STORAGE_TESTS=true`: enable object storage tests (needs `chocobozzz/s3-ninja` container first)
* `AKISMET_KEY`: specify an Akismet key to test akismet external PeerTube plugin
* `OBJECT_STORAGE_SCALEWAY_KEY_ID` and `OBJECT_STORAGE_SCALEWAY_ACCESS_KEY`: specify Scaleway API keys to test object storage ACL (not supported by our `chocobozzz/s3-ninja` container)
* `ENABLE_FFMPEG_THUMBNAIL_PIXEL_COMPARISON_TESTS=true`: enable pixel comparison on images generated by ffmpeg. Disabled by default because a custom ffmpeg version may fails the tests
### Debug server logs
While testing, you might want to display a server's logs to understand why they failed:
```bash
NODE_APP_INSTANCE=1 NODE_ENV=test npm run parse-log -- --level debug | less +GF
```
You can also:
- checkout only the latest logs (PeerTube >= 5.0):
```bash
tail -n 100 test1/logs/peertube.log | npm run parse-log -- --level debug --files -
```
- continuously print the latests logs (PeerTube >= 5.0):
```bash
tail -f test1/logs/peertube.log | npm run parse-log -- --level debug --files -
```
## Client E2E tests
### Local tests
To run tests on local web browsers (comment web browsers you don't have in `client/e2e/wdio.local.conf.ts`):
```bash
PEERTUBE2_E2E_PASSWORD=password npm run e2e:local
```
### Browserstack tests
To run tests on browser stack:
```bash
BROWSERSTACK_USER=your_user BROWSERSTACK_KEY=your_key npm run e2e:browserstack
```
### Add E2E tests
To add E2E tests and quickly run tests using a local Chrome:
```bash
cd client/e2e
../node_modules/.bin/wdio wdio.local-test.conf.ts # you can also add --mochaOpts.grep to only run tests you want
```
+180
ファイルの表示
@@ -0,0 +1,180 @@
# Docker guide
This guide requires [docker](https://www.docker.com/community-edition) and
[docker-compose V2](https://docs.docker.com/compose/install/).
```shell
docker compose version # Must be > 2.x.x
```
## Install
**PeerTube does not support webserver host change**. Keep in mind your domain
name is definitive after your first PeerTube start.
#### Go to your workdir
:::info
The guide that follows assumes an empty workdir, but you can also clone the repository, use the master branch and `cd support/docker/production`.
:::
```shell
cd /your/peertube/directory
```
#### Get the latest Compose file
```shell
curl https://raw.githubusercontent.com/chocobozzz/PeerTube/master/support/docker/production/docker-compose.yml > docker-compose.yml
```
View the source of the file you're about to download: [docker-compose.yml](https://github.com/Chocobozzz/PeerTube/blob/master/support/docker/production/docker-compose.yml)
#### Get the latest env_file
```shell
curl https://raw.githubusercontent.com/Chocobozzz/PeerTube/master/support/docker/production/.env > .env
```
View the source of the file you're about to download: [.env](https://github.com/Chocobozzz/PeerTube/blob/master/support/docker/production/.env)
#### Tweak the `docker-compose.yml` file there according to your needs
```shell
sudo nano docker-compose.yml
```
#### Then tweak the `.env` file to change the environment variables settings
```shell
sudo nano .env
```
In the downloaded example [.env](https://github.com/Chocobozzz/PeerTube/blob/master/support/docker/production/.env), you must replace:
- `<MY POSTGRES USERNAME>`
- `<MY POSTGRES PASSWORD>`
- `<MY DOMAIN>` without 'https://'
- `<MY EMAIL ADDRESS>`
- `<MY PEERTUBE SECRET>`
Other environment variables are used in
[/support/docker/production/config/custom-environment-variables.yaml](https://github.com/Chocobozzz/PeerTube/blob/master/support/docker/production/config/custom-environment-variables.yaml) and can be
intuited from usage.
#### Webserver
::: info
The docker compose file includes a configured web server. You can skip this part and comment the appropriate section in the docker compose if you use another webserver/proxy.
:::
Install the template that the nginx container will use.
The container will generate the configuration by replacing `${WEBSERVER_HOST}` and `${PEERTUBE_HOST}` using your docker compose env file.
```shell
mkdir -p docker-volume/nginx
curl https://raw.githubusercontent.com/Chocobozzz/PeerTube/master/support/nginx/peertube > docker-volume/nginx/peertube
```
You need to manually generate the first SSL/TLS certificate using Let's Encrypt:
```shell
mkdir -p docker-volume/certbot
docker run -it --rm --name certbot -p 80:80 -v "$(pwd)/docker-volume/certbot/conf:/etc/letsencrypt" certbot/certbot certonly --standalone
```
A dedicated container in the docker-compose will automatically renew this certificate and reload nginx.
#### Test your setup
_note_: Newer versions of compose are called with `docker compose` instead of `docker-compose`, so remove the dash in all steps that use this command if you are getting errors.
Run your containers:
```shell
docker compose up
```
#### Obtaining your automatically-generated admin credentials
You can change the automatically created password for user root by running this command from peertube's root directory:
```shell
docker compose exec -u peertube peertube npm run reset-password -- -u root
```
You can also grep your peertube container's logs for the default `root` password. You're going to want to run `docker-compose logs peertube | grep -A1 root` to search the log output for your new PeerTube's instance admin credentials which will look something like this.
```bash
docker compose logs peertube | grep -A1 root
peertube_1 | [example.com:443] 2019-11-16 04:26:06.082 info: Username: root
peertube_1 | [example.com:443] 2019-11-16 04:26:06.083 info: User password: abcdefghijklmnop
```
#### Obtaining Your Automatically Generated DKIM DNS TXT Record
[DKIM](https://en.wikipedia.org/wiki/DomainKeys_Identified_Mail) signature sending and RSA keys generation are enabled by the default Postfix image `mwader/postfix-relay` with [OpenDKIM](http://www.opendkim.org/).
Run `cat ./docker-volume/opendkim/keys/*/*.txt` to display your DKIM DNS TXT Record containing the public key to configure to your domain :
```bash
cat ./docker-volume/opendkim/keys/*/*.txt
peertube._domainkey.mydomain.tld. IN TXT ( "v=DKIM1; h=sha256; k=rsa; "
"p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0Dx7wLGPFVaxVQ4TGym/eF89aQ8oMxS9v5BCc26Hij91t2Ci8Fl12DHNVqZoIPGm+9tTIoDVDFEFrlPhMOZl8i4jU9pcFjjaIISaV2+qTa8uV1j3MyByogG8pu4o5Ill7zaySYFsYB++cHJ9pjbFSC42dddCYMfuVgrBsLNrvEi3dLDMjJF5l92Uu8YeswFe26PuHX3Avr261n"
"j5joTnYwat4387VEUyGUnZ0aZxCERi+ndXv2/wMJ0tizq+a9+EgqIb+7lkUc2XciQPNuTujM25GhrQBEKznvHyPA6fHsFheymOuB763QpkmnQQLCxyLygAY9mE/5RY+5Q6J9oDOQIDAQAB" ) ; ----- DKIM key peertube for mydomain.tld
```
#### Administrator password
See the production guide ["Administrator" section](https://docs.joinpeertube.org/install/any-os#administrator)
#### What now?
See the production guide ["What now" section](https://docs.joinpeertube.org/install/any-os#what-now).
## Upgrade
::: warning
Check the changelog (in particular the *IMPORTANT NOTES* section): https://github.com/Chocobozzz/PeerTube/blob/develop/CHANGELOG.md
:::
Pull the latest images:
```shell
cd /your/peertube/directory
docker compose pull
```
Stop, delete the containers and internal volumes (to invalidate static client files shared by `peertube` and `webserver` containers):
```shell
docker compose down -v
```
Update the nginx configuration:
```shell
mv docker-volume/nginx/peertube docker-volume/nginx/peertube.bak
curl https://raw.githubusercontent.com/Chocobozzz/PeerTube/master/support/nginx/peertube > docker-volume/nginx/peertube
```
Rerun PeerTube:
```shell
docker compose up -d
```
## Build
### Production
```shell
git clone https://github.com/chocobozzz/PeerTube /tmp/peertube
cd /tmp/peertube
docker build . -f ./support/docker/production/Dockerfile.bookworm
```
### Development
We don't have a Docker image for development. See [the CONTRIBUTING guide](https://github.com/Chocobozzz/PeerTube/blob/develop/.github/CONTRIBUTING.md#develop) for more information on how you can hack PeerTube!
ファイル差分が大きすぎるため省略します 差分を読込み
+415
ファイルの表示
@@ -0,0 +1,415 @@
# Production guide
* [Installation](#installation)
* [Upgrade](#upgrade)
## Installation
Please don't install PeerTube for production on a device behind a low bandwidth connection (example: your ADSL link).
If you want information about the appropriate hardware to run PeerTube, please see the [FAQ](https://joinpeertube.org/en_US/faq#should-i-have-a-big-server-to-run-peertube).
### :hammer: Dependencies
Follow the steps of the [dependencies guide](/support/doc/dependencies.md).
### :construction_worker: PeerTube user
Create a `peertube` user with `/var/www/peertube` home:
```bash
sudo useradd -m -d /var/www/peertube -s /bin/bash -p peertube peertube
```
Set its password:
```bash
sudo passwd peertube
```
Ensure the peertube root directory is traversable by nginx:
```bash
ls -ld /var/www/peertube # Should be drwxr-xr-x
```
**On FreeBSD**
```bash
sudo pw useradd -n peertube -d /var/www/peertube -s /usr/local/bin/bash -m
sudo passwd peertube
```
or use `adduser` to create it interactively.
### :card_file_box: Database
Create the production database and a peertube user inside PostgreSQL:
```bash
cd /var/www/peertube
sudo -u postgres createuser -P peertube
```
Here you should enter a password for PostgreSQL `peertube` user, that should be copied in `production.yaml` file.
Don't just hit enter else it will be empty.
```bash
sudo -u postgres createdb -O peertube -E UTF8 -T template0 peertube_prod
```
Then enable extensions PeerTube needs:
```bash
sudo -u postgres psql -c "CREATE EXTENSION pg_trgm;" peertube_prod
sudo -u postgres psql -c "CREATE EXTENSION unaccent;" peertube_prod
```
### :page_facing_up: Prepare PeerTube directory
Fetch the latest tagged version of Peertube:
```bash
VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4) && echo "Latest Peertube version is $VERSION"
```
Open the peertube directory, create a few required directories:
```bash
cd /var/www/peertube
sudo -u peertube mkdir config storage versions
sudo -u peertube chmod 750 config/
```
Download the latest version of the Peertube client, unzip it and remove the zip:
```bash
cd /var/www/peertube/versions
# Releases are also available on https://builds.joinpeertube.org/release
sudo -u peertube wget -q "https://github.com/Chocobozzz/PeerTube/releases/download/${VERSION}/peertube-${VERSION}.zip"
sudo -u peertube unzip -q peertube-${VERSION}.zip && sudo -u peertube rm peertube-${VERSION}.zip
```
Install Peertube:
```bash
cd /var/www/peertube
sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest
cd ./peertube-latest && sudo -H -u peertube yarn install --production --pure-lockfile
```
### :wrench: PeerTube configuration
Copy the default configuration file that contains the default configuration provided by PeerTube.
You **must not** update this file.
```bash
cd /var/www/peertube
sudo -u peertube cp peertube-latest/config/default.yaml config/default.yaml
```
Now copy the production example configuration:
```bash
cd /var/www/peertube
sudo -u peertube cp peertube-latest/config/production.yaml.example config/production.yaml
```
Then edit the `config/production.yaml` file according to your webserver and database configuration. In particular:
* `webserver`: Reverse proxy public information
* `secrets`: Secret strings you must generate manually (PeerTube version >= 5.0)
* `database`: PostgreSQL settings
* `redis`: Redis settings
* `smtp`: If you want to use emails
* `admin.email`: To correctly fill `root` user email
Keys defined in `config/production.yaml` will override keys defined in `config/default.yaml`.
**PeerTube does not support webserver host change**. Even though [PeerTube CLI can help you to switch hostname](https://docs.joinpeertube.org/maintain/tools#update-host-js) there's no official support for that since it is a risky operation that might result in unforeseen errors.
### :truck: Webserver
We only provide official configuration files for Nginx.
Copy the nginx configuration template:
```bash
sudo cp /var/www/peertube/peertube-latest/support/nginx/peertube /etc/nginx/sites-available/peertube
```
Set the domain for the webserver configuration file by replacing `[peertube-domain]` with the domain for the peertube server:
```bash
sudo sed -i 's/${WEBSERVER_HOST}/[peertube-domain]/g' /etc/nginx/sites-available/peertube
sudo sed -i 's/${PEERTUBE_HOST}/127.0.0.1:9000/g' /etc/nginx/sites-available/peertube
```
Then modify the webserver configuration file. Please pay attention to:
* the `alias`, `root` and `rewrite` directives paths, the paths must correspond to your PeerTube filesystem location
* the `proxy_limit_rate` and `limit_rate` directives if you plan to stream high bitrate videos (like 4K at 60FPS)
```bash
sudo vim /etc/nginx/sites-available/peertube
```
Activate the configuration file:
```bash
sudo ln -s /etc/nginx/sites-available/peertube /etc/nginx/sites-enabled/peertube
```
To generate the certificate for your domain as required to make https work you can use [Let's Encrypt](https://letsencrypt.org/):
```bash
sudo systemctl stop nginx
sudo certbot certonly --standalone --post-hook "systemctl restart nginx"
sudo systemctl reload nginx
```
Certbot should have installed a cron to automatically renew your certificate.
Since our nginx template supports webroot renewal, we suggest you to update the renewal config file to use the `webroot` authenticator:
```bash
# Replace authenticator = standalone by authenticator = webroot
# Add webroot_path = /var/www/certbot
sudo vim /etc/letsencrypt/renewal/your-domain.com.conf
```
If you plan to have many concurrent viewers on your PeerTube instance, consider increasing `worker_connections` value: https://nginx.org/en/docs/ngx_core_module.html#worker_connections.
<details>
<summary><strong>If using FreeBSD</strong></summary>
On FreeBSD you can use [Dehydrated](https://dehydrated.io/) `security/dehydrated` for [Let's Encrypt](https://letsencrypt.org/)
```bash
sudo pkg install dehydrated
```
</details>
### :alembic: Linux TCP/IP Tuning
```bash
sudo cp /var/www/peertube/peertube-latest/support/sysctl.d/30-peertube-tcp.conf /etc/sysctl.d/
sudo sysctl -p /etc/sysctl.d/30-peertube-tcp.conf
```
Your distro may enable this by default, but at least Debian 9 does not, and the default FIFO
scheduler is quite prone to "Buffer Bloat" and extreme latency when dealing with slower client
links as we often encounter in a video server.
### :bricks: systemd
If your OS uses systemd, copy the configuration template:
```bash
sudo cp /var/www/peertube/peertube-latest/support/systemd/peertube.service /etc/systemd/system/
```
Check the service file (PeerTube paths and security directives):
```bash
sudo vim /etc/systemd/system/peertube.service
```
Tell systemd to reload its config:
```bash
sudo systemctl daemon-reload
```
If you want to start PeerTube on boot:
```bash
sudo systemctl enable peertube
```
Run:
```bash
sudo systemctl start peertube
sudo journalctl -feu peertube
```
<details>
<summary><strong>If using FreeBSD</strong></summary>
On FreeBSD, copy the startup script and update rc.conf:
```bash
sudo install -m 0555 /var/www/peertube/peertube-latest/support/freebsd/peertube /usr/local/etc/rc.d/
sudo sysrc peertube_enable="YES"
```
Run:
```bash
sudo service peertube start
```
</details>
<details>
<summary><strong>If using OpenRC</strong></summary>
If your OS uses OpenRC, copy the service script:
```bash
sudo cp /var/www/peertube/peertube-latest/support/init.d/peertube /etc/init.d/
```
If you want to start PeerTube on boot:
```bash
sudo rc-update add peertube default
```
Run and print last logs:
```bash
sudo /etc/init.d/peertube start
tail -f /var/log/peertube/peertube.log
```
</details>
### :technologist: Administrator
The administrator username is `root` and the password is automatically generated. It can be found in PeerTube
logs (path defined in `production.yaml`). You can also set another password with:
```bash
cd /var/www/peertube/peertube-latest && NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run reset-password -- -u root
```
Alternatively you can set the environment variable `PT_INITIAL_ROOT_PASSWORD`,
to your own administrator password, although it must be 6 characters or more.
### :tada: What now?
Now your instance is up you can:
* Add your instance to the public PeerTube instances index if you want to: https://instances.joinpeertube.org/
* Check [available CLI tools](/support/doc/tools.md)
## Upgrade
### PeerTube instance
**Check the changelog (in particular the *IMPORTANT NOTES* section):** https://github.com/Chocobozzz/PeerTube/blob/develop/CHANGELOG.md
Run the upgrade script (the password it asks is PeerTube's database user password):
```bash
cd /var/www/peertube/peertube-latest/scripts && sudo -H -u peertube ./upgrade.sh
sudo systemctl restart peertube # Or use your OS command to restart PeerTube if you don't use systemd
```
You may want to run `sudo -u peertube yarn cache clean` after several upgrades to free up disk space.
<details>
<summary><strong>Prefer manual upgrade?</strong></summary>
Make a SQL backup
```bash
SQL_BACKUP_PATH="backup/sql-peertube_prod-$(date -Im).bak" && \
cd /var/www/peertube && sudo -u peertube mkdir -p backup && \
sudo -u postgres pg_dump -F c peertube_prod | sudo -u peertube tee "$SQL_BACKUP_PATH" >/dev/null
```
Fetch the latest tagged version of Peertube:
```bash
VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4) && echo "Latest Peertube version is $VERSION"
```
Download the new version and unzip it:
```bash
cd /var/www/peertube/versions && \
sudo -u peertube wget -q "https://github.com/Chocobozzz/PeerTube/releases/download/${VERSION}/peertube-${VERSION}.zip" && \
sudo -u peertube unzip -o peertube-${VERSION}.zip && \
sudo -u peertube rm peertube-${VERSION}.zip
```
Install node dependencies:
```bash
cd /var/www/peertube/versions/peertube-${VERSION} && \
sudo -H -u peertube yarn install --production --pure-lockfile
```
Copy new configuration defaults values and update your configuration file:
```bash
sudo -u peertube cp /var/www/peertube/versions/peertube-${VERSION}/config/default.yaml /var/www/peertube/config/default.yaml
diff -u /var/www/peertube/versions/peertube-${VERSION}/config/production.yaml.example /var/www/peertube/config/production.yaml
```
Change the link to point to the latest version:
```bash
cd /var/www/peertube && \
sudo unlink ./peertube-latest && \
sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest
```
</details>
### Update PeerTube configuration
Check for configuration changes, and report them in your `config/production.yaml` file:
```bash
cd /var/www/peertube/versions
diff -u "$(ls -t | head -2 | tail -1)/config/production.yaml.example" "$(ls -t | head -1)/config/production.yaml.example"
```
### Update nginx configuration
Check changes in nginx configuration:
```bash
cd /var/www/peertube/versions
diff -u "$(ls -t | head -2 | tail -1)/support/nginx/peertube" "$(ls -t | head -1)/support/nginx/peertube"
```
### Update systemd service
Check changes in systemd configuration:
```bash
cd /var/www/peertube/versions
diff -u "$(ls -t | head -2 | tail -1)/support/systemd/peertube.service" "$(ls -t | head -1)/support/systemd/peertube.service"
```
### Restart PeerTube
If you changed your nginx configuration:
```bash
sudo systemctl reload nginx
```
If you changed your systemd configuration:
```bash
sudo systemctl daemon-reload
```
Restart PeerTube and check the logs:
```bash
sudo systemctl restart peertube && sudo journalctl -fu peertube
```
### Things went wrong?
Change `peertube-latest` destination to the previous version and restore your SQL backup:
```bash
OLD_VERSION="v0.42.42" && SQL_BACKUP_PATH="backup/sql-peertube_prod-2018-01-19T10:18+01:00.bak" && \
cd /var/www/peertube && sudo -u peertube unlink ./peertube-latest && \
sudo -u peertube ln -s "versions/peertube-$OLD_VERSION" peertube-latest && \
sudo -u postgres pg_restore -c -C -d postgres "$SQL_BACKUP_PATH" && \
sudo systemctl restart peertube
```
+659
ファイルの表示
@@ -0,0 +1,659 @@
# CLI tools guide
[[toc]]
## Remote PeerTube CLI
`peertube-cli` is a tool that communicates with a PeerTube instance using its [REST API](https://docs.joinpeertube.org/api-rest-reference.html).
It can be launched from a remote server/computer to easily upload videos, manage plugins, redundancies etc.
### Installation
Ensure you have `node` installed on your system:
```bash
node --version # Should be >= 16.x
```
Then install the CLI:
```bash
sudo npm install -g @peertube/peertube-cli
```
### CLI wrapper
The wrapper provides a convenient interface to the following sub-commands.
```
Usage: peertube-cli [command] [options]
Options:
-v, --version output the version number
-h, --help display help for command
Commands:
auth Register your accounts on remote instances to use them with other commands
upload|up [options] Upload a video on a PeerTube instance
redundancy|r Manage instance redundancies
plugins|p Manage instance plugins/themes
get-access-token|token [options] Get a peertube access token
help [command] display help for command
```
The wrapper can keep track of instances you have an account on. We limit to one account per instance for now.
```bash
peertube-cli auth add -u 'PEERTUBE_URL' -U 'PEERTUBE_USER' --password 'PEERTUBE_PASSWORD'
peertube-cli auth list
┌──────────────────────────────┬──────────────────────────────┐
│ instance │ login │
├──────────────────────────────┼──────────────────────────────┤
'PEERTUBE_URL''PEERTUBE_USER'
└──────────────────────────────┴──────────────────────────────┘
```
You can now use that account to execute sub-commands without feeding the `--url`, `--username` and `--password` parameters:
```bash
peertube-cli upload <videoFile>
peertube-cli plugins list
...
```
#### peertube-cli upload
You can use this script to upload videos directly from the CLI.
Videos will be publicly available after transcoding (you can see them before that in your account on the web interface).
```bash
cd ${CLONE}
peertube-cli upload --help
```
#### peertube-cli plugins
Install/update/uninstall or list local or NPM PeerTube plugins:
```bash
cd ${CLONE}
peertube-cli plugins --help
peertube-cli plugins list --help
peertube-cli plugins install --help
peertube-cli plugins update --help
peertube-cli plugins uninstall --help
peertube-cli plugins install --path /my/plugin/path
peertube-cli plugins install --npm-name peertube-theme-example
```
#### peertube-cli redundancy
Manage (list/add/remove) video redundancies:
To list your videos that are duplicated by remote instances:
```bash
peertube-cli redundancy list-remote-redundancies
```
To list remote videos that your instance duplicated:
```bash
peertube-cli redundancy list-my-redundancies
```
To duplicate a specific video in your redundancy system:
```bash
peertube-cli redundancy add --video 823
```
To remove a video redundancy:
```bash
peertube-cli redundancy remove --video 823
```
## PeerTube runner
PeerTube supports VOD/Live transcoding and VOD transcription (PeerTube >= 6.2) by a remote PeerTube runner.
### Runner installation
Ensure you have `node`, `ffmpeg` and `ffprobe` installed on your system:
```bash
node --version # Should be >= 16.x
ffprobe -version # Should be >= 4.3
ffmpeg -version # Should be >= 4.3
```
If you want to use video transcription:
```bash
pip install whisper-ctranslate2 # or pipx install whisper-ctranslate2 depending on your distribution
```
Then install the CLI:
```bash
sudo npm install -g @peertube/peertube-runner
```
### Configuration
The runner uses env paths like `~/.config`, `~/.cache` and `~/.local/share` directories to store runner configuration or temporary files.
Multiple PeerTube runners can run on the same OS by using the `--id` CLI option (each runner uses its own config/tmp directories):
```bash
peertube-runner [commands] --id instance-1
peertube-runner [commands] --id instance-2
peertube-runner [commands] --id instance-3
```
You can change the runner configuration (jobs concurrency, ffmpeg threads/nice, whisper engines/models, etc.) by editing `~/.config/peertube-runner-nodejs/[id]/config.toml`.
### Run the server
#### In a shell
You need to run the runner in server mode first so it can run transcoding jobs of registered PeerTube instances:
```bash
peertube-runner server
```
#### As a Systemd service
If your OS uses systemd, you can also configure a service so that the runner starts automatically.
To do so, first create a dedicated user. Here, we are calling it `prunner`, but you can choose whatever name you want.
We are using `/srv/prunner` as his home dir, but you can choose any other path.
```bash
useradd -m -d /srv/prunner -s /bin/bash -p prunner prunner
```
::: info Note
If you want to use `/home/prunner`, you have to set `ProtectHome=false` in the systemd configuration (see below).
:::
Now, you can create the `/etc/systemd/system/prunner.service` file (don't forget to adapt path and user/group names if you changed it):
```Systemd
[Unit]
Description=PeerTube runner daemon
After=network.target
[Service]
Type=simple
Environment=NODE_ENV=production
User=prunner
Group=prunner
ExecStart=peertube-runner server
WorkingDirectory=/srv/prunner
SyslogIdentifier=prunner
Restart=always
; Some security directives.
; Mount /usr, /boot, and /etc as read-only for processes invoked by this service.
ProtectSystem=full
; Sets up a new /dev mount for the process and only adds API pseudo devices
; like /dev/null, /dev/zero or /dev/random but not physical devices. Disabled
; by default because it may not work on devices like the Raspberry Pi.
PrivateDevices=false
; Ensures that the service process and all its children can never gain new
; privileges through execve().
NoNewPrivileges=true
; This makes /home, /root, and /run/user inaccessible and empty for processes invoked
; by this unit. Make sure that you do not depend on data inside these folders.
ProtectHome=true
; Drops the sys admin capability from the daemon.
CapabilityBoundingSet=~CAP_SYS_ADMIN
[Install]
WantedBy=multi-user.target
```
:::info Note
You can add the parameter `--id instance-1` on the `ExecStart` line, if you want to have multiple instances.
You can then create multiple separate services. They can use the same user and path.
:::
Finally, to enable the service for the first time:
```bash
systemctl daemon-reload
systemctl enable prunner.service
systemctl restart prunner.service
```
Next time, if you need to start/stop/restart the service:
```bash
systemctl stop prunner.service
systemctl start prunner.service
systemctl restart prunner.service
```
You can also check the status (and last logs):
```bash
systemctl status prunner.service
```
To edit the runner configuration: juste edit the `/srv/prunner/.config/peertube-runner-nodejs/default/config.toml` file,
and restart the service (this file will be created when the runner starts for the first time).
If you are using the `--id` parameter, you can change specific configuration by editing the file `/srv/prunner/.config/peertube-runner-nodejs/[id]/config.toml`.
::: info
For every peertube-runner commands described below, you have to run them as the `prunner` user.
So for example, to call the `list-registered` command: `sudo -u prunner peertube-runner list-registered`.
Otherwise the script will read the wrong configuration and cache files, and won't work as expected.
:::
### Register
Then, you can register the runner to process transcoding job of a remote PeerTube instance:
::: code-group
```bash [Shell]
peertube-runner register --url http://peertube.example.com --registration-token ptrrt-... --runner-name my-runner-name
```
```bash [Systemd]
sudo -u prunner peertube-runner register --url http://peertube.example.com --registration-token ptrrt-... --runner-name my-runner-name
```
:::
The runner will then use a websocket connection with the PeerTube instance to be notified about new available transcoding jobs.
### Unregister
To unregister a PeerTube instance:
::: code-group
```bash [Shell]
peertube-runner unregister --url http://peertube.example.com --runner-name my-runner-name
```
```bash [Systemd]
sudo -u prunner peertube-runner unregister --url http://peertube.example.com --runner-name my-runner-name
```
:::
### List registered instances
::: code-group
```bash [Shell]
peertube-runner list-registered
```
```bash [Systemd]
sudo -u prunner peertube-runner list-registered
```
:::
### Update the runner package
You can check if there is a new runner version using:
```bash
sudo npm outdated -g @peertube/peertube-runner
```
```
Package Current Wanted Latest Location Depended by
@peertube/peertube-runner 0.0.6 0.0.7 0.0.7 node_modules/@peertube/peertube-runner lib
```
To update the runner:
```bash
# Update the package
sudo npm update -g @peertube/peertube-runner
# Check that the version changed (optional)
sudo npm list -g @peertube/peertube-runner
# Restart the service (if you are using systemd)
sudo systemctl restart prunner.service
```
## Server tools
Server tools are scripts that interact directly with the code of your PeerTube instance.
They must be run on the server, in `peertube-latest` directory.
### Parse logs
To parse PeerTube last log file:
::: code-group
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run parse-log -- --level info
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run parse-log -- --level info
```
:::
`--level` is optional and could be `info`/`warn`/`error`
You can also remove SQL or HTTP logs using `--not-tags` (PeerTube >= 3.2):
::: code-group
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run parse-log -- --level debug --not-tags http sql
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run parse-log -- --level debug --not-tags http sql
```
:::
### Regenerate video thumbnails
Regenerating local video thumbnails could be useful because new PeerTube releases may increase thumbnail sizes:
::: code-group
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run regenerate-thumbnails
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run regenerate-thumbnails
```
:::
### Add or replace specific video file
You can use this script to import a video file to replace an already uploaded file or to add a new web compatible resolution to a video. PeerTube needs to be running.
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.
::: code-group
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile]
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile]
```
:::
### Move video files from filesystem to object storage
Use this script to move all video files or a specific video file to object storage.
::: code-group
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
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]
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage -v [videoUUID]
```
:::
The script can also move all video files that are not already in object storage:
::: code-group
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
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
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage --all-videos
```
:::
### Move video files from object storage to filesystem
**PeerTube >= 6.0**
Use this script to move all video files or a specific video file from object storage to the PeerTube instance filesystem.
::: code-group
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-move-video-storage-job -- --to-file-system -v [videoUUID]
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-file-system -v [videoUUID]
```
:::
The script can also move all video files that are not already on the filesystem:
::: code-group
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-move-video-storage-job -- --to-file-system --all-videos
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-file-system --all-videos
```
:::
### Update object storage URLs
**PeerTube >= 6.2**
Use this script after you migrated to another object storage provider so PeerTube updates its internal object URLs (a confirmation will be demanded first).
PeerTube must be stopped.
::: code-group
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run update-object-storage-url -- --from 'https://region.old-s3-provider.example.com' --to 'https://region.new-s3-provider.example.com'
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run update-object-storage-url -- --from 'https://region.old-s3-provider.example.com' --to 'https://region.new-s3-provider.example.com'
```
:::
### Cleanup remote files
**PeerTube >= 6.2**
Use this script to recover disk space by removing remote files (thumbnails, avatars...) that can be re-fetched later by your PeerTube instance on-demand:
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run house-keeping -- --delete-remote-files
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run house-keeping -- --delete-remote-files
```
:::
### Generate storyboard
**PeerTube >= 6.0**
Use this script to generate storyboard of a specific video:
::: code-group
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-generate-storyboard-job -- -v [videoUUID]
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run create-generate-storyboard-job -- -v [videoUUID]
```
:::
The script can also generate all missing storyboards of local videos:
::: code-group
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-generate-storyboard-job -- --all-videos
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run create-generate-storyboard-job -- --all-videos
```
:::
### Prune filesystem/object storage
Some transcoded videos or shutdown at a bad time can leave some unused files on your storage.
To delete these files (a confirmation will be demanded first):
```bash
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run prune-storage
```
### Update PeerTube instance domain name
**Changing the hostname is unsupported and may be a risky operation, especially if you have already federated.**
If you started PeerTube with a domain, and then changed it you will have
invalid torrent files and invalid URLs in your database. To fix this, you have
to run the command below (keep in mind your follower instances will NOT update their URLs).
::: code-group
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run update-host
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run update-host
```
:::
### Reset user password
To reset a user password from CLI, run:
::: code-group
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run reset-password -- -u target_username
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run reset-password -- -u target_username
```
:::
### Install or uninstall plugins
The difference with `peertube plugins` CLI is that these scripts can be used even if PeerTube is not running.
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).
To install/update a plugin or a theme from the disk:
::: code-group
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:install -- --plugin-path /local/plugin/path
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run plugin:install -- --plugin-path /local/plugin/path
```
:::
From NPM:
::: code-group
```bash
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:install -- --npm-name peertube-plugin-myplugin
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run plugin:install -- --npm-name peertube-plugin-myplugin
```
:::
To uninstall a plugin or a theme:
::: code-group
```bash [Classic installation]
cd /var/www/peertube/peertube-latest
sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin
```
```bash [Docker]
cd /var/www/peertube-docker
docker compose exec -u peertube peertube npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin
```
:::
+63
ファイルの表示
@@ -0,0 +1,63 @@
# Translation
We use [Weblate](https://weblate.org) as translation platform.
Please do not edit translation files directly from Git, you have to use Weblate!
If you don't see your locale in the platform you can add it directly in the Weblate interface.
Then, if you think there are enough translated strings, please [create an issue](https://github.com/Chocobozzz/PeerTube/issues) so we add the new locale in PeerTube!
Translations are manually pulled and merged in PeerTube software and are publicly available in the next official release.
You can get a chance to see translations before the official release by going to https://peertube2.cpy.re which is updated every night with the latest PeerTube changes.
## How to
* Create an account: https://weblate.framasoft.org/accounts/register/
* Validate your email and follow the link sent
* Create your password (keep the `Current password` field empty) and setup your account
* Go to the PeerTube page https://weblate.framasoft.org/projects/peertube/
* Choose the file and the locale you want to translate
## Files
There are 4 files:
* **angular**: contains client strings
* **player**: contains player strings.
Most of the strings come from VideoJS, so you can help yourself by using [video.js JSON files](https://github.com/videojs/video.js/tree/master/lang)
* **server**: contains server strings (privacies, licences...) and iso639 (languages) strings used by PeerTube to describe the audio language of a particular video.
It's the reason why these strings should be translated too. There are many strings so do not hesitate to translate only main audio languages.
## Tips
### Special tags
You must not translate special tags like `<x id="INTERPOLATION" ... />`.
For example:
```
<x id="INTERPOLATION" equiv-text="{{ video.publishedAt | myFromNow }}"/> - <x id="INTERPOLATION_1" equiv-text="{{ video.views | myNumberFormatter }}"/> views
```
should be in french
```
<x id="INTERPOLATION" equiv-text="{{ video.publishedAt | myFromNow }}"/> - <x id="INTERPOLATION_1" equiv-text="{{ video.views | myNumberFormatter }}"/> vues
```
### Singular/plural
For singular/plural translations, you must translate values inside `{` and `}`. **Please don't translate the word *other***
For example:
```
{VAR_PLURAL, plural, =0 {No videos} =1 {1 video} other {<x id="INTERPOLATION" equiv-text="{{ playlist.videosLength }}"/> videos} }
```
should be in french
```
{VAR_PLURAL, plural, =0 {Aucune vidéo} =1 {1 vidéo} other {<x id="INTERPOLATION" equiv-text="{{ playlist.videosLength }}"/> vidéos} }
```