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

peertube: parameter mechanism update

parent cd8f7c43
Pipeline #24770 passed with stage
in 0 seconds
...@@ -4,6 +4,12 @@ ...@@ -4,6 +4,12 @@
"description": "Parameters to instantiate Peertube", "description": "Parameters to instantiate Peertube",
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"fronted-url": {
"title": "Frontend URL",
"description": "Frontend URL",
"default": "",
"type": "string"
},
"name": { "name": {
"title": "Instance Title", "title": "Instance Title",
"description": "The name of your peertube instance.", "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 = ...@@ -10,7 +10,7 @@ parts =
nginx-service nginx-service
peertube-service peertube-service
publish-connection-parameter publish-connection-parameter
peertube-urlparse peertube-parameters
dcron-service dcron-service
activate-crontab-file activate-crontab-file
peertube-backup-cron peertube-backup-cron
...@@ -45,6 +45,12 @@ storage = $${:peertube_directory}/storage ...@@ -45,6 +45,12 @@ storage = $${:peertube_directory}/storage
versions = $${:peertube_directory}/versions versions = $${:peertube_directory}/versions
ssl = $${:etc}/ssl ssl = $${:etc}/ssl
[peertube-passwd]
recipe = slapos.cookbook:generate.password
storage-path = $${directory:etc}/.peertube_user
bytes = 8
username = root
[peertube-yaml] [peertube-yaml]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${template-peertube:output} url = ${template-peertube:output}
...@@ -79,11 +85,6 @@ ipv4 = $${instance-parameter:ipv4-random} ...@@ -79,11 +85,6 @@ ipv4 = $${instance-parameter:ipv4-random}
ipv6 = ipv6 =
port = 5432 port = 5432
[service-postgresql]
recipe = slapos.cookbook:postgres
bin = ${postgresql10:location}/bin
services= $${directory:service}
################################# #################################
# Nginx service # Nginx service
################################# #################################
...@@ -211,6 +212,7 @@ name = PeerTube Server Frontend ...@@ -211,6 +212,7 @@ name = PeerTube Server Frontend
# XXX We have hardcoded SR URL here. # XXX We have hardcoded SR URL here.
software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
slave = true slave = true
state = stopped
config-type = websocket config-type = websocket
config-websocket-path-list = /socket.io /socket /tracker/socket config-websocket-path-list = /socket.io /socket /tracker/socket
config-url = https://[$${nginx-configuration:ip}]:$${nginx-configuration:port} config-url = https://[$${nginx-configuration:ip}]:$${nginx-configuration:port}
...@@ -223,33 +225,51 @@ partition = $${slap_connection:partition_id} ...@@ -223,33 +225,51 @@ partition = $${slap_connection:partition_id}
url = $${slap_connection:server_url} url = $${slap_connection:server_url}
key = $${slap_connection:key_file} key = $${slap_connection:key_file}
cert = $${slap_connection:cert_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 recipe = slapos.recipe.build
slapparameter-dict = $${slap-configuration:configuration} 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 = init =
from six.moves.urllib.parse import urlparse 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: if url.port:
options['host'] = '[' + url.hostname + ']' options['host'] = '[' + url.hostname + ']'
options['port'] = str(url.port) options['port'] = str(url.port)
...@@ -259,6 +279,9 @@ init = ...@@ -259,6 +279,9 @@ init =
[publish-connection-parameter] [publish-connection-parameter]
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish
frontend-url = $${frontend:connection-secure_access}
frontend-hostname = $${frontend:connection-domain} 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 @@ ...@@ -8,6 +8,7 @@
"software-type": "default", "software-type": "default",
"description": "Default", "description": "Default",
"request": "instance-peertube-input-schema.json", "request": "instance-peertube-input-schema.json",
"response": "instance-peertube-output-schema.json",
"index": 1 "index": 1
} }
} }
......
...@@ -51,7 +51,7 @@ http { ...@@ -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; gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
upstream backend { upstream backend {
server $${instance-parameter:ipv4-random}:$${publish-connection-parameter:ipv4-port}; server $${instance-parameter:ipv4-random}:$${peertube-parameters:ipv4-port};
} }
server { server {
......
...@@ -30,5 +30,6 @@ echo "I: PostgreSQL ready." 1>&2 ...@@ -30,5 +30,6 @@ echo "I: PostgreSQL ready." 1>&2
cd ${peertube:location} 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 ${nodejs:location}/bin/node ${peertube:location}/dist/server
listen: listen:
hostname: '$${instance-parameter:ipv4-random}' 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) # Correspond to your reverse proxy server_name/listen configuration (i.e., your public PeerTube instance URL)
webserver: webserver:
https: true https: true
hostname: '$${peertube-urlparse:host}' hostname: '$${peertube-parameters:host}'
port: $${peertube-urlparse:port} port: $${peertube-parameters:port}
# Secrets you need to generate the first time you run PeerTube # Secrets you need to generate the first time you run PeerTube
secrets: secrets:
...@@ -564,30 +564,30 @@ auto_blacklist: ...@@ -564,30 +564,30 @@ auto_blacklist:
# Instance settings # Instance settings
instance: instance:
name: '$${peertube-text-content:name}' #'Peertube' name: '$${peertube-parameters:name}' #'Peertube'
short_description: '$${peertube-text-content:short_description}' short_description: '$${peertube-parameters:short_description}'
description: '$${peertube-text-content:description}' description: '$${peertube-parameters:description}'
terms: '$${peertube-text-content:terms}' terms: '$${peertube-parameters:terms}'
code_of_conduct: '$${peertube-text-content:code_of_conduct}' code_of_conduct: '$${peertube-parameters:code_of_conduct}'
# Who moderates the instance? What is the policy regarding NSFW videos? Political videos? etc # 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? # 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? # 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? # 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? # 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 # If you want to explain on what type of hardware your PeerTube instance runs
# Example: '2 vCore, 2GB RAM...' # 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 # What are the main languages of your instance? To interact with your users for example
# Uncomment or add the languages you want # 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