Commit 676c7443 authored by Boxiang Sun's avatar Boxiang Sun

peertube: parameter mechanism update

parent cd8f7c43
......@@ -4,6 +4,12 @@
"description": "Parameters to instantiate Peertube",
"additionalProperties": false,
"properties": {
"fronted-url": {
"title": "Frontend URL",
"description": "Frontend URL",
"default": "",
"type": "string"
},
"name": {
"title": "Instance Title",
"description": "The name of your peertube instance.",
......
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Values returned by Peertube instanciation",
"properties": {
"backend-url": {
"description": "Peertube Backend URL",
"type": "string"
},
"username": {
"description": "Peertube username",
"type": "string"
},
"password": {
"description": "Peertube password",
"type": "string"
}
},
"type": "object"
}
......@@ -10,7 +10,7 @@ parts =
nginx-service
peertube-service
publish-connection-parameter
peertube-urlparse
peertube-parameters
dcron-service
activate-crontab-file
peertube-backup-cron
......@@ -45,6 +45,12 @@ storage = $${:peertube_directory}/storage
versions = $${:peertube_directory}/versions
ssl = $${:etc}/ssl
[peertube-passwd]
recipe = slapos.cookbook:generate.password
storage-path = $${directory:etc}/.peertube_user
bytes = 8
username = root
[peertube-yaml]
recipe = slapos.recipe.template
url = ${template-peertube:output}
......@@ -79,11 +85,6 @@ ipv4 = $${instance-parameter:ipv4-random}
ipv6 =
port = 5432
[service-postgresql]
recipe = slapos.cookbook:postgres
bin = ${postgresql10:location}/bin
services= $${directory:service}
#################################
# Nginx service
#################################
......@@ -211,6 +212,7 @@ name = PeerTube Server Frontend
# XXX We have hardcoded SR URL here.
software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
slave = true
state = stopped
config-type = websocket
config-websocket-path-list = /socket.io /socket /tracker/socket
config-url = https://[$${nginx-configuration:ip}]:$${nginx-configuration:port}
......@@ -223,33 +225,51 @@ partition = $${slap_connection:partition_id}
url = $${slap_connection:server_url}
key = $${slap_connection:key_file}
cert = $${slap_connection:cert_file}
short_description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.'
description = 'Welcome to this PeerTube instance!'
terms = 'No terms for now.'
[peertube-text-content]
recipe = slapos.recipe.build
slapparameter-dict = $${slap-configuration:configuration}
init =
options['name'] = options['slapparameter-dict'].get('name') or 'Peertube in Slapos'
options['short_description'] = options['slapparameter-dict'].get('short_description') or ''
options['description'] = options['slapparameter-dict'].get('description') or ''
options['terms'] = options['slapparameter-dict'].get('terms') or ''
options['code_of_conduct'] = options['slapparameter-dict'].get('code_of_conduct') or ''
options['moderation_information'] = options['slapparameter-dict'].get('moderation_information') or ''
options['creation_reason'] = options['slapparameter-dict'].get('creation_reason') or ''
options['administrator'] = options['slapparameter-dict'].get('administrator') or ''
options['maintenance_lifetime'] = options['slapparameter-dict'].get('maintenance_lifetime') or ''
options['business_model'] = options['slapparameter-dict'].get('business_model') or ''
options['hardware_information'] = options['slapparameter-dict'].get('hardware_information') or ''
[peertube-urlparse]
[peertube-parameters]
recipe = slapos.recipe.build
slapparameter-dict = $${slap-configuration:configuration}
url = $${publish-connection-parameter:frontend-url}
default-frontend-url = $${frontend:config-url}
working-dir = ${peertube:location}
node-config-dir=$${directory:config}
ipv4-port=9000
node-env=production
npm-bin=${nodejs:location}/bin/npm
default-parameters =
{
"name" : "Peertube in Slapos",
"frontend-url" : "",
"short_description" : "PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.",
"description" : "Welcome to this PeerTube instance!",
"terms" : "No terms for now.",
"code_of_conduct" : "",
"moderation_information" : "",
"creation_reason" : "",
"administrator" : "",
"maintenance_lifetime" : "",
"business_model" : "",
"hardware_information" : ""
}
init =
from six.moves.urllib.parse import urlparse
url = urlparse(options.get('url'))
import json
default_parameters = json.loads(options.get('default-parameters').strip())
default_parameters['frontend-url'] = options['default-frontend-url']
parameters = dict(default_parameters, **options['slapparameter-dict'])
# options is not a dict...
options['name'] = parameters['name']
options['frontend-url'] = parameters['frontend-url']
options['short_description'] = parameters['short_description']
options['description'] = parameters['description']
options['terms'] = parameters['terms']
options['code_of_conduct'] = parameters['code_of_conduct']
options['moderation_information'] = parameters['moderation_information']
options['creation_reason'] = parameters['creation_reason']
options['administrator'] = parameters['administrator']
options['maintenance_lifetime'] = parameters['maintenance_lifetime']
options['business_model'] = parameters['business_model']
options['hardware_information'] = parameters['hardware_information']
url = urlparse(options.get('frontend-url'))
if url.port:
options['host'] = '[' + url.hostname + ']'
options['port'] = str(url.port)
......@@ -259,6 +279,9 @@ init =
[publish-connection-parameter]
recipe = slapos.cookbook:publish
frontend-url = $${frontend:connection-secure_access}
frontend-hostname = $${frontend:connection-domain}
ipv4-port = 9000
frontend-url = $${peertube-parameters:frontend-url}
backend-url = $${frontend:config-url}
password = $${peertube-passwd:passwd}
username = root
......@@ -8,6 +8,7 @@
"software-type": "default",
"description": "Default",
"request": "instance-peertube-input-schema.json",
"response": "instance-peertube-output-schema.json",
"index": 1
}
}
......
......@@ -51,7 +51,7 @@ http {
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
upstream backend {
server $${instance-parameter:ipv4-random}:$${publish-connection-parameter:ipv4-port};
server $${instance-parameter:ipv4-random}:$${peertube-parameters:ipv4-port};
}
server {
......
......@@ -30,5 +30,6 @@ echo "I: PostgreSQL ready." 1>&2
cd ${peertube:location}
exec env NODE_ENV=peertube NODE_CONFIG_DIR=$${directory:config} PATH=${ffmpeg:location}/bin:$PATH\
exec env PT_INITIAL_ROOT_PASSWORD=$${peertube-passwd:passwd} NODE_ENV=peertube\
NODE_CONFIG_DIR=$${directory:config} PATH=${ffmpeg:location}/bin:$PATH\
${nodejs:location}/bin/node ${peertube:location}/dist/server
listen:
hostname: '$${instance-parameter:ipv4-random}'
port: $${publish-connection-parameter:ipv4-port}
port: $${peertube-parameters:ipv4-port}
# Correspond to your reverse proxy server_name/listen configuration (i.e., your public PeerTube instance URL)
webserver:
https: true
hostname: '$${peertube-urlparse:host}'
port: $${peertube-urlparse:port}
hostname: '$${peertube-parameters:host}'
port: $${peertube-parameters:port}
# Secrets you need to generate the first time you run PeerTube
secrets:
......@@ -564,30 +564,30 @@ auto_blacklist:
# Instance settings
instance:
name: '$${peertube-text-content:name}' #'Peertube'
short_description: '$${peertube-text-content:short_description}'
description: '$${peertube-text-content:description}'
terms: '$${peertube-text-content:terms}'
code_of_conduct: '$${peertube-text-content:code_of_conduct}'
name: '$${peertube-parameters:name}' #'Peertube'
short_description: '$${peertube-parameters:short_description}'
description: '$${peertube-parameters:description}'
terms: '$${peertube-parameters:terms}'
code_of_conduct: '$${peertube-parameters:code_of_conduct}'
# Who moderates the instance? What is the policy regarding NSFW videos? Political videos? etc
moderation_information: '$${peertube-text-content:moderation_information}'
moderation_information: '$${peertube-parameters:moderation_information}'
# Why did you create this instance?
creation_reason: '$${peertube-text-content:creation_reason}'
creation_reason: '$${peertube-parameters:creation_reason}'
# Who is behind the instance? A single person? A non profit?
administrator: '$${peertube-text-content:administrator}'
administrator: '$${peertube-parameters:administrator}'
# How long do you plan to maintain this instance?
maintenance_lifetime: '$${peertube-text-content:maintenance_lifetime}'
maintenance_lifetime: '$${peertube-parameters:maintenance_lifetime}'
# How will you pay the PeerTube instance server? With your own funds? With users donations? Advertising?
business_model: '$${peertube-text-content:business_model}'
business_model: '$${peertube-parameters:business_model}'
# If you want to explain on what type of hardware your PeerTube instance runs
# Example: '2 vCore, 2GB RAM...'
hardware_information: '$${peertube-text-content:hardware_information}'
hardware_information: '$${peertube-parameters:hardware_information}'
# What are the main languages of your instance? To interact with your users for example
# Uncomment or add the languages you want
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment