diff --git a/snap/hooks/configure b/snap/hooks/configure new file mode 100644 index 00000000..9e9d75b5 --- /dev/null +++ b/snap/hooks/configure @@ -0,0 +1,31 @@ +#!/bin/sh + +base_url="$(snapctl get base-url)" +enabled="$(snapctl get enabled)" + +if [ -n ${enabled} -a \( "${enabled}" != "true" -a "${enabled}" != "false" \) ] +then + echo "Invalid 'enabled' setting: ${enabled}. Valid values are 'true' or 'false'" + exit 1 +fi + +if [ -n ${base_url} -a \( -z "${enabled}" -o "${enabled}" = "false" \) ] +then + echo "All required configuration available." + echo "Conduit can now be enabled by setting 'snap set conduit enabled=true' and restarting the service \ +with 'snap restart conduit'" +fi + +federation_enabled=$(snapctl get federation) +if [ -n ${federation_enabled} -a \( "${federation_enabled}" != "true" -a "${federation_enabled}" != "false" \) ] +then + echo "Invalid 'federation' setting: ${federation_enabled}. Valid values are 'true' or 'false'" +fi + +registration_enabled=$(snapctl get registration) +if [ -n ${registration_enabled} -a \( "${registration_enabled}" != "true" -a "${registration_enabled}" != "false" \) ] +then + echo "Invalid 'registration' setting: ${registration_enabled}. Valid values are 'true' or 'false'" +fi + +exit 0 diff --git a/snap/local/set-environment b/snap/local/set-environment new file mode 100755 index 00000000..42552f56 --- /dev/null +++ b/snap/local/set-environment @@ -0,0 +1,35 @@ +#!/bin/sh + +enabled="$(snapctl get enabled)" +if [ -z "${enabled}" -o "${enabled}" != "true" ] +then + echo "Conduit not yet enabled" + exit 0 +fi + +export ROCKET_SERVER_NAME="$(snapctl get base-url)" + +listen_address="$(snapctl get listen.address)" +if [ -n "${listen_address}" ] +then + export ROCKET_ADDRESS="$(snapctl get listen.address)" + export ROCKET_PORT="$(snapctl get listen.port)" +fi + +federation_enabled="$(snapctl get federation)" +if [ -n "${federation_enabled}" ] +then + export ROCKET_FEDERATION_ENABLED=${federation_enabled} +fi + +registration_enabled="$(snapctl get registration)" +if [ -n "${registration_enabled}" -a "${registration_enabled}" = "false" ] +then + export ROCKET_REGISTRATION_DISABLED="true" +fi + +export ROCKET_ENV="production" +export ROCKET_DATABASE_PATH=${SNAP_DATA} + +cd ${SNAP} +exec $@ diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 00000000..4eae1028 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,40 @@ +name: conduit +base: core20 +version: git +summary: A Matrix homeserver written in Rust +description: | + A fast Matrix homeserver that's easy to set up and just works. You can + install it on a mini-computer like the Raspberry Pi to host Matrix for + your family, friends or company. + + Conduit is under heavy development, and many features of a fully-functional + Matrix server are incomplete or missing, but + + What are the biggest things still missing? + * Appservices (Bridges and Bots) + * Most federation features (invites, e2ee) + * Push notifications on mobile + * Notification settings + * Lots of testing + +grade: devel # must be 'stable' to release into candidate/stable channels +confinement: strict # use 'strict' once you have the right plugs and slots + +apps: + conduit: + daemon: simple + command: set-environment bin/conduit + plugs: + - network + - network-bind + +parts: + conduit: + plugin: rust + source: . + build-packages: + - libssl-dev + - pkg-config + snap-helper: + plugin: dump + source: snap/local/