bundles/infobeamer-cms: config is toml now, deploy to src/
All checks were successful
kunsi/bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2021-12-24 15:28:36 +01:00
parent b39d87f33f
commit 6292dd4c71
Signed by: kunsi
GPG key ID: 12E3D2136B818350
7 changed files with 117 additions and 279 deletions

View file

@ -7,4 +7,4 @@ Requires=infobeamer-cms.service
User=infobeamer-cms User=infobeamer-cms
Group=infobeamer-cms Group=infobeamer-cms
WorkingDirectory=/opt/infobeamer-cms WorkingDirectory=/opt/infobeamer-cms
ExecStart=curl -s -H "Host: infobeamer-cms.c3voc.de" http://127.0.0.1:8000/sync ExecStart=curl -s -H "Host: ${domain}" http://127.0.0.1:8000/sync

View file

@ -4,15 +4,15 @@ After=network.target
[Service] [Service]
Type=exec Type=exec
Environment=SETTINGS=settings.cfg Environment=SETTINGS=/opt/infobeamer-cms/settings.toml
Restart=always Restart=always
RestartSec=5s RestartSec=5s
ExecStart=/usr/bin/gunicorn frontend:app -b 127.0.0.1:${PORT} -w ${WORKERS} -t 120 -k gevent --max-requests=1000 ExecStart=/opt/infobeamer-cms/venv/bin/gunicorn frontend:app -b 127.0.0.1:8000 -w ${workers} -t 120 -k gevent --max-requests=1000
# You may have to adjust these settings # You may have to adjust these settings
User=infobeamer-cms User=infobeamer-cms
Group=infobeamer-cms Group=infobeamer-cms
WorkingDirectory=/opt/infobeamer-cms WorkingDirectory=/opt/infobeamer-cms/src
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -1,64 +0,0 @@
<%
from json import dumps
%>
# This github OAuth client will be used for authentication. Create
# one at https://github.com/organizations/ACCOUNT/settings/applications
GITHUB_CLIENT_ID = '${GITHUB_CLIENT_ID}'
GITHUB_CLIENT_SECRET = '${GITHUB_CLIENT_SECRET}'
SESSION_COOKIE_NAME = '${SESSION_COOKIE_NAME}'
PREFERRED_URL_SCHEME = '${PREFERRED_URL_SCHEME}'
# info-beamer API keys.
# This key needs access to setups and assets as well as the
# node-message calls. If you consider the host running this
# code trusted, you might use a key with full account access.
# The keys given out to users are adhoc keys based on this key.
HOSTED_API_KEY = '${HOSTED_API_KEY}'
# Maximum uploads per github user
MAX_UPLOADS = ${MAX_UPLOADS}
# Setup IDs using the scheduled player setup. One of the
# playlists must be named 'User Content'. Its pages will be
# autogenerated by the CMS when calling /sync
SETUP_IDS = ${SETUP_IDS}
# Generate some random string. It's used for signing
# urls send to moderators.
URL_KEY = b'${URL_KEY}'
# Push notifications for moderation requests to an mqtt server.
MQTT_SERVER = 'mqtt.c3voc.de'
MQTT_USERNAME = '${MQTT_USERNAME}'
MQTT_PASSWORD = '${MQTT_PASSWORD}'
MQTT_TOPIC = '/voc/alert'
MQTT_MESSAGE = '{{"level":"info","component":"infobeamer-cms","msg":"{asset} uploaded by {user}. Check it at {url}"}}'
# Unix timestamp allows for specifying start/end time
# of uploaded content
TIME_MIN = ${TIME_MIN}
TIME_MAX = ${TIME_MAX}
# change this to invalidate cached static files.
VERSION = ${VERSION}
# extra assets. If this is empty, only the uploaded content and a notice
# on where to find the CMS will be shown. You can use this to overlay
# content on top of that content.
EXTRA_ASSETS = [
{
"type": "image",
"asset": 828107, # fairydust
# bottom left, 10px from border
"x1":10,
"y1":1070-66,
"x2":10+100,
"y2":1070,
}
]
# rooms. This is both used for the /last view as well
# as the interruption control on /interrupt.
ROOMS = ${dumps(node.metadata.get('infobeamer-cms/config/ROOMS', {}))}

View file

@ -0,0 +1,4 @@
<%
from tomlkit import dumps as toml_dumps
from bundlewrap.utils.text import toml_clean
%>${toml_clean(toml_dumps(repo.libs.faults.resolve_faults(config), sort_keys=True))}

View file

@ -1,34 +1,73 @@
actions = { actions = {
'infobeamer-cms_set_directory_permissions': { 'infobeamer-cms_set_directory_permissions': {
'triggered': True, 'triggered': True,
'command': 'chown -R infobeamer-cms:infobeamer-cms /opt/infobeamer-cms/static/' 'command': 'chown -R infobeamer-cms:infobeamer-cms /opt/infobeamer-cms/src/static/'
},
'infobeamer-cms_create_virtualenv': {
'command': '/usr/bin/python3 -m virtualenv -p python3 /opt/infobeamer-cms/venv/',
'unless': 'test -d /opt/infobeamer-cms/venv/',
'needs': {
# actually /opt/infobeamer-cms, but we don't create that
'directory:/opt/infobeamer-cms/src',
},
},
'infobeamer-cms_install_requirements': {
'command': 'cd /opt/infobeamer-cms/src && /opt/infobeamer-cms/venv/bin/pip install --upgrade pip gunicorn -r requirements.txt',
'needs': {
'action:infobeamer-cms_create_virtualenv',
},
'triggered': True,
}, },
} }
git_deploy = { git_deploy = {
'/opt/infobeamer-cms': { '/opt/infobeamer-cms/src': {
'rev': 'master', 'rev': 'master',
'repo': 'https://github.com/sophieschi/36c3-cms.git', 'repo': 'https://github.com/sophieschi/36c3-cms.git',
'needs': { 'needs': {
'directory:/opt/infobeamer-cms', 'directory:/opt/infobeamer-cms/src',
}, },
'triggers': { 'triggers': {
'svc_systemd:infobeamer-cms:restart', 'svc_systemd:infobeamer-cms:restart',
'action:infobeamer-cms_set_directory_permissions', 'action:infobeamer-cms_set_directory_permissions',
'action:infobeamer-cms_install_requirements',
}, },
}, },
} }
directories = { directories = {
'/opt/infobeamer-cms': {}, '/opt/infobeamer-cms/src': {},
} }
config = node.metadata.get('infobeamer-cms/config', {})
config['ROOMS'] = []
interrupts = []
for name, data in sorted(node.metadata.get('infobeamer-cms/interrupts', {}).items()):
interrupts.append({
'name': name,
'data': data,
})
if interrupts:
interrupts_dict = {
'interrupts': interrupts,
}
else:
interrupts_dict = {}
for room, device_id in sorted(node.metadata.get('infobeamer-cms/rooms', {}).items()):
config['ROOMS'].append({
'name': room,
'device_id': device_id,
**interrupts_dict,
})
files = { files = {
'/opt/infobeamer-cms/settings.cfg': { '/opt/infobeamer-cms/settings.toml': {
'content_type': 'mako', 'content_type': 'mako',
'context': node.metadata.get('infobeamer-cms/config'), 'context': {
'needs': { 'config': config,
'git_deploy:/opt/infobeamer-cms',
}, },
'triggers': { 'triggers': {
'svc_systemd:infobeamer-cms:restart', 'svc_systemd:infobeamer-cms:restart',
@ -36,7 +75,7 @@ files = {
}, },
'/etc/systemd/system/infobeamer-cms.service': { '/etc/systemd/system/infobeamer-cms.service': {
'content_type': 'mako', 'content_type': 'mako',
'context': node.metadata.get('infobeamer-cms/config'), 'context': node.metadata.get('infobeamer-cms'),
'triggers': { 'triggers': {
'action:systemd-reload', 'action:systemd-reload',
'svc_systemd:infobeamer-cms:restart', 'svc_systemd:infobeamer-cms:restart',
@ -49,6 +88,8 @@ files = {
}, },
}, },
'/etc/systemd/system/infobeamer-cms-runperiodic.service': { '/etc/systemd/system/infobeamer-cms-runperiodic.service': {
'content_type': 'mako',
'context': node.metadata.get('infobeamer-cms'),
'triggers': { 'triggers': {
'action:systemd-reload', 'action:systemd-reload',
}, },
@ -58,7 +99,7 @@ files = {
pkg_pip = { pkg_pip = {
'github-flask': { 'github-flask': {
'needed_by': { 'needed_by': {
'git_deploy:/opt/infobeamer-cms', 'svc_systemd:infobeamer-cms',
}, },
}, },
} }
@ -66,9 +107,11 @@ pkg_pip = {
svc_systemd = { svc_systemd = {
'infobeamer-cms': { 'infobeamer-cms': {
'needs': { 'needs': {
'file:/opt/infobeamer-cms/settings.cfg', 'action:infobeamer-cms_install_requirements',
'action:infobeamer-cms_set_directory_permissions',
'file:/etc/systemd/system/infobeamer-cms.service', 'file:/etc/systemd/system/infobeamer-cms.service',
'git_deploy:/opt/infobeamer-cms', 'file:/opt/infobeamer-cms/settings.toml',
'git_deploy:/opt/infobeamer-cms/src',
}, },
}, },
'infobeamer-cms-runperiodic.timer': { 'infobeamer-cms-runperiodic.timer': {

View file

@ -1,17 +1,4 @@
defaults = { defaults = {
'apt': {
'packages': {
'gunicorn': {},
'python3-gevent': {},
'python3-flask': {},
'python3-jinja2': {},
'python3-redis': {},
'python3-oauth2client': {},
'python3-virtualenv': {},
'python3-requests': {},
'python3-iso8601': {},
},
},
'infobeamer-cms': { 'infobeamer-cms': {
'config': { 'config': {
'GITHUB_CLIENT_ID': repo.vault.decrypt('encrypt$gAAAAABhxJT3JG3Qb1X-gjtBxwOXZmF-GVPjNbDkYo0Eke5Ly4CAKiussQ8Lld-4zoIWnIVBgndfPPGFDV2RlAHgb-_RY5r7jQcAlgsR0RUw4as0jEhiKlQ='), 'GITHUB_CLIENT_ID': repo.vault.decrypt('encrypt$gAAAAABhxJT3JG3Qb1X-gjtBxwOXZmF-GVPjNbDkYo0Eke5Ly4CAKiussQ8Lld-4zoIWnIVBgndfPPGFDV2RlAHgb-_RY5r7jQcAlgsR0RUw4as0jEhiKlQ='),
@ -20,170 +7,48 @@ defaults = {
'PREFERRED_URL_SCHEME': 'https', 'PREFERRED_URL_SCHEME': 'https',
'HOSTED_API_KEY': repo.vault.decrypt('encrypt$gAAAAABhxJPH2sIGMAibU2Us1HoCVlNfF0SQQnVl0eiod48Zu8webL_-xk3wDw3yXw1Hkglj-2usl-D3Yd095yTSq0vZMCv2fh-JWwSPdJewQ45x9Ai4vXVD4CNz5vuJBESKS9xQWXTc'), 'HOSTED_API_KEY': repo.vault.decrypt('encrypt$gAAAAABhxJPH2sIGMAibU2Us1HoCVlNfF0SQQnVl0eiod48Zu8webL_-xk3wDw3yXw1Hkglj-2usl-D3Yd095yTSq0vZMCv2fh-JWwSPdJewQ45x9Ai4vXVD4CNz5vuJBESKS9xQWXTc'),
'MAX_UPLOADS': 5, 'MAX_UPLOADS': 5,
'SETUP_IDS': '[212947]', 'SETUP_IDS': [
212947,
],
'URL_KEY': repo.vault.password_for(f'{node.name} infobeamer-cms url key'), 'URL_KEY': repo.vault.password_for(f'{node.name} infobeamer-cms url key'),
'MQTT_SERVER': 'mqtt.c3voc.de',
'MQTT_USERNAME': repo.vault.decrypt('encrypt$gAAAAABhxakKHC_kHmHP2mFHorb4niuNTH4F24w1D6m5JUxl117N7znlZA6fpMmY3_NcmBr2Ihw4hL3FjZr9Fm_1oUZ1ZQdADA=='), 'MQTT_USERNAME': repo.vault.decrypt('encrypt$gAAAAABhxakKHC_kHmHP2mFHorb4niuNTH4F24w1D6m5JUxl117N7znlZA6fpMmY3_NcmBr2Ihw4hL3FjZr9Fm_1oUZ1ZQdADA=='),
'MQTT_PASSWORD': repo.vault.decrypt('encrypt$gAAAAABhxakfhhwWn0vxhoO1FiMEpdCkomWvo0dHIuBrqDKav8WDpI6dXpb0hoXiWRsPV6p5m-8RlbfFbjPhz47AY-nFOOAAW6Yis3-IVD-U-InKJo9dvms='), 'MQTT_PASSWORD': repo.vault.decrypt('encrypt$gAAAAABhxakfhhwWn0vxhoO1FiMEpdCkomWvo0dHIuBrqDKav8WDpI6dXpb0hoXiWRsPV6p5m-8RlbfFbjPhz47AY-nFOOAAW6Yis3-IVD-U-InKJo9dvms='),
'MQTT_TOPIC': '/voc/alert',
'MQTT_MESSAGE': '{{"level":"info","component":"infobeamer-cms","msg":"{asset} uploaded by {user}. Check it at {url}"}}',
'TIME_MIN': 1640039559,
'TIME_MIN': 1640559600, 'TIME_MIN': 1640559600,
'TIME_MAX': 1640905200, 'TIME_MAX': 1640905200,
'VERSION': 1, 'VERSION': 1,
'ROOMS': [ 'EXTRA_ASSETS': [{
{ 'type': "image",
'name': 'Chaos-West TV', 'asset': 828107, # fairydust
'device_id': 17968, # bottom left, 10px from border
'interrupts': [ 'x1': 10,
{ 'y1': 1004,
'name': 'Signal', 'x2': 110,
'data': 'signal', 'y2': 1070,
}, }],
],
},
{
'name': 'Chaosstudio Hamburg',
'device_id': 3284,
'interrupts': [
{
'name': 'Signal',
'data': 'signal',
},
],
},
{
'name': 'ChaosZone TV',
'device_id': 3,
'interrupts': [
{
'name': 'Signal',
'data': 'signal',
},
],
},
{
'name': 'r3s - Monheim/Rhein',
'device_id': 22460,
'interrupts': [
{
'name': 'Signal',
'data': 'signal',
},
],
},
{
'name': 'franconian.net Livestream',
'device_id': 246100657,
'interrupts': [
{
'name': 'Signal',
'data': 'signal',
},
],
},
{
'name': 'about:future stage',
'device_id': 246100658,
'interrupts': [
{
'name': 'Signal',
'data': 'signal',
},
],
},
{
'name': 'Sendezentrum Bühne',
'device_id': 246100659,
'interrupts': [
{
'name': 'Signal',
'data': 'signal',
},
],
},
{
'name': 'Haecksen Stream',
'device_id': 246100660,
'interrupts': [
{
'name': 'Signal',
'data': 'signal',
},
],
},
{
'name': 'xHain Mainhall',
'device_id': 246100661,
'interrupts': [
{
'name': 'Signal',
'data': 'signal',
},
],
},
{
'name': 'xHain Workshop-Area',
'device_id': 246100662,
'interrupts': [
{
'name': 'Signal',
'data': 'signal',
},
],
},
{
'name': 'c-base',
'device_id': 246100663,
'interrupts': [
{
'name': 'Signal',
'data': 'signal',
},
],
},
{
'name': 'about:future Kitchen',
'device_id': 246100664,
'interrupts': [
{
'name': 'Signal',
'data': 'signal',
},
],
},
{
'name': 'Haecksen Zur schönen Mary',
'device_id': 246100665,
'interrupts': [
{
'name': 'Signal',
'data': 'signal',
},
],
},
{
'name': 'Haecksen Zur magischen Margaret',
'device_id': 246100666,
'interrupts': [
{
'name': 'Signal',
'data': 'signal',
},
],
},
{
'name': 'infobeamer stream',
'device_id': 15586,
'interrupts': [
{
'name': 'Signal',
'data': 'signal',
},
],
},
],
'PORT': 8000,
'WORKERS': 4,
'unused': 'foobar',
}, },
'domain': 'infobeamer-cms.c3voc.de',
'rooms': {
'Chaos-West TV': 17968,
'Chaosstudio Hamburg': 3284,
'ChaosZone TV': 3,
'r3s - Monheim/Rhein': 22460,
'franconian.net Livestream': 246100657,
'about:future stage': 246100658,
'Sendezentrum Bühne': 246100659,
'Haecksen Stream': 246100660,
'xHain Mainhall': 246100661,
'xHain Workshop-Area': 246100662,
'c-base': 246100663,
'about:future Kitchen': 246100664,
'Haecksen Zur schönen Mary': 246100665,
'Haecksen Zur magischen Margaret': 246100666,
'infobeamer stream': 15586,
},
'workers': 4,
}, },
} }
@ -194,29 +59,26 @@ def nginx(metadata):
if not node.has_bundle('nginx'): if not node.has_bundle('nginx'):
raise DoNotRunAgain raise DoNotRunAgain
locations = {
'/': {
'target': 'http://127.0.0.1:8000',
},
'/sync': {
'return': 'forbidden',
'mode': 403,
},
'/static': {
'alias': '/opt/infobeamer-cms/static',
},
}
vhosts = {
'infobeamer-cms': {
'locations': locations,
'website_check_path': '/',
'website_check_string': '',
},
}
return { return {
'nginx': { 'nginx': {
'vhosts': vhosts 'vhosts': {
'infobeamer-cms': {
'domain': node.metadata.get('infobeamer-cms/domain'),
'locations': {
'/': {
'target': 'http://127.0.0.1:8000',
},
'/sync': {
'return': 'forbidden',
'mode': 403,
},
'/static': {
'alias': '/opt/infobeamer-cms/src/static',
},
},
'website_check_path': '/',
'website_check_string': 'Share your projects',
},
},
}, },
} }

View file

@ -32,12 +32,5 @@ nodes['voc.infobeamer-cms'] = {
'icinga_options': { 'icinga_options': {
'pretty_name': 'infobeamer-cms.c3voc.de', 'pretty_name': 'infobeamer-cms.c3voc.de',
}, },
'nginx': {
'vhosts': {
'infobeamer-cms': {
'domain': 'infobeamer-cms.c3voc.de',
},
},
},
}, },
} }