Commit 3834566e authored by Boxiang Sun's avatar Boxiang Sun

peertube: Use template

parent 80ddc397
......@@ -24,6 +24,18 @@ md5sum = 458870b70c33a1621b68961ae2372ad5
filename = template-peertube-service.sh.in
# md5sum = 458870b70c33a1621b68961ae2372ad5
[template-peertube-production]
filename = template-peertube-production.yaml.in
# md5sum = 458870b70c33a1621b68961ae2372ad5
[template-peertube-nginx-available]
filename = template-peertube-nginx-available.in
# md5sum = 458870b70c33a1621b68961ae2372ad5
[template-peertube-default]
filename = template-peertube-default.yaml.in
# md5sum = 458870b70c33a1621b68961ae2372ad5
[template-nginx-configuration]
filename = template-nginx.cfg.in
# md5sum = 6b11e79bcc7734d8629e1b6e6cb497e1
......@@ -8,9 +8,11 @@ parts =
postgresql
nginx-service
nginx-listen-promise
peertube-nginx-available
peertube-nginx-enabled
peertube-default-yaml
peertube-production-yaml
peertube-service
peertube-setup
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
......@@ -23,67 +25,39 @@ srv = $${buildout:directory}/srv
var = $${buildout:directory}/var
log = $${:var}/log
run = $${:var}/run
www = $${:srv}/www
www = $${:var}/www
nginx = $${:etc}/nginx
nginx_sites-available = $${:nginx}/sites-available
nginx_sites-enabled = $${:nginx}/sites-enabled
varnginx = $${:var}/nginx
services = $${:etc}/service
peertube_directory = $${:srv}/var/www/peertube
config = $${:var}/www/peertube/config
storage = $${:var}/www/peertube/storage
versions = $${:var}/www/peertube/versions
xoxox = $${buildout:directory}/xoxox
wwwx = $${:var}/wwwx
peertube_directory = $${:www}/peertube
config = $${:peertube_directory}/config
storage = $${:peertube_directory}/storage
versions = $${:peertube_directory}/versions
ssl = $${:etc}/ssl
[peertube-setup]
recipe = slapos.recipe.build
peertube_config = $${directory:config}
production_config_template = ${peertube:location}/config/production.yaml.example
production_config_prod = $${directory:config}/production.yaml
default_yaml = ${peertube:location}/config/default.yaml
default_yaml_prod = $${directory:config}/default.yaml
nginx_sites-available = ${peertube:location}/support/nginx/peertube
nginx_sites-available_prod = $${directory:nginx_sites-available}/peertube
nginx_sites-enabled_prod = $${directory:nginx_sites-enabled}/peertube
init =
import shutil, os
shutil.copyfile(options['default_yaml'], options['default_yaml_prod'])
with open(options['nginx_sites-available'], "r", encoding='utf-8') as example_file:
with open(options['nginx_sites-available_prod'], "w", encoding='utf-8') as prod_file:
for line in example_file:
if "WEBSERVER_HOST" in line:
line = line.replace('$', '')
line = line.replace("{WEBSERVER_HOST}", "https://[$${nginx-configuration:ip}]/$${nginx-configuration:port}")
if "{PEERTUBE_HOST}" in line:
line = line.replace('$', '')
line = line.replace("{PEERTUBE_HOST}", "127.0.0.1:9000")
if "ssl_certificate" in line:
line = ''
prod_file.write(line)
if not os.path.exists(options['nginx_sites-enabled_prod']):
os.symlink(options['nginx_sites-available_prod'], options['nginx_sites-enabled_prod'])
with open(options['production_config_template'], "r", encoding='utf-8') as config_template_file:
with open(options['production_config_prod'], "w", encoding='utf-8') as config_prod_file:
local_host_counter = 0
for line in config_template_file:
if "hostname: 'example.com'" in line:
line = line.replace("example.com", "https://[$${nginx-configuration:ip}]/$${nginx-configuration:port}")
elif "password: 'peertube'" in line:
line = line.replace("peertube", "$${postgresql:password}")
elif "hostname: 'localhost'" in line:
local_host_counter += 1
if local_host_counter == 2:
line = line.replace("localhost", "$${postgresql:ipv4}")
if local_host_counter == 3:
line = '' # set 'hostname' and 'port' to null, use redis.socket
elif "6379" in line:
line = line.replace("port: 6379", "unixsocket: $${service-redis:unixsocket}") # set 'hostname' and 'port' to null, use redis.socket
elif "/var/www/peertube" in line:
line = line.replace("/var/www/peertube", "$${directory:peertube_directory}")
config_prod_file.write(line)
[peertube-nginx-available]
recipe = slapos.recipe.template
url = ${template-peertube-nginx-available:output}
output = $${directory:nginx_sites-available}/peertube
[peertube-nginx-enabled]
recipe = slapos.recipe.template
url = ${template-peertube-nginx-available:output}
output = $${directory:nginx_sites-enabled}/peertube
[peertube-default-yaml]
recipe = slapos.recipe.template
url = ${template-peertube-default:output}
output = $${directory:config}/default.yaml
[peertube-production-yaml]
recipe = slapos.recipe.template
url = ${template-peertube-production:output}
output = $${directory:config}/production.yaml
[peertube-service]
recipe = slapos.recipe.template
......
......@@ -53,7 +53,6 @@ parts =
peertube
peertube-build
instance-profile
# postgresql-setup
[nodejs]
<= nodejs-16.13.2
......@@ -67,7 +66,7 @@ md5sum = 1c9639748d66e8c49fc27e4705f87622
recipe = slapos.recipe.cmmi
path = ${peertube:location}
environment =
PATH=${unzip:location}/bin:${vim:location}/bin:${nodejs:location}/bin:${yarn:location}/bin:${python3:location}/bin:${nginx:location}/sbin:${postgresql:location}/sbin:${gcc-10.2:location}/bin:${redis:location}/bin:{git:location}/bin:{wget:location}/bin:%(PATH)s
PATH=${unzip:location}/bin:${vim:location}/bin:${nodejs:location}/bin:${yarn:location}/bin:${python3:location}/bin:${nginx:location}/sbin:${postgresql10:location}/bin:${gcc-10.2:location}/bin:${redis:location}/bin:{git:location}/bin:{wget:location}/bin:%(PATH)s
CPPFLAGS=-I${openssl:location}/include
LDFLAGS=-L${curl:location}/lib -Wl,-rpath -Wl,${openssl:location}/lib -Wl,-rpath -Wl
pre-configure =
......@@ -75,6 +74,11 @@ pre-configure =
configure-command = true
make-binary = cd ${peertube:location} && ${yarn:location}/bin/yarn
[peertube-postgresql-setup.in]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_update_hash_filename_}
destination = ${buildout:directory}/${:_buildout_section_name_}
[instance-profile]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename}
......@@ -85,6 +89,21 @@ recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename}
output = ${buildout:directory}/${:filename}
[template-peertube-production]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename}
output = ${buildout:directory}/${:filename}
[template-peertube-default]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename}
output = ${buildout:directory}/${:filename}
[template-peertube-nginx-available]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename}
output = ${buildout:directory}/${:filename}
[template-nginx-service]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -34,5 +34,5 @@ echo "I: PostgreSQL ready." 1>&2
# make sure unaccent extension is enabled for peertube db
# $${postgresql:bin}/psql -c 'CREATE EXTENSION IF NOT EXISTS unaccent;' $${postgresql:dbname} || die "unaccent setup failed"
exec env NODE_ENV=production NODE_CONFIG_DIR=$${peertube-setup:peertube_config} PATH=${ffmpeg:location}/bin:$PATH\
exec env NODE_ENV=production NODE_CONFIG_DIR=$${directory:config} PATH=${ffmpeg:location}/bin:$PATH\
${nodejs:location}/bin/node ${peertube:location}/dist/server
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