#!/bin/sh # TODO: check if matrix-synapse package is installed (fail if not - it's not # this type's job to install it). name=$__object_id os=$(cat "$__global/explorer/os") case "$os" in debian) synapse_conf_dir='/etc/synapse' synapse_workers_conf_dir="$synapse_conf_dir/workers" # Synapse log configuration on debian - default value of config-log # parameter. WORKER_LOG_CONFIG="$synapse_conf_dir/log.yaml" # As of writing, debian's matrix-synapse package does not install the # matrix-synapse-worker@.service systemd unit. systemd_worker_service_override=present systemd_worker_service="matrix-synapse-worker@$name" ;; *) printf "Your operating system (%s) is currently not supported by this type (%s)\n" "$os" "${__type##*/}" >&2 printf "Please contribute an implementation for it if you can.\n" >&2 exit 1 ;; esac # Type parameters. WORKER_NAME=$__object_id WORKER_APP=$(cat "$__object/parameter/app") WORKER_PORT=$(cat "$__object/parameter/port") WORKER_RESOURCES=$(cat "$__object/parameter/resource") export WORKER_APP WORKER_NAME WORKER_PORT if [ -f "$__object/parameter/log-config" ]; then WORKER_LOG_CONFIG=$(cat "$__object/parameter/log-config") fi export WORKER_LOG_CONFIG WORKER_REPLICATION_HOST=$(cat "$__object/parameter/replication-host") WORKER_REPLICATION_PORT=$(cat "$__object/parameter/replication-port") export WORKER_REPLICATION_HOST WORKER_REPLICATION_PORT # Generate and deploy configuration files. mkdir -p "$__object/files" "$__type/files/worker.yaml.sh" > "$__object/files/worker.yaml" __directory "$synapse_workers_conf_dir" --parents require="__directory/$synapse_workers_conf_dir" \ __file "$synapse_workers_conf_dir/$name.yaml" \ --source "$__object/files/worker.yaml" \ --mode 0644 __file "/etc/systemd/systemd/matrix-synapse-worker@.service" \ --source "$__type/files/matrix-synapse-worker@.service" \ --mode 0644 \ --state $systemd_worker_service_override # Start service, enable at boot. require="__file/$synapse_workers_conf_dir/$name.yaml \ __file/etc/systemd/systemd/matrix-synapse-worker@.service" \ __service "$systemd_worker_service" --action start require="__service/$systemd_worker_service" \ __start_on_boot "$systemd_worker_service"