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

peertube: Use template

parent 80ddc397
...@@ -24,6 +24,18 @@ md5sum = 458870b70c33a1621b68961ae2372ad5 ...@@ -24,6 +24,18 @@ md5sum = 458870b70c33a1621b68961ae2372ad5
filename = template-peertube-service.sh.in filename = template-peertube-service.sh.in
# md5sum = 458870b70c33a1621b68961ae2372ad5 # 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] [template-nginx-configuration]
filename = template-nginx.cfg.in filename = template-nginx.cfg.in
# md5sum = 6b11e79bcc7734d8629e1b6e6cb497e1 # md5sum = 6b11e79bcc7734d8629e1b6e6cb497e1
...@@ -8,9 +8,11 @@ parts = ...@@ -8,9 +8,11 @@ parts =
postgresql postgresql
nginx-service nginx-service
nginx-listen-promise nginx-listen-promise
peertube-nginx-available
peertube-nginx-enabled
peertube-default-yaml
peertube-production-yaml
peertube-service peertube-service
peertube-setup
eggs-directory = ${buildout:eggs-directory} eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory} develop-eggs-directory = ${buildout:develop-eggs-directory}
...@@ -23,67 +25,39 @@ srv = $${buildout:directory}/srv ...@@ -23,67 +25,39 @@ srv = $${buildout:directory}/srv
var = $${buildout:directory}/var var = $${buildout:directory}/var
log = $${:var}/log log = $${:var}/log
run = $${:var}/run run = $${:var}/run
www = $${:srv}/www www = $${:var}/www
nginx = $${:etc}/nginx nginx = $${:etc}/nginx
nginx_sites-available = $${:nginx}/sites-available nginx_sites-available = $${:nginx}/sites-available
nginx_sites-enabled = $${:nginx}/sites-enabled nginx_sites-enabled = $${:nginx}/sites-enabled
varnginx = $${:var}/nginx varnginx = $${:var}/nginx
services = $${:etc}/service services = $${:etc}/service
peertube_directory = $${:srv}/var/www/peertube xoxox = $${buildout:directory}/xoxox
config = $${:var}/www/peertube/config wwwx = $${:var}/wwwx
storage = $${:var}/www/peertube/storage peertube_directory = $${:www}/peertube
versions = $${:var}/www/peertube/versions config = $${:peertube_directory}/config
storage = $${:peertube_directory}/storage
versions = $${:peertube_directory}/versions
ssl = $${:etc}/ssl ssl = $${:etc}/ssl
[peertube-setup] [peertube-nginx-available]
recipe = slapos.recipe.build recipe = slapos.recipe.template
peertube_config = $${directory:config} url = ${template-peertube-nginx-available:output}
production_config_template = ${peertube:location}/config/production.yaml.example output = $${directory:nginx_sites-available}/peertube
production_config_prod = $${directory:config}/production.yaml
default_yaml = ${peertube:location}/config/default.yaml [peertube-nginx-enabled]
default_yaml_prod = $${directory:config}/default.yaml recipe = slapos.recipe.template
nginx_sites-available = ${peertube:location}/support/nginx/peertube url = ${template-peertube-nginx-available:output}
nginx_sites-available_prod = $${directory:nginx_sites-available}/peertube output = $${directory:nginx_sites-enabled}/peertube
nginx_sites-enabled_prod = $${directory:nginx_sites-enabled}/peertube
init = [peertube-default-yaml]
import shutil, os recipe = slapos.recipe.template
shutil.copyfile(options['default_yaml'], options['default_yaml_prod']) url = ${template-peertube-default:output}
output = $${directory:config}/default.yaml
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: [peertube-production-yaml]
for line in example_file: recipe = slapos.recipe.template
if "WEBSERVER_HOST" in line: url = ${template-peertube-production:output}
line = line.replace('$', '') output = $${directory:config}/production.yaml
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-service] [peertube-service]
recipe = slapos.recipe.template recipe = slapos.recipe.template
......
...@@ -53,7 +53,6 @@ parts = ...@@ -53,7 +53,6 @@ parts =
peertube peertube
peertube-build peertube-build
instance-profile instance-profile
# postgresql-setup
[nodejs] [nodejs]
<= nodejs-16.13.2 <= nodejs-16.13.2
...@@ -67,7 +66,7 @@ md5sum = 1c9639748d66e8c49fc27e4705f87622 ...@@ -67,7 +66,7 @@ md5sum = 1c9639748d66e8c49fc27e4705f87622
recipe = slapos.recipe.cmmi recipe = slapos.recipe.cmmi
path = ${peertube:location} path = ${peertube:location}
environment = 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 CPPFLAGS=-I${openssl:location}/include
LDFLAGS=-L${curl:location}/lib -Wl,-rpath -Wl,${openssl:location}/lib -Wl,-rpath -Wl LDFLAGS=-L${curl:location}/lib -Wl,-rpath -Wl,${openssl:location}/lib -Wl,-rpath -Wl
pre-configure = pre-configure =
...@@ -75,6 +74,11 @@ pre-configure = ...@@ -75,6 +74,11 @@ pre-configure =
configure-command = true configure-command = true
make-binary = cd ${peertube:location} && ${yarn:location}/bin/yarn 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] [instance-profile]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename} url = ${:_profile_base_location_}/${:filename}
...@@ -85,6 +89,21 @@ recipe = slapos.recipe.template ...@@ -85,6 +89,21 @@ recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename} url = ${:_profile_base_location_}/${:filename}
output = ${buildout:directory}/${: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] [template-nginx-service]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename} 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 ...@@ -34,5 +34,5 @@ echo "I: PostgreSQL ready." 1>&2
# make sure unaccent extension is enabled for peertube db # 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" # $${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 ${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