1) Fork the Github repository.
1) Run the following commands.
```
-$ git clone https://github.com/Chocobozzz/PeerTube
-$ cd PeerTube
-$ git remote add me git@github.com:YOUR_GITHUB_USERNAME/PeerTube.git
-$ yarn install --pure-lockfile
+git clone https://github.com/Chocobozzz/PeerTube
+cd PeerTube
+git remote add me git@github.com:YOUR_GITHUB_USERNAME/PeerTube.git
+yarn install --pure-lockfile
```
Note that development is done on the `develop` branch. If you want to hack on
When you create a new branch you should also tell to use your repo for upload
not default one. To do just do:
```
-$ git push --set-upstream me <your branch name>
+git push --set-upstream me <your branch name>
```
Then, create a postgres database and user with the values set in the
Then enable extensions PeerTube needs:
```
-$ sudo -u postgres psql -c "CREATE EXTENSION pg_trgm;" peertube_dev
-$ sudo -u postgres psql -c "CREATE EXTENSION unaccent;" peertube_dev
+sudo -u postgres psql -c "CREATE EXTENSION pg_trgm;" peertube_dev
+sudo -u postgres psql -c "CREATE EXTENSION unaccent;" peertube_dev
```
Peertube also requires a running redis server, no special setup is needed for
To develop on the server-side:
```
-$ npm run dev:server
+npm run dev:server
```
Then, the server will listen on `localhost:9000`. When server source files
To develop on the client side:
```
-$ npm run dev:client
+npm run dev:client
```
The API will listen on `localhost:9000` and the frontend on `localhost:3000`.
and the web server is automatically restarted.
```
-$ npm run dev
+npm run dev
```
### Embed
The following command will compile embed files and run the PeerTube server:
```
-$ npm run dev:embed
+npm run dev:embed
```
### RTL layout
To test RTL (right-to-left) layout using `ar` locale:
```
-$ npm run dev -- --ar-locale
+npm run dev -- --ar-locale
```
### Testing
Then, we can create the databases (if they don't already exist):
```
-$ sudo -u postgres createuser you_username --createdb --superuser
-$ createdb -O peertube peertube_test{1,2,3}
+sudo -u postgres createuser you_username --createdb --superuser
+createdb -O peertube peertube_test{1,2,3}
```
Build the application and flush the old tests data:
```
-$ npm run build
-$ npm run clean:server:test
+npm run build
+npm run clean:server:test
```
To run 3 nodes:
```
-$ NODE_APP_INSTANCE=1 NODE_ENV=test npm start
-$ NODE_APP_INSTANCE=2 NODE_ENV=test npm start
-$ NODE_APP_INSTANCE=3 NODE_ENV=test npm start
+NODE_APP_INSTANCE=1 NODE_ENV=test npm start
+NODE_APP_INSTANCE=2 NODE_ENV=test npm start
+NODE_APP_INSTANCE=3 NODE_ENV=test npm start
```
Then you will get access to the three nodes at `http://127.0.0.1:900{1,2,3}`
**Important:** Before upgrading run the following commands (no need to stop PeerTube) on your PeerTube database (in this example it's *peertube_prod*):
```
-$ sudo -u postgres psql peertube_prod -c 'CREATE EXTENSION IF NOT EXISTS unaccent;'
-$ sudo -u postgres psql peertube_prod -c 'CREATE EXTENSION IF NOT EXISTS pg_trgm;'
+sudo -u postgres psql peertube_prod -c 'CREATE EXTENSION IF NOT EXISTS unaccent;'
+sudo -u postgres psql peertube_prod -c 'CREATE EXTENSION IF NOT EXISTS pg_trgm;'
```
You will need [PostgreSQL Contrib](https://www.postgresql.org/docs/9.6/static/contrib.html).
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
+curl https://peertube.example.com/api/v1/oauth-clients/local
```
Response example:
Now you can fetch the user token:
```bash
-$ curl -X POST \
+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
```
Just use the `access_token` in the `Authorization` header:
```bash
-$ curl -H 'Authorization: Bearer 90286a0bdf0f7315d9d3fe8dabf9e1d2be9c97d0' https://peertube.example.com/api/v1/jobs/completed
+curl -H 'Authorization: Bearer 90286a0bdf0f7315d9d3fe8dabf9e1d2be9c97d0' https://peertube.example.com/api/v1/jobs/completed
```
## List videos
```bash
-$ curl https://peertube.example.com/api/v1/videos
+curl https://peertube.example.com/api/v1/videos
```
## Libraries
### Build & Publish
```
-$ cd client/src/standalone/player/
-$ npm run build
-$ npm publish --access=public
+cd client/src/standalone/player/
+npm run build
+npm publish --access=public
```
## @peertube/peertube-types
The complete types package is generated via:
```
-$ npm run generate-types-package 4.x.x
-$ cd packages/types/dist
-$ npm publish --access=public
+npm run generate-types-package 4.x.x
+cd packages/types/dist
+npm publish --access=public
```
> See [scripts/generate-types-package.ts](scripts/generate-types-package.ts) for details.
Then, it will merge new translation keys into localized Angular files (`angular.fr-FR.xlf` etc).
```
-$ npm run i18n:update
+npm run i18n:update
```
To open a report of client build:
```
-$ npm run build -- --analyze-bundle && npm run client-report
+npm run build -- --analyze-bundle && npm run client-report
```
## API benchmark
To benchmark the REST API and save result in `benchmark.json`:
```
-$ node dist/scripts/benchmark.js -o benchmark.json
+node dist/scripts/benchmark.js -o benchmark.json
```
You can also grep on a specific test:
```
-$ node dist/scripts/benchmark.js --grep homepage
+node dist/scripts/benchmark.js --grep homepage
```
Prepare PostgreSQL user so PeerTube can delete/create the test databases:
```bash
-$ sudo -u postgres createuser you_username --createdb --superuser
+sudo -u postgres createuser you_username --createdb --superuser
```
Prepare databases:
```bash
-$ npm run clean:server:test
+npm run clean:server:test
```
Build PeerTube:
```bash
-$ npm run build
+npm run build
```
## Server tests
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
+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
+exiftool --help
+parallel --help
```
Otherwise, install the packages. On Debian-based systems (like Debian, Ubuntu or Mint):
```bash
-$ sudo apt-get install parallel libimage-exiftool-perl
+sudo apt-get install parallel libimage-exiftool-perl
```
### Test
To run all test suites:
```bash
-$ npm run test # See scripts/test.sh to run a particular suite
+npm run test # See scripts/test.sh to run a particular suite
```
Most of tests can be run using:
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
+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
+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
+cd client/e2e
+../node_modules/.bin/wdio wdio.local-test.conf.ts # you can also add --mochaOpts.grep to only run tests you want
```
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
+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
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
+cat ./docker-volume/opendkim/keys/*/*.txt
peertube._domainkey.mydomain.tld. IN TXT ( "v=DKIM1; h=sha256; k=rsa; "
"p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0Dx7wLGPFVaxVQ4TGym/eF89aQ8oMxS9v5BCc26Hij91t2Ci8Fl12DHNVqZoIPGm+9tTIoDVDFEFrlPhMOZl8i4jU9pcFjjaIISaV2+qTa8uV1j3MyByogG8pu4o5Ill7zaySYFsYB++cHJ9pjbFSC42dddCYMfuVgrBsLNrvEi3dLDMjJF5l92Uu8YeswFe26PuHX3Avr261n"
Pull the latest images:
```shell
-$ cd /your/peertube/directory
-$ docker-compose pull
+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
+docker-compose down -v
```
Rerun PeerTube:
```shell
-$ docker-compose up -d
+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.bullseye
+git clone https://github.com/chocobozzz/PeerTube /tmp/peertube
+cd /tmp/peertube
+docker build . -f ./support/docker/production/Dockerfile.bullseye
```
### Development
If you develop a plugin, clone the `peertube-plugin-quickstart` repository:
```
-$ git clone https://framagit.org/framasoft/peertube/peertube-plugin-quickstart.git peertube-plugin-mysupername
+git clone https://framagit.org/framasoft/peertube/peertube-plugin-quickstart.git peertube-plugin-mysupername
```
If you develop a theme, clone the `peertube-theme-quickstart` repository:
```
-$ git clone https://framagit.org/framasoft/peertube/peertube-theme-quickstart.git peertube-theme-mysupername
+git clone https://framagit.org/framasoft/peertube/peertube-theme-quickstart.git peertube-theme-mysupername
```
### Configure your repository
Set your repository URL:
```
-$ cd peertube-plugin-mysupername # or cd peertube-theme-mysupername
-$ git remote set-url origin https://your-git-repo
+cd peertube-plugin-mysupername # or cd peertube-theme-mysupername
+git remote set-url origin https://your-git-repo
```
### Update README
Update `README.md` file:
```
-$ $EDITOR README.md
+$EDITOR README.md
```
### Update package.json
Install webpack:
```
-$ npm install
+npm install
```
Add/update your files in the `clientFiles` array of `webpack.config.js`:
```
-$ $EDITOR ./webpack.config.js
+$EDITOR ./webpack.config.js
```
Build your client files:
```
-$ npm run build
+npm run build
```
You built files are in the `dist/` directory. Check `package.json` to correctly point to them.
* Build PeerTube:
```
-$ npm run build
+npm run build
```
* Build the CLI:
```
-$ npm run setup:cli
+npm run setup:cli
```
* Run PeerTube (you can access to your instance on `localhost:9000`):
```
-$ NODE_ENV=dev npm start
+NODE_ENV=dev npm start
```
* Register the instance via the CLI:
```
-$ node ./dist/server/tools/peertube.js auth add -u 'http://localhost:9000' -U 'root' --password 'test'
+node ./dist/server/tools/peertube.js auth add -u 'http://localhost:9000' -U 'root' --password 'test'
```
Then, you can install or reinstall your local plugin/theme by running:
```
-$ node ./dist/server/tools/peertube.js plugins install --path /your/absolute/plugin-or-theme/path
+node ./dist/server/tools/peertube.js plugins install --path /your/absolute/plugin-or-theme/path
```
### Publish
Go in your plugin/theme directory, and run:
```
-$ npm publish
+npm publish
```
Every time you want to publish another version of your plugin/theme, just update the `version` key from the `package.json`
you can deprecate it. The plugin index will automatically remove it preventing users to find/install it from the PeerTube admin interface:
```bash
-$ npm deprecate peertube-plugin-xxx@"> 0.0.0" "explain here why you deprecate your plugin/theme"
+npm deprecate peertube-plugin-xxx@"> 0.0.0" "explain here why you deprecate your plugin/theme"
```
## Plugin & Theme hooks/helpers API
Create a `peertube` user with `/var/www/peertube` home:
```bash
-$ sudo useradd -m -d /var/www/peertube -s /bin/bash -p peertube peertube
+sudo useradd -m -d /var/www/peertube -s /bin/bash -p peertube peertube
```
Set its password:
```bash
-$ sudo passwd peertube
+sudo passwd peertube
```
Ensure the peertube root directory is traversable by nginx:
```bash
-$ ls -ld /var/www/peertube # Should be drwxr-xr-x
+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
+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.
Create the production database and a peertube user inside PostgreSQL:
```bash
-$ cd /var/www/peertube
-$ sudo -u postgres createuser -P peertube
+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
+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
+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"
+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/
+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
+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
+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
You **must not** update this file.
```bash
-$ cd /var/www/peertube
-$ sudo -u peertube cp peertube-latest/config/default.yaml config/default.yaml
+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
+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:
Copy the nginx configuration template:
```bash
-$ sudo cp /var/www/peertube/peertube-latest/support/nginx/peertube /etc/nginx/sites-available/peertube
+sudo cp /var/www/peertube/peertube-latest/support/nginx/peertube /etc/nginx/sites-available/peertube
```
Then set the domain for the webserver configuration file.
Replace `[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
+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` keys of the static locations.
It should correspond to the paths of your storage directories (set in the configuration file inside the `storage` key).
```bash
-$ sudo vim /etc/nginx/sites-available/peertube
+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
+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
+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
+# 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.
On FreeBSD you can use [Dehydrated](https://dehydrated.io/) `security/dehydrated` for [Let's Encrypt](https://letsencrypt.org/)
```bash
-$ sudo pkg install dehydrated
+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
+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
If your OS uses systemd, copy the configuration template:
```bash
-$ sudo cp /var/www/peertube/peertube-latest/support/systemd/peertube.service /etc/systemd/system/
+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
+sudo vim /etc/systemd/system/peertube.service
```
Tell systemd to reload its config:
```bash
-$ sudo systemctl daemon-reload
+sudo systemctl daemon-reload
```
If you want to start PeerTube on boot:
```bash
-$ sudo systemctl enable peertube
+sudo systemctl enable peertube
```
Run:
```bash
-$ sudo systemctl start peertube
-$ sudo journalctl -feu peertube
+sudo systemctl start peertube
+sudo journalctl -feu peertube
```
<details>
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"
+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
+sudo service peertube start
```
</details>
If your OS uses OpenRC, copy the service script:
```bash
-$ sudo cp /var/www/peertube/peertube-latest/support/init.d/peertube /etc/init.d/
+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
+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
+sudo /etc/init.d/peertube start
+tail -f /var/log/peertube/peertube.log
```
</details>
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
+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`,
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
+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
```
<details>
Make a SQL backup
```bash
-$ SQL_BACKUP_PATH="backup/sql-peertube_prod-$(date -Im).bak" && \
+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"
+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 && \
+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} && \
+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
+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 && \
+cd /var/www/peertube && \
sudo unlink ./peertube-latest && \
sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest
```
Check for configuration changes, and report them in your `config/production.yaml` file:
```bash
-$ cd /var/www/peertube/versions
-$ diff -u "$(ls --sort=t | head -2 | tail -1)/config/production.yaml.example" "$(ls --sort=t | head -1)/config/production.yaml.example"
+cd /var/www/peertube/versions
+diff -u "$(ls --sort=t | head -2 | tail -1)/config/production.yaml.example" "$(ls --sort=t | head -1)/config/production.yaml.example"
```
### Update nginx configuration
Check changes in nginx configuration:
```bash
-$ cd /var/www/peertube/versions
-$ diff -u "$(ls --sort=t | head -2 | tail -1)/support/nginx/peertube" "$(ls --sort=t | head -1)/support/nginx/peertube"
+cd /var/www/peertube/versions
+diff -u "$(ls --sort=t | head -2 | tail -1)/support/nginx/peertube" "$(ls --sort=t | head -1)/support/nginx/peertube"
```
### Update systemd service
Check changes in systemd configuration:
```bash
-$ cd /var/www/peertube/versions
-$ diff -u "$(ls --sort=t | head -2 | tail -1)/support/systemd/peertube.service" "$(ls --sort=t | head -1)/support/systemd/peertube.service"
+cd /var/www/peertube/versions
+diff -u "$(ls --sort=t | head -2 | tail -1)/support/systemd/peertube.service" "$(ls --sort=t | head -1)/support/systemd/peertube.service"
```
### Restart PeerTube
If you changed your nginx configuration:
```bash
-$ sudo systemctl reload nginx
+sudo systemctl reload nginx
```
If you changed your systemd configuration:
```bash
-$ sudo systemctl daemon-reload
+sudo systemctl daemon-reload
```
Restart PeerTube and check the logs:
```bash
-$ sudo systemctl restart peertube && sudo journalctl -fu peertube
+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
+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
```
Clone the PeerTube repo to get the latest version (even if you are on your PeerTube server):
```bash
-$ git clone https://github.com/Chocobozzz/PeerTube.git
-$ CLONE="$(pwd)/PeerTube"
-$ cd ${CLONE}
+git clone https://github.com/Chocobozzz/PeerTube.git
+CLONE="$(pwd)/PeerTube"
+cd ${CLONE}
```
Install dependencies and build CLI tools:
```bash
-$ NOCLIENT=1 yarn install --pure-lockfile
-$ npm run setup:cli
+NOCLIENT=1 yarn install --pure-lockfile
+npm run setup:cli
```
### CLI wrapper
The wrapper can keep track of instances you have an account on. We limit to one account per instance for now.
```bash
-$ peertube auth add -u 'PEERTUBE_URL' -U 'PEERTUBE_USER' --password 'PEERTUBE_PASSWORD'
-$ peertube auth list
+peertube auth add -u 'PEERTUBE_URL' -U 'PEERTUBE_USER' --password 'PEERTUBE_PASSWORD'
+peertube auth list
┌──────────────────────────────┬──────────────────────────────┐
│ instance │ login │
├──────────────────────────────┼──────────────────────────────┤
You can now use that account to upload videos without feeding the same parameters again.
```bash
-$ peertube up <videoFile>
+peertube up <videoFile>
```
To list, install, uninstall dynamically plugins/themes of an instance:
```bash
-$ peertube plugins list
-$ peertube plugins install --path /local/plugin/path
-$ peertube plugins install --npm-name peertube-plugin-myplugin
-$ peertube plugins uninstall --npm-name peertube-plugin-myplugin
+peertube plugins list
+peertube plugins install --path /local/plugin/path
+peertube plugins install --npm-name peertube-plugin-myplugin
+peertube plugins uninstall --npm-name peertube-plugin-myplugin
```
#### peertube-import-videos.js
Be sure you own the videos or have the author's authorization to do so.
```sh
-$ node dist/server/tools/peertube-import-videos.js \
+node dist/server/tools/peertube-import-videos.js \
-u 'PEERTUBE_URL' \
-U 'PEERTUBE_USER' \
--password 'PEERTUBE_PASSWORD' \
Videos will be publicly available after transcoding (you can see them before that in your account on the web interface).
```bash
-$ cd ${CLONE}
-$ node dist/server/tools/peertube-upload.js --help
+cd ${CLONE}
+node dist/server/tools/peertube-upload.js --help
```
#### peertube-plugins.js
Install/update/uninstall or list local or NPM PeerTube plugins:
```bash
-$ cd ${CLONE}
-$ node dist/server/tools/peertube-plugins.js --help
-$ node dist/server/tools/peertube-plugins.js list --help
-$ node dist/server/tools/peertube-plugins.js install --help
-$ node dist/server/tools/peertube-plugins.js update --help
-$ node dist/server/tools/peertube-plugins.js uninstall --help
-
-$ node dist/server/tools/peertube-plugins.js install --path /my/plugin/path
-$ node dist/server/tools/peertube-plugins.js install --npm-name peertube-theme-example
+cd ${CLONE}
+node dist/server/tools/peertube-plugins.js --help
+node dist/server/tools/peertube-plugins.js list --help
+node dist/server/tools/peertube-plugins.js install --help
+node dist/server/tools/peertube-plugins.js update --help
+node dist/server/tools/peertube-plugins.js uninstall --help
+
+node dist/server/tools/peertube-plugins.js install --path /my/plugin/path
+node dist/server/tools/peertube-plugins.js install --npm-name peertube-theme-example
```
#### peertube-redundancy.js
To list your videos that are duplicated by remote instances:
```bash
-$ node dist/server/tools/peertube.js redundancy list-remote-redundancies
+node dist/server/tools/peertube.js redundancy list-remote-redundancies
```
To list remote videos that your instance duplicated:
```bash
-$ node dist/server/tools/peertube.js redundancy list-my-redundancies
+node dist/server/tools/peertube.js redundancy list-my-redundancies
```
To duplicate a specific video in your redundancy system:
```bash
-$ node dist/server/tools/peertube.js redundancy add --video 823
+node dist/server/tools/peertube.js redundancy add --video 823
```
To remove a video redundancy:
```bash
-$ node dist/server/tools/peertube.js redundancy remove --video 823
+node dist/server/tools/peertube.js redundancy remove --video 823
```
## Server tools
To parse PeerTube last log file:
```bash
-$ # Basic 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
+# Basic 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
-$ # Docker installation
-$ cd /var/www/peertube-docker
-$ docker-compose exec -u peertube peertube npm run parse-log -- --level info
+# Docker installation
+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):
```bash
-$ # Basic 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
+# Basic 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
-$ # Docker installation
-$ cd /var/www/peertube-docker
-$ docker-compose exec -u peertube peertube npm run parse-log -- --level debug --not-tags http sql
+# Docker installation
+cd /var/www/peertube-docker
+docker-compose exec -u peertube peertube npm run parse-log -- --level debug --not-tags http sql
```
### regenerate-thumbnails.js
Regenerating local video thumbnails could be useful because new PeerTube releases may increase thumbnail sizes:
```bash
-$ # Basic installation
-$ cd /var/www/peertube/peertube-latest
-$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run regenerate-thumbnails
+# Basic installation
+cd /var/www/peertube/peertube-latest
+sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run regenerate-thumbnails
-$ # Docker installation
-$ cd /var/www/peertube-docker
-$ docker-compose exec -u peertube peertube npm run regenerate-thumbnails
+# Docker installation
+cd /var/www/peertube-docker
+docker-compose exec -u peertube peertube npm run regenerate-thumbnails
```
### create-transcoding-job.js
To generate transcoding jobs depending on the instance configuration:
```bash
-$ # Basic installation
-$ cd /var/www/peertube/peertube-latest
-$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID]
+# Basic installation
+cd /var/www/peertube/peertube-latest
+sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID]
-$ # Docker installation
-$ cd /var/www/peertube-docker
-$ docker-compose exec -u peertube peertube npm run create-transcoding-job -- -v [videoUUID]
+# Docker installation
+cd /var/www/peertube-docker
+docker-compose exec -u peertube peertube npm run create-transcoding-job -- -v [videoUUID]
```
Or to transcode to a specific resolution:
```bash
-$ # Basic installation
-$ cd /var/www/peertube/peertube-latest
-$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID] -r [resolution]
+# Basic installation
+cd /var/www/peertube/peertube-latest
+sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID] -r [resolution]
-$ # Docker installation
-$ cd /var/www/peertube-docker
-$ docker-compose exec -u peertube peertube npm run create-transcoding-job -- -v [videoUUID] -r [resolution]
+# Docker installation
+cd /var/www/peertube-docker
+docker-compose exec -u peertube peertube npm run create-transcoding-job -- -v [videoUUID] -r [resolution]
```
The resolution should be an integer (`1080`, `720`, `480`, etc.)
To generate an HLS playlist for a video:
```bash
-$ # Basic installation
-$ cd /var/www/peertube/peertube-latest
-$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- --generate-hls -v [videoUUID]
+# Basic installation
+cd /var/www/peertube/peertube-latest
+sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- --generate-hls -v [videoUUID]
-$ # Docker installation
-$ cd /var/www/peertube-docker
-$ docker-compose exec -u peertube peertube npm run create-transcoding-job -- --generate-hls -v [videoUUID]
+# Docker installation
+cd /var/www/peertube-docker
+docker-compose exec -u peertube peertube npm run create-transcoding-job -- --generate-hls -v [videoUUID]
```
### create-import-video-file-job.js
You can then create a transcoding job using `npm run create-transcoding-job` if you need to optimize your file or create an HLS version of it.
```bash
-$ # Basic 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]
+# Basic 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]
-$ # Docker installation
-$ cd /var/www/peertube-docker
-$ docker-compose exec -u peertube peertube npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile]
+# Docker installation
+cd /var/www/peertube-docker
+docker-compose exec -u peertube peertube npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile]
```
### create-move-video-storage-job.js
Use this script to move all video files or a specific video file to object storage.
```bash
-$ # Basic 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]
+# Basic 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]
-$ # Docker installation
-$ cd /var/www/peertube-docker
-$ docker-compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage -v [videoUUID]
+# Docker installation
+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:
```bash
-$ # Basic 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
+# Basic 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
-$ # Docker installation
-$ cd /var/www/peertube-docker
-$ docker-compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage --all-videos
+# Docker installation
+cd /var/www/peertube-docker
+docker-compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage --all-videos
```
Stop PeerTube and delete these files (a confirmation will be demanded first):
```bash
-$ cd /var/www/peertube/peertube-latest
-$ sudo systemctl stop peertube && sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run prune-storage
+cd /var/www/peertube/peertube-latest
+sudo systemctl stop peertube && sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run prune-storage
```
to run the command below (keep in mind your follower instances will NOT update their URLs).
```bash
-$ # Basic installation
-$ cd /var/www/peertube/peertube-latest
-$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run update-host
+# Basic installation
+cd /var/www/peertube/peertube-latest
+sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run update-host
-$ # Docker installation
-$ cd /var/www/peertube-docker
-$ docker-compose exec -u peertube peertube npm run update-host
+# Docker installation
+cd /var/www/peertube-docker
+docker-compose exec -u peertube peertube npm run update-host
```
### reset-password.js
To reset a user password from CLI, run:
```bash
-$ # Basic 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
+# Basic 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
-$ # Docker installation
-$ cd /var/www/peertube-docker
-$ docker-compose exec -u peertube peertube npm run reset-password -- -u target_username
+# Docker installation
+cd /var/www/peertube-docker
+docker-compose exec -u peertube peertube npm run reset-password -- -u target_username
```
To install/update a plugin or a theme from the disk:
```bash
-$ 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
+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
-$ # Docker installation
-$ cd /var/www/peertube-docker
-$ docker-compose exec -u peertube peertube npm run plugin:install -- --plugin-path /local/plugin/path
+# Docker installation
+cd /var/www/peertube-docker
+docker-compose exec -u peertube peertube npm run plugin:install -- --plugin-path /local/plugin/path
```
From NPM:
```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
+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
-$ # Docker installation
-$ cd /var/www/peertube-docker
-$ docker-compose exec -u peertube peertube npm run plugin:install -- --npm-name peertube-plugin-myplugin
+# Docker installation
+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:
```bash
-$ 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
+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
-$ # Docker installation
-$ cd /var/www/peertube-docker
-$ docker-compose exec -u peertube peertube npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin
+# Docker installation
+cd /var/www/peertube-docker
+docker-compose exec -u peertube peertube npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin
```