2018-07-27 21:08:14 +08:00
|
|
|
#!/bin/bash
|
2018-09-26 01:45:08 +08:00
|
|
|
set -e
|
|
|
|
|
2018-07-17 00:10:33 +08:00
|
|
|
# config
|
2018-09-18 22:51:50 +08:00
|
|
|
SYNAPSE_BRANCH=develop
|
2018-07-17 00:10:33 +08:00
|
|
|
INSTALLATION_NAME=consent
|
|
|
|
SERVER_DIR=installations/$INSTALLATION_NAME
|
|
|
|
CONFIG_TEMPLATE=consent
|
2018-08-08 00:28:18 +08:00
|
|
|
PORT=5005
|
2018-07-17 00:10:33 +08:00
|
|
|
# set current directory to script directory
|
2018-09-26 01:45:08 +08:00
|
|
|
BASE_DIR=$(cd $(dirname $0) && pwd)
|
2018-07-27 20:00:01 +08:00
|
|
|
|
2018-07-27 21:08:14 +08:00
|
|
|
if [ -d $BASE_DIR/$SERVER_DIR ]; then
|
2018-08-14 18:53:16 +08:00
|
|
|
echo "synapse is already installed"
|
|
|
|
exit
|
2018-07-27 20:00:01 +08:00
|
|
|
fi
|
|
|
|
|
2018-07-27 20:10:19 +08:00
|
|
|
cd $BASE_DIR
|
2018-07-27 20:00:01 +08:00
|
|
|
|
2018-07-17 00:10:33 +08:00
|
|
|
mkdir -p installations/
|
|
|
|
curl https://codeload.github.com/matrix-org/synapse/zip/$SYNAPSE_BRANCH --output synapse.zip
|
2018-07-30 19:40:23 +08:00
|
|
|
unzip -q synapse.zip
|
2018-07-17 00:10:33 +08:00
|
|
|
mv synapse-$SYNAPSE_BRANCH $SERVER_DIR
|
2018-07-27 20:10:19 +08:00
|
|
|
cd $SERVER_DIR
|
2018-07-17 00:10:33 +08:00
|
|
|
virtualenv -p python2.7 env
|
|
|
|
source env/bin/activate
|
2018-09-26 01:45:08 +08:00
|
|
|
|
|
|
|
# Having been bitten by pip SSL fail too many times, I don't trust the existing pip
|
|
|
|
# to be able to --upgrade itself, so grab a new one fresh from source.
|
|
|
|
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
|
|
|
|
python get-pip.py
|
|
|
|
|
2018-07-17 00:10:33 +08:00
|
|
|
pip install --upgrade setuptools
|
2018-09-26 01:45:08 +08:00
|
|
|
python synapse/python_dependencies.py | xargs pip install
|
|
|
|
pip install lxml mock
|
2018-07-17 00:10:33 +08:00
|
|
|
pip install .
|
2018-09-26 01:45:08 +08:00
|
|
|
|
2018-07-17 00:10:33 +08:00
|
|
|
python -m synapse.app.homeserver \
|
|
|
|
--server-name localhost \
|
|
|
|
--config-path homeserver.yaml \
|
|
|
|
--generate-config \
|
|
|
|
--report-stats=no
|
|
|
|
# apply configuration
|
|
|
|
cp -r $BASE_DIR/config-templates/$CONFIG_TEMPLATE/. ./
|
2018-09-26 01:45:08 +08:00
|
|
|
|
|
|
|
# Hashes used instead of slashes because we'll get a value back from $(pwd) that'll be
|
|
|
|
# full of un-escapable slashes.
|
2018-09-27 20:21:45 +08:00
|
|
|
# Manually directing output to .templated file and then manually renaming back on top
|
|
|
|
# of the original file because -i is a nonstandard sed feature which is implemented
|
|
|
|
# differently, across os X and ubuntu at least
|
|
|
|
sed "s#{{SYNAPSE_ROOT}}#$(pwd)/#g" homeserver.yaml > homeserver.yaml.templated && mv homeserver.yaml.templated homeserver.yaml
|
|
|
|
sed "s#{{SYNAPSE_PORT}}#${PORT}#g" homeserver.yaml > homeserver.yaml.templated && mv homeserver.yaml.templated homeserver.yaml
|
|
|
|
sed "s#{{FORM_SECRET}}#$(uuidgen)#g" homeserver.yaml > homeserver.yaml.templated && mv homeserver.yaml.templated homeserver.yaml
|
|
|
|
sed "s#{{REGISTRATION_SHARED_SECRET}}#$(uuidgen)#g" homeserver.yaml > homeserver.yaml.templated && mv homeserver.yaml.templated homeserver.yaml
|
|
|
|
sed "s#{{MACAROON_SECRET_KEY}}#$(uuidgen)#g" homeserver.yaml > homeserver.yaml.templated && mv homeserver.yaml.templated homeserver.yaml
|