| 
				
			 | 
			
			
				@@ -1,408 +0,0 @@ 
			 | 
		
	
		
			
			| 
				1
			 | 
			
				
			 | 
			
			
				-#!/bin/bash 
			 | 
		
	
		
			
			| 
				2
			 | 
			
				
			 | 
			
			
				-# 
			 | 
		
	
		
			
			| 
				3
			 | 
			
				
			 | 
			
			
				-# .---.                  .              . 
			 | 
		
	
		
			
			| 
				4
			 | 
			
				
			 | 
			
			
				-# |                      |              | 
			 | 
		
	
		
			
			| 
				5
			 | 
			
				
			 | 
			
			
				-# |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-. 
			 | 
		
	
		
			
			| 
				6
			 | 
			
				
			 | 
			
			
				-# |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-' 
			 | 
		
	
		
			
			| 
				7
			 | 
			
				
			 | 
			
			
				-# '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --' 
			 | 
		
	
		
			
			| 
				8
			 | 
			
				
			 | 
			
			
				-# 
			 | 
		
	
		
			
			| 
				9
			 | 
			
				
			 | 
			
			
				-#                    Freedom in the Cloud 
			 | 
		
	
		
			
			| 
				10
			 | 
			
				
			 | 
			
			
				-# 
			 | 
		
	
		
			
			| 
				11
			 | 
			
				
			 | 
			
			
				-# synapse matrix server 
			 | 
		
	
		
			
			| 
				12
			 | 
			
				
			 | 
			
			
				-# 
			 | 
		
	
		
			
			| 
				13
			 | 
			
				
			 | 
			
			
				-# https://matrix.org/blog/2016/02/10/advanced-synapse-setup-with-lets-encrypt/ 
			 | 
		
	
		
			
			| 
				14
			 | 
			
				
			 | 
			
			
				-# 
			 | 
		
	
		
			
			| 
				15
			 | 
			
				
			 | 
			
			
				-# Had no success in configuring this with Riot, and the identity server 
			 | 
		
	
		
			
			| 
				16
			 | 
			
				
			 | 
			
			
				-# turned out to be centralised. 
			 | 
		
	
		
			
			| 
				17
			 | 
			
				
			 | 
			
			
				-#   https://github.com/matrix-org/matrix-doc/issues/712 
			 | 
		
	
		
			
			| 
				18
			 | 
			
				
			 | 
			
			
				-# Possibly it might become decentralised in future. 
			 | 
		
	
		
			
			| 
				19
			 | 
			
				
			 | 
			
			
				-# 
			 | 
		
	
		
			
			| 
				20
			 | 
			
				
			 | 
			
			
				-# License 
			 | 
		
	
		
			
			| 
				21
			 | 
			
				
			 | 
			
			
				-# ======= 
			 | 
		
	
		
			
			| 
				22
			 | 
			
				
			 | 
			
			
				-# 
			 | 
		
	
		
			
			| 
				23
			 | 
			
				
			 | 
			
			
				-# Copyright (C) 2016 Bob Mottram <bob@freedombone.net> 
			 | 
		
	
		
			
			| 
				24
			 | 
			
				
			 | 
			
			
				-# 
			 | 
		
	
		
			
			| 
				25
			 | 
			
				
			 | 
			
			
				-# This program is free software: you can redistribute it and/or modify 
			 | 
		
	
		
			
			| 
				26
			 | 
			
				
			 | 
			
			
				-# it under the terms of the GNU Affero General Public License as published by 
			 | 
		
	
		
			
			| 
				27
			 | 
			
				
			 | 
			
			
				-# the Free Software Foundation, either version 3 of the License, or 
			 | 
		
	
		
			
			| 
				28
			 | 
			
				
			 | 
			
			
				-# (at your option) any later version. 
			 | 
		
	
		
			
			| 
				29
			 | 
			
				
			 | 
			
			
				-# 
			 | 
		
	
		
			
			| 
				30
			 | 
			
				
			 | 
			
			
				-# This program is distributed in the hope that it will be useful, 
			 | 
		
	
		
			
			| 
				31
			 | 
			
				
			 | 
			
			
				-# but WITHOUT ANY WARRANTY; without even the implied warranty of 
			 | 
		
	
		
			
			| 
				32
			 | 
			
				
			 | 
			
			
				-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
			 | 
		
	
		
			
			| 
				33
			 | 
			
				
			 | 
			
			
				-# GNU Affero General Public License for more details. 
			 | 
		
	
		
			
			| 
				34
			 | 
			
				
			 | 
			
			
				-# 
			 | 
		
	
		
			
			| 
				35
			 | 
			
				
			 | 
			
			
				-# You should have received a copy of the GNU Affero General Public License 
			 | 
		
	
		
			
			| 
				36
			 | 
			
				
			 | 
			
			
				-# along with this program.  If not, see <http://www.gnu.org/licenses/>. 
			 | 
		
	
		
			
			| 
				37
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				38
			 | 
			
				
			 | 
			
			
				-VARIANTS='' 
			 | 
		
	
		
			
			| 
				39
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				40
			 | 
			
				
			 | 
			
			
				-IN_DEFAULT_INSTALL=0 
			 | 
		
	
		
			
			| 
				41
			 | 
			
				
			 | 
			
			
				-SHOW_ON_ABOUT=0 
			 | 
		
	
		
			
			| 
				42
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				43
			 | 
			
				
			 | 
			
			
				-SYNAPSE_PORT=8448 
			 | 
		
	
		
			
			| 
				44
			 | 
			
				
			 | 
			
			
				-SYNAPSE_PASSWORD= 
			 | 
		
	
		
			
			| 
				45
			 | 
			
				
			 | 
			
			
				-SYNAPSE_DIR=/etc/matrix-synapse 
			 | 
		
	
		
			
			| 
				46
			 | 
			
				
			 | 
			
			
				-MATRIX_IRC_REPO="https://github.com/matrix-org/matrix-appservice-irc" 
			 | 
		
	
		
			
			| 
				47
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				48
			 | 
			
				
			 | 
			
			
				-synapse_variables=(ONION_ONLY 
			 | 
		
	
		
			
			| 
				49
			 | 
			
				
			 | 
			
			
				-                   MY_USERNAME 
			 | 
		
	
		
			
			| 
				50
			 | 
			
				
			 | 
			
			
				-                   SYNAPSE_PASSWORD 
			 | 
		
	
		
			
			| 
				51
			 | 
			
				
			 | 
			
			
				-                   DEFAULT_DOMAIN_NAME) 
			 | 
		
	
		
			
			| 
				52
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				53
			 | 
			
				
			 | 
			
			
				-function install_matrix_irc_bridge { 
			 | 
		
	
		
			
			| 
				54
			 | 
			
				
			 | 
			
			
				-    if [ ! -d /etc/matrix-synapse ]; then 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				
			 | 
			
			
				-        return 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				
			 | 
			
			
				-    if [ ! -d /etc/ngircd ]; then 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				
			 | 
			
			
				-        return 
			 | 
		
	
		
			
			| 
				59
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				60
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				
			 | 
			
			
				-    function_check install_nodejs 
			 | 
		
	
		
			
			| 
				62
			 | 
			
				
			 | 
			
			
				-    install_nodejs synapse 
			 | 
		
	
		
			
			| 
				63
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				64
			 | 
			
				
			 | 
			
			
				-    if [ ! -d $INSTALL_DIR ]; then 
			 | 
		
	
		
			
			| 
				65
			 | 
			
				
			 | 
			
			
				-        mkdir -p $INSTALL_DIR 
			 | 
		
	
		
			
			| 
				66
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				67
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				68
			 | 
			
				
			 | 
			
			
				-    cd $INSTALL_DIR 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				
			 | 
			
			
				-    git_clone $MATRIX_IRC_REPO $INSTALL_DIR/matrix_irc_bridge 
			 | 
		
	
		
			
			| 
				70
			 | 
			
				
			 | 
			
			
				-    cd $INSTALL_DIR/matrix_irc_bridge 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				
			 | 
			
			
				-    npm install 
			 | 
		
	
		
			
			| 
				72
			 | 
			
				
			 | 
			
			
				-    if [ ! -f config.sample.yaml ]; then 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				
			 | 
			
			
				-        exit 623835 
			 | 
		
	
		
			
			| 
				74
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				
			 | 
			
			
				-    IRC_PASSWORD=$(cat /etc/ngircd/ngircd.conf | grep "Password =" | head -n 1 | awk -F '=' '{print $2}') 
			 | 
		
	
		
			
			| 
				77
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				78
			 | 
			
				
			 | 
			
			
				-    echo 'homeserver:' > $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				79
			 | 
			
				
			 | 
			
			
				-    echo '  url: "http://localhost:8008"' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				80
			 | 
			
				
			 | 
			
			
				-    echo '  domain: "localhost"' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				81
			 | 
			
				
			 | 
			
			
				-    echo 'ircService:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				82
			 | 
			
				
			 | 
			
			
				-    echo '  servers:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				83
			 | 
			
				
			 | 
			
			
				-    echo "    localhost:" >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				84
			 | 
			
				
			 | 
			
			
				-    echo "      name: \"${PROJECT_NAME} IRC\"" >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				85
			 | 
			
				
			 | 
			
			
				-    echo "      port: ${IRC_PORT}" >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				86
			 | 
			
				
			 | 
			
			
				-    echo '      ssl: false' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				87
			 | 
			
				
			 | 
			
			
				-    echo '      sslselfsign: false' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				88
			 | 
			
				
			 | 
			
			
				-    echo '      password: "${IRC_PASSWORD}"' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				89
			 | 
			
				
			 | 
			
			
				-    echo '      sendConnectionMessages: true' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				90
			 | 
			
				
			 | 
			
			
				-    echo '      quitDebounce:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				91
			 | 
			
				
			 | 
			
			
				-    echo '        enabled: false' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				92
			 | 
			
				
			 | 
			
			
				-    echo '        quitsPerSecond: 5' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				93
			 | 
			
				
			 | 
			
			
				-    echo '        delayMs: 3600000 # 1h' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				94
			 | 
			
				
			 | 
			
			
				-    echo '      botConfig:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				95
			 | 
			
				
			 | 
			
			
				-    echo '        enabled: true' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				96
			 | 
			
				
			 | 
			
			
				-    echo '        nick: "MatrixBot"' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				97
			 | 
			
				
			 | 
			
			
				-    echo '        joinChannelsIfNoUsers: true' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				98
			 | 
			
				
			 | 
			
			
				-    echo '      privateMessages:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				99
			 | 
			
				
			 | 
			
			
				-    echo '        enabled: true' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				100
			 | 
			
				
			 | 
			
			
				-    echo '        federate: true' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				101
			 | 
			
				
			 | 
			
			
				-    echo '      dynamicChannels:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				102
			 | 
			
				
			 | 
			
			
				-    echo '        enabled: true' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				103
			 | 
			
				
			 | 
			
			
				-    echo '        createAlias: true' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				104
			 | 
			
				
			 | 
			
			
				-    echo '        published: true' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				105
			 | 
			
				
			 | 
			
			
				-    echo '        joinRule: public' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				106
			 | 
			
				
			 | 
			
			
				-    echo '        federate: true' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				107
			 | 
			
				
			 | 
			
			
				-    echo '        aliasTemplate: "#irc_$CHANNEL"' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				108
			 | 
			
				
			 | 
			
			
				-    echo '      membershipLists:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				109
			 | 
			
				
			 | 
			
			
				-    echo '        enabled: false' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				110
			 | 
			
				
			 | 
			
			
				-    echo '        floodDelayMs: 10000' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				111
			 | 
			
				
			 | 
			
			
				-    echo '        global:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				112
			 | 
			
				
			 | 
			
			
				-    echo '          ircToMatrix:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				113
			 | 
			
				
			 | 
			
			
				-    echo '            initial: false' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				114
			 | 
			
				
			 | 
			
			
				-    echo '            incremental: false' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				115
			 | 
			
				
			 | 
			
			
				-    echo '          matrixToIrc:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				116
			 | 
			
				
			 | 
			
			
				-    echo '            initial: false' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				117
			 | 
			
				
			 | 
			
			
				-    echo '            incremental: false' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				118
			 | 
			
				
			 | 
			
			
				-    echo '        rooms:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				119
			 | 
			
				
			 | 
			
			
				-    echo '          - room: "!fuasirouddJoxtwfge:localhost"' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				120
			 | 
			
				
			 | 
			
			
				-    echo '            matrixToIrc:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				121
			 | 
			
				
			 | 
			
			
				-    echo '              initial: false' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				122
			 | 
			
				
			 | 
			
			
				-    echo '              incremental: false' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				123
			 | 
			
				
			 | 
			
			
				-    echo '        channels:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				124
			 | 
			
				
			 | 
			
			
				-    echo "          - channel: \"#${PROJECT_NAME}\"" >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				125
			 | 
			
				
			 | 
			
			
				-    echo '            ircToMatrix:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				126
			 | 
			
				
			 | 
			
			
				-    echo '              initial: false' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				127
			 | 
			
				
			 | 
			
			
				-    echo '              incremental: false' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				128
			 | 
			
				
			 | 
			
			
				-    echo '      mappings:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				129
			 | 
			
				
			 | 
			
			
				-    echo '        "#thepub": ["!kieouiJuedJoxtVdaG:localhost"]' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				130
			 | 
			
				
			 | 
			
			
				-    echo '      matrixClients:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				131
			 | 
			
				
			 | 
			
			
				-    echo '        userTemplate: "@irc_$NICK"' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				132
			 | 
			
				
			 | 
			
			
				-    echo '        displayName: "$NICK (IRC)"' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				133
			 | 
			
				
			 | 
			
			
				-    echo '      ircClients:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				134
			 | 
			
				
			 | 
			
			
				-    echo '        nickTemplate: "$DISPLAY[m]"' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				135
			 | 
			
				
			 | 
			
			
				-    echo '        allowNickChanges: true' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				136
			 | 
			
				
			 | 
			
			
				-    echo '        maxClients: 30' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				137
			 | 
			
				
			 | 
			
			
				-    echo '        idleTimeout: 10800' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				138
			 | 
			
				
			 | 
			
			
				-    echo '        reconnectIntervalMs: 5000' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				139
			 | 
			
				
			 | 
			
			
				-    echo '        lineLimit: 3' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				140
			 | 
			
				
			 | 
			
			
				-    echo '  ident:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				141
			 | 
			
				
			 | 
			
			
				-    echo '    enabled: false' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				142
			 | 
			
				
			 | 
			
			
				-    echo '    port: 1113' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				143
			 | 
			
				
			 | 
			
			
				-    echo '  logging:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				144
			 | 
			
				
			 | 
			
			
				-    echo '    level: "debug"' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				145
			 | 
			
				
			 | 
			
			
				-    echo '    logfile: "debug.log"' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				146
			 | 
			
				
			 | 
			
			
				-    echo '    errfile: "errors.log"' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				147
			 | 
			
				
			 | 
			
			
				-    echo '    toConsole: true' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				148
			 | 
			
				
			 | 
			
			
				-    echo '    maxFileSizeBytes: 134217728 # 128 MB' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				149
			 | 
			
				
			 | 
			
			
				-    echo '    maxFiles: 5' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				150
			 | 
			
				
			 | 
			
			
				-    echo '  databaseUri: "nedb://data"' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				151
			 | 
			
				
			 | 
			
			
				-    echo '  debugApi:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				152
			 | 
			
				
			 | 
			
			
				-    echo '    enabled: false' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				153
			 | 
			
				
			 | 
			
			
				-    echo '    port: 11100' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				154
			 | 
			
				
			 | 
			
			
				-    echo '  provisioning:' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				155
			 | 
			
				
			 | 
			
			
				-    echo '    enabled: false' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				156
			 | 
			
				
			 | 
			
			
				-    echo '    requestTimeoutSeconds: 300' >> $INSTALL_DIR/matrix_irc_bridge/config.yaml 
			 | 
		
	
		
			
			| 
				157
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				158
			 | 
			
				
			 | 
			
			
				-    /usr/bin/node $INSTALL_DIR/matrix_irc_bridge/app.js -r -f /etc/matrix-synapse/my_registration_file.yaml -u "http://${DEFAULT_DOMAIN_NAME}:9999" -c $INSTALL_DIR/matrix_irc_bridge/config.yaml -l my_bot 
			 | 
		
	
		
			
			| 
				159
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				160
			 | 
			
				
			 | 
			
			
				-    if ! grep "my_registration_file.yaml" homeserver.yaml; then 
			 | 
		
	
		
			
			| 
				161
			 | 
			
				
			 | 
			
			
				-        echo 'app_service_config_files: ["my_registration_file.yaml"]' >> homeserver.yaml 
			 | 
		
	
		
			
			| 
				162
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				163
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				164
			 | 
			
				
			 | 
			
			
				-    echo '[Unit]' > /etc/systemd/system/matrix_irc_bridge.service 
			 | 
		
	
		
			
			| 
				165
			 | 
			
				
			 | 
			
			
				-    echo 'Description=Matrix IRC Bridge' >> /etc/systemd/system/matrix_irc_bridge.service 
			 | 
		
	
		
			
			| 
				166
			 | 
			
				
			 | 
			
			
				-    echo '' >> /etc/systemd/system/matrix_irc_bridge.service 
			 | 
		
	
		
			
			| 
				167
			 | 
			
				
			 | 
			
			
				-    echo '[Service]' >> /etc/systemd/system/matrix_irc_bridge.service 
			 | 
		
	
		
			
			| 
				168
			 | 
			
				
			 | 
			
			
				-    echo 'Type=simple' >> /etc/systemd/system/matrix_irc_bridge.service 
			 | 
		
	
		
			
			| 
				169
			 | 
			
				
			 | 
			
			
				-    echo 'User=matrix-synapse' >> /etc/systemd/system/matrix_irc_bridge.service 
			 | 
		
	
		
			
			| 
				170
			 | 
			
				
			 | 
			
			
				-    echo "WorkingDirectory=$INSTALL_DIR/matrix_irc_bridge" >> /etc/systemd/system/matrix_irc_bridge.service 
			 | 
		
	
		
			
			| 
				171
			 | 
			
				
			 | 
			
			
				-    echo "ExecStart=/usr/bin/node $INSTALL_DIR/matrix_irc_bridge/app.js -c $INSTALL_DIR/matrix_irc_bridge/config.yaml -f /etc/matrix-synapse/my_registration_file.yaml -p 9999" >> /etc/systemd/system/matrix_irc_bridge.service 
			 | 
		
	
		
			
			| 
				172
			 | 
			
				
			 | 
			
			
				-    echo 'Restart=always' >> /etc/systemd/system/matrix_irc_bridge.service 
			 | 
		
	
		
			
			| 
				173
			 | 
			
				
			 | 
			
			
				-    echo 'RestartSec=3' >> /etc/systemd/system/matrix_irc_bridge.service 
			 | 
		
	
		
			
			| 
				174
			 | 
			
				
			 | 
			
			
				-    echo '' >> /etc/systemd/system/matrix_irc_bridge.service 
			 | 
		
	
		
			
			| 
				175
			 | 
			
				
			 | 
			
			
				-    echo '[Install]' >> /etc/systemd/system/matrix_irc_bridge.service 
			 | 
		
	
		
			
			| 
				176
			 | 
			
				
			 | 
			
			
				-    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/matrix_irc_bridge.service 
			 | 
		
	
		
			
			| 
				177
			 | 
			
				
			 | 
			
			
				-    systemctl enable matrix_irc_bridge 
			 | 
		
	
		
			
			| 
				178
			 | 
			
				
			 | 
			
			
				-    systemctl start matrix_irc_bridge 
			 | 
		
	
		
			
			| 
				179
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				180
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				181
			 | 
			
				
			 | 
			
			
				-function can_install_synapse { 
			 | 
		
	
		
			
			| 
				182
			 | 
			
				
			 | 
			
			
				-    check_architecture=$(uname -a) 
			 | 
		
	
		
			
			| 
				183
			 | 
			
				
			 | 
			
			
				-    if [[ "$check_architecture" == *"amd64"* || "$check_architecture" == *"i386"* ]]; then 
			 | 
		
	
		
			
			| 
				184
			 | 
			
				
			 | 
			
			
				-        echo "1" 
			 | 
		
	
		
			
			| 
				185
			 | 
			
				
			 | 
			
			
				-    else 
			 | 
		
	
		
			
			| 
				186
			 | 
			
				
			 | 
			
			
				-        echo "0" 
			 | 
		
	
		
			
			| 
				187
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				188
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				189
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				190
			 | 
			
				
			 | 
			
			
				-function remove_user_synapse { 
			 | 
		
	
		
			
			| 
				191
			 | 
			
				
			 | 
			
			
				-    remove_username="$1" 
			 | 
		
	
		
			
			| 
				192
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				193
			 | 
			
				
			 | 
			
			
				-    ${PROJECT_NAME}-pass -u $remove_username --rmapp synapse 
			 | 
		
	
		
			
			| 
				194
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				195
			 | 
			
				
			 | 
			
			
				-    # TODO 
			 | 
		
	
		
			
			| 
				196
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				197
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				198
			 | 
			
				
			 | 
			
			
				-function add_user_synapse { 
			 | 
		
	
		
			
			| 
				199
			 | 
			
				
			 | 
			
			
				-    new_username="$1" 
			 | 
		
	
		
			
			| 
				200
			 | 
			
				
			 | 
			
			
				-    new_user_password="$2" 
			 | 
		
	
		
			
			| 
				201
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				202
			 | 
			
				
			 | 
			
			
				-    ${PROJECT_NAME}-pass -u $new_username -a synapse -p "$new_user_password" 
			 | 
		
	
		
			
			| 
				203
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				204
			 | 
			
				
			 | 
			
			
				-    cd $SYNAPSE_DIR 
			 | 
		
	
		
			
			| 
				205
			 | 
			
				
			 | 
			
			
				-    register_new_matrix_user -c homeserver.yaml https://localhost:${SYNAPSE_PORT} -u "${new_username}" -p "${new_user_password}" -a 
			 | 
		
	
		
			
			| 
				206
			 | 
			
				
			 | 
			
			
				-    echo '0' 
			 | 
		
	
		
			
			| 
				207
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				208
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				209
			 | 
			
				
			 | 
			
			
				-function install_interactive_synapse { 
			 | 
		
	
		
			
			| 
				210
			 | 
			
				
			 | 
			
			
				-    echo -n '' 
			 | 
		
	
		
			
			| 
				211
			 | 
			
				
			 | 
			
			
				-    APP_INSTALLED=1 
			 | 
		
	
		
			
			| 
				212
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				213
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				214
			 | 
			
				
			 | 
			
			
				-function change_password_synapse { 
			 | 
		
	
		
			
			| 
				215
			 | 
			
				
			 | 
			
			
				-    curr_username="$1" 
			 | 
		
	
		
			
			| 
				216
			 | 
			
				
			 | 
			
			
				-    new_user_password="$2" 
			 | 
		
	
		
			
			| 
				217
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				218
			 | 
			
				
			 | 
			
			
				-    #${PROJECT_NAME}-pass -u "$curr_username" -a synapse -p "$new_user_password" 
			 | 
		
	
		
			
			| 
				219
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				220
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				221
			 | 
			
				
			 | 
			
			
				-function reconfigure_synapse { 
			 | 
		
	
		
			
			| 
				222
			 | 
			
				
			 | 
			
			
				-    echo -n '' 
			 | 
		
	
		
			
			| 
				223
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				224
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				225
			 | 
			
				
			 | 
			
			
				-function upgrade_synapse { 
			 | 
		
	
		
			
			| 
				226
			 | 
			
				
			 | 
			
			
				-    echo -n '' 
			 | 
		
	
		
			
			| 
				227
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				228
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				229
			 | 
			
				
			 | 
			
			
				-function backup_local_synapse { 
			 | 
		
	
		
			
			| 
				230
			 | 
			
				
			 | 
			
			
				-    source_directory=$SYNAPSE_DIR 
			 | 
		
	
		
			
			| 
				231
			 | 
			
				
			 | 
			
			
				-    if [ -d $source_directory ]; then 
			 | 
		
	
		
			
			| 
				232
			 | 
			
				
			 | 
			
			
				-        systemctl stop synapse 
			 | 
		
	
		
			
			| 
				233
			 | 
			
				
			 | 
			
			
				-        function_check backup_directory_to_usb 
			 | 
		
	
		
			
			| 
				234
			 | 
			
				
			 | 
			
			
				-        backup_directory_to_usb $source_directory synapse 
			 | 
		
	
		
			
			| 
				235
			 | 
			
				
			 | 
			
			
				-        source_directory=/var/lib/matrix-synapse 
			 | 
		
	
		
			
			| 
				236
			 | 
			
				
			 | 
			
			
				-        if [ -d $source_directory ]; then 
			 | 
		
	
		
			
			| 
				237
			 | 
			
				
			 | 
			
			
				-            backup_directory_to_usb $source_directory synapsedata 
			 | 
		
	
		
			
			| 
				238
			 | 
			
				
			 | 
			
			
				-        fi 
			 | 
		
	
		
			
			| 
				239
			 | 
			
				
			 | 
			
			
				-        systemctl start synapse 
			 | 
		
	
		
			
			| 
				240
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				241
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				242
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				243
			 | 
			
				
			 | 
			
			
				-function restore_local_synapse { 
			 | 
		
	
		
			
			| 
				244
			 | 
			
				
			 | 
			
			
				-    if [ -d $SYNAPSE_DIR ]; then 
			 | 
		
	
		
			
			| 
				245
			 | 
			
				
			 | 
			
			
				-        systemctl stop synapse 
			 | 
		
	
		
			
			| 
				246
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				247
			 | 
			
				
			 | 
			
			
				-        temp_restore_dir=/root/tempsynapse 
			 | 
		
	
		
			
			| 
				248
			 | 
			
				
			 | 
			
			
				-        function_check restore_directory_from_usb 
			 | 
		
	
		
			
			| 
				249
			 | 
			
				
			 | 
			
			
				-        restore_directory_from_usb $temp_restore_dir synapse 
			 | 
		
	
		
			
			| 
				250
			 | 
			
				
			 | 
			
			
				-        cp -r $temp_restore_dir$SYNAPSE_DIR/* $SYNAPSE_DIR 
			 | 
		
	
		
			
			| 
				251
			 | 
			
				
			 | 
			
			
				-        if [ ! "$?" = "0" ]; then 
			 | 
		
	
		
			
			| 
				252
			 | 
			
				
			 | 
			
			
				-            function_check backup_unmount_drive 
			 | 
		
	
		
			
			| 
				253
			 | 
			
				
			 | 
			
			
				-            backup_unmount_drive 
			 | 
		
	
		
			
			| 
				254
			 | 
			
				
			 | 
			
			
				-            exit 725 
			 | 
		
	
		
			
			| 
				255
			 | 
			
				
			 | 
			
			
				-        fi 
			 | 
		
	
		
			
			| 
				256
			 | 
			
				
			 | 
			
			
				-        rm -rf $temp_restore_dir 
			 | 
		
	
		
			
			| 
				257
			 | 
			
				
			 | 
			
			
				-        chown -R synapse:synapse $SYNAPSE_DIR 
			 | 
		
	
		
			
			| 
				258
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				259
			 | 
			
				
			 | 
			
			
				-        temp_restore_dir=/root/tempsynapsedata 
			 | 
		
	
		
			
			| 
				260
			 | 
			
				
			 | 
			
			
				-        restore_directory_from_usb $temp_restore_dir synapsedata 
			 | 
		
	
		
			
			| 
				261
			 | 
			
				
			 | 
			
			
				-        cp -r $temp_restore_dir/var/lib/matrix-synapse/* /var/lib/matrix-synapse 
			 | 
		
	
		
			
			| 
				262
			 | 
			
				
			 | 
			
			
				-        if [ ! "$?" = "0" ]; then 
			 | 
		
	
		
			
			| 
				263
			 | 
			
				
			 | 
			
			
				-            function_check backup_unmount_drive 
			 | 
		
	
		
			
			| 
				264
			 | 
			
				
			 | 
			
			
				-            backup_unmount_drive 
			 | 
		
	
		
			
			| 
				265
			 | 
			
				
			 | 
			
			
				-            exit 36872 
			 | 
		
	
		
			
			| 
				266
			 | 
			
				
			 | 
			
			
				-        fi 
			 | 
		
	
		
			
			| 
				267
			 | 
			
				
			 | 
			
			
				-        rm -rf $temp_restore_dir 
			 | 
		
	
		
			
			| 
				268
			 | 
			
				
			 | 
			
			
				-        chown -R synapse:synapse /var/lib/matrix-synapse 
			 | 
		
	
		
			
			| 
				269
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				270
			 | 
			
				
			 | 
			
			
				-        systemctl start synapse 
			 | 
		
	
		
			
			| 
				271
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				272
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				273
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				274
			 | 
			
				
			 | 
			
			
				-function backup_remote_synapse { 
			 | 
		
	
		
			
			| 
				275
			 | 
			
				
			 | 
			
			
				-    source_directory=$SYNAPSE_DIR 
			 | 
		
	
		
			
			| 
				276
			 | 
			
				
			 | 
			
			
				-    if [ -d $source_directory ]; then 
			 | 
		
	
		
			
			| 
				277
			 | 
			
				
			 | 
			
			
				-        systemctl stop synapse 
			 | 
		
	
		
			
			| 
				278
			 | 
			
				
			 | 
			
			
				-        function_check backup_directory_to_friend 
			 | 
		
	
		
			
			| 
				279
			 | 
			
				
			 | 
			
			
				-        backup_directory_to_friend $source_directory synapse 
			 | 
		
	
		
			
			| 
				280
			 | 
			
				
			 | 
			
			
				-        source_directory=/var/lib/matrix-synapse 
			 | 
		
	
		
			
			| 
				281
			 | 
			
				
			 | 
			
			
				-        if [ -d $source_directory ]; then 
			 | 
		
	
		
			
			| 
				282
			 | 
			
				
			 | 
			
			
				-            backup_directory_to_friend $source_directory synapsedata 
			 | 
		
	
		
			
			| 
				283
			 | 
			
				
			 | 
			
			
				-        fi 
			 | 
		
	
		
			
			| 
				284
			 | 
			
				
			 | 
			
			
				-        systemctl start synapse 
			 | 
		
	
		
			
			| 
				285
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				286
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				287
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				288
			 | 
			
				
			 | 
			
			
				-function restore_remote_synapse { 
			 | 
		
	
		
			
			| 
				289
			 | 
			
				
			 | 
			
			
				-    if [ -d $SYNAPSE_DIR ]; then 
			 | 
		
	
		
			
			| 
				290
			 | 
			
				
			 | 
			
			
				-        systemctl stop synapse 
			 | 
		
	
		
			
			| 
				291
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				292
			 | 
			
				
			 | 
			
			
				-        temp_restore_dir=/root/tempsynapse 
			 | 
		
	
		
			
			| 
				293
			 | 
			
				
			 | 
			
			
				-        function_check restore_directory_from_friend 
			 | 
		
	
		
			
			| 
				294
			 | 
			
				
			 | 
			
			
				-        restore_directory_from_friend $temp_restore_dir synapse 
			 | 
		
	
		
			
			| 
				295
			 | 
			
				
			 | 
			
			
				-        cp -r $temp_restore_dir$SYNAPSE_DIR/* $SYNAPSE_DIR 
			 | 
		
	
		
			
			| 
				296
			 | 
			
				
			 | 
			
			
				-        if [ ! "$?" = "0" ]; then 
			 | 
		
	
		
			
			| 
				297
			 | 
			
				
			 | 
			
			
				-            exit 59262 
			 | 
		
	
		
			
			| 
				298
			 | 
			
				
			 | 
			
			
				-        fi 
			 | 
		
	
		
			
			| 
				299
			 | 
			
				
			 | 
			
			
				-        rm -rf $temp_restore_dir 
			 | 
		
	
		
			
			| 
				300
			 | 
			
				
			 | 
			
			
				-        chown -R synapse:synapse $SYNAPSE_DIR 
			 | 
		
	
		
			
			| 
				301
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				302
			 | 
			
				
			 | 
			
			
				-        temp_restore_dir=/root/tempsynapsedata 
			 | 
		
	
		
			
			| 
				303
			 | 
			
				
			 | 
			
			
				-        restore_directory_from_friend $temp_restore_dir synapsedata 
			 | 
		
	
		
			
			| 
				304
			 | 
			
				
			 | 
			
			
				-        cp -r $temp_restore_dir/var/lib/matrix-synapse/* /var/lib/matrix-synapse 
			 | 
		
	
		
			
			| 
				305
			 | 
			
				
			 | 
			
			
				-        if [ ! "$?" = "0" ]; then 
			 | 
		
	
		
			
			| 
				306
			 | 
			
				
			 | 
			
			
				-            exit 78335 
			 | 
		
	
		
			
			| 
				307
			 | 
			
				
			 | 
			
			
				-        fi 
			 | 
		
	
		
			
			| 
				308
			 | 
			
				
			 | 
			
			
				-        rm -rf $temp_restore_dir 
			 | 
		
	
		
			
			| 
				309
			 | 
			
				
			 | 
			
			
				-        chown -R synapse:synapse /var/lib/matrix-synapse 
			 | 
		
	
		
			
			| 
				310
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				311
			 | 
			
				
			 | 
			
			
				-        systemctl start synapse 
			 | 
		
	
		
			
			| 
				312
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				313
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				314
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				315
			 | 
			
				
			 | 
			
			
				-function remove_synapse { 
			 | 
		
	
		
			
			| 
				316
			 | 
			
				
			 | 
			
			
				-    systemctl stop matrix-synapse 
			 | 
		
	
		
			
			| 
				317
			 | 
			
				
			 | 
			
			
				-    firewall_remove ${SYNAPSE_PORT} 
			 | 
		
	
		
			
			| 
				318
			 | 
			
				
			 | 
			
			
				-    rm -rf $SYNAPSE_DIR 
			 | 
		
	
		
			
			| 
				319
			 | 
			
				
			 | 
			
			
				-    apt-get -yq remove --purge matrix-synapse matrix-synapse-angular-client 
			 | 
		
	
		
			
			| 
				320
			 | 
			
				
			 | 
			
			
				-    apt-get -yq autoremove 
			 | 
		
	
		
			
			| 
				321
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				322
			 | 
			
				
			 | 
			
			
				-    rm /etc/apt/sources.list.d/synapse.list 
			 | 
		
	
		
			
			| 
				323
			 | 
			
				
			 | 
			
			
				-    apt-get update 
			 | 
		
	
		
			
			| 
				324
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				325
			 | 
			
				
			 | 
			
			
				-    if [ -f /etc/systemd/system/matrix_irc_bridge.service ]; then 
			 | 
		
	
		
			
			| 
				326
			 | 
			
				
			 | 
			
			
				-        systemctl stop matrix_irc_bridge 
			 | 
		
	
		
			
			| 
				327
			 | 
			
				
			 | 
			
			
				-        systemctl disable matrix_irc_bridge 
			 | 
		
	
		
			
			| 
				328
			 | 
			
				
			 | 
			
			
				-        rm /etc/systemd/system/matrix_irc_bridge.service 
			 | 
		
	
		
			
			| 
				329
			 | 
			
				
			 | 
			
			
				-        remove_nodejs synapse 
			 | 
		
	
		
			
			| 
				330
			 | 
			
				
			 | 
			
			
				-        rm -rf $INSTALL_DIR/matrix_irc_bridge 
			 | 
		
	
		
			
			| 
				331
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				332
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				333
			 | 
			
				
			 | 
			
			
				-    remove_completion_param install_synapse 
			 | 
		
	
		
			
			| 
				334
			 | 
			
				
			 | 
			
			
				-    sed -i '/synapse/d' $COMPLETION_FILE 
			 | 
		
	
		
			
			| 
				335
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				336
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				337
			 | 
			
				
			 | 
			
			
				-function install_synapse { 
			 | 
		
	
		
			
			| 
				338
			 | 
			
				
			 | 
			
			
				-    if [[ "$(can_install_synapse)" == "0" ]]; then 
			 | 
		
	
		
			
			| 
				339
			 | 
			
				
			 | 
			
			
				-        echo $'Matrix/Synapse can only be installed on i386 or amd64 architectures' 
			 | 
		
	
		
			
			| 
				340
			 | 
			
				
			 | 
			
			
				-        exit 36734 
			 | 
		
	
		
			
			| 
				341
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				342
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				343
			 | 
			
				
			 | 
			
			
				-    if [[ ${ONION_ONLY} == 'no' ]]; then 
			 | 
		
	
		
			
			| 
				344
			 | 
			
				
			 | 
			
			
				-        # obtain a cert for the default domain 
			 | 
		
	
		
			
			| 
				345
			 | 
			
				
			 | 
			
			
				-        if [[ "$(cert_exists ${DEFAULT_DOMAIN_NAME} pem)" == "0" ]]; then 
			 | 
		
	
		
			
			| 
				346
			 | 
			
				
			 | 
			
			
				-            echo $'Obtaining certificate for the main domain' 
			 | 
		
	
		
			
			| 
				347
			 | 
			
				
			 | 
			
			
				-            create_site_certificate ${DEFAULT_DOMAIN_NAME} 'yes' 
			 | 
		
	
		
			
			| 
				348
			 | 
			
				
			 | 
			
			
				-        fi 
			 | 
		
	
		
			
			| 
				349
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				350
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				351
			 | 
			
				
			 | 
			
			
				-    if [ ! -d /etc/prosody ]; then 
			 | 
		
	
		
			
			| 
				352
			 | 
			
				
			 | 
			
			
				-        echo $'xmpp should be installed first' 
			 | 
		
	
		
			
			| 
				353
			 | 
			
				
			 | 
			
			
				-        exit 67382 
			 | 
		
	
		
			
			| 
				354
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				355
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				356
			 | 
			
				
			 | 
			
			
				-    apt-get -yq install build-essential python2.7-dev libffi-dev \ 
			 | 
		
	
		
			
			| 
				357
			 | 
			
				
			 | 
			
			
				-            python-pip python-setuptools sqlite3 \ 
			 | 
		
	
		
			
			| 
				358
			 | 
			
				
			 | 
			
			
				-            libssl-dev libjpeg-dev libxslt1-dev python-virtualenv curl 
			 | 
		
	
		
			
			| 
				359
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				360
			 | 
			
				
			 | 
			
			
				-    curl -s https://matrix.org/packages/debian/repo-key.asc | apt-key add - 
			 | 
		
	
		
			
			| 
				361
			 | 
			
				
			 | 
			
			
				-    echo "deb https://matrix.org/packages/debian/ ${DEBIAN_VERSION} main" | tee /etc/apt/sources.list.d/synapse.list 
			 | 
		
	
		
			
			| 
				362
			 | 
			
				
			 | 
			
			
				-    apt-get update 
			 | 
		
	
		
			
			| 
				363
			 | 
			
				
			 | 
			
			
				-    apt-get -yq install python-cffi 
			 | 
		
	
		
			
			| 
				364
			 | 
			
				
			 | 
			
			
				-    apt-get -yq install python-nacl 
			 | 
		
	
		
			
			| 
				365
			 | 
			
				
			 | 
			
			
				-    apt-get -yq install python-signedjson 
			 | 
		
	
		
			
			| 
				366
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				367
			 | 
			
				
			 | 
			
			
				-    debconf-set-selections <<< "matrix-synapse matrix-synapse/server-name string $DEFAULT_DOMAIN_NAME" 
			 | 
		
	
		
			
			| 
				368
			 | 
			
				
			 | 
			
			
				-    debconf-set-selections <<< "matrix-synapse matrix-synapse/server_name string $DEFAULT_DOMAIN_NAME" 
			 | 
		
	
		
			
			| 
				369
			 | 
			
				
			 | 
			
			
				-    debconf-set-selections <<< "matrix-synapse matrix-synapse/report-stats boolean false" 
			 | 
		
	
		
			
			| 
				370
			 | 
			
				
			 | 
			
			
				-    apt-get -yq install matrix-synapse 
			 | 
		
	
		
			
			| 
				371
			 | 
			
				
			 | 
			
			
				-    if [ ! -d /etc/matrix-synapse ]; then 
			 | 
		
	
		
			
			| 
				372
			 | 
			
				
			 | 
			
			
				-        exit 653835 
			 | 
		
	
		
			
			| 
				373
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				374
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				375
			 | 
			
				
			 | 
			
			
				-    #apt-get -yq install matrix-synapse-angular-client 
			 | 
		
	
		
			
			| 
				376
			 | 
			
				
			 | 
			
			
				-    #cp -av /etc/matrix-synapse/conf.d/webclient.yaml \ 
			 | 
		
	
		
			
			| 
				377
			 | 
			
				
			 | 
			
			
				-       #/etc/matrix-synapse/conf.d/webclient.yaml.orig 
			 | 
		
	
		
			
			| 
				378
			 | 
			
				
			 | 
			
			
				-    #sed -e 's|,$||g' -i /etc/matrix-synapse/conf.d/webclient.yaml 
			 | 
		
	
		
			
			| 
				379
			 | 
			
				
			 | 
			
			
				-    #cp -av  /etc/init.d/matrix-synapse /etc/init.d/matrix-synapse.orig 
			 | 
		
	
		
			
			| 
				380
			 | 
			
				
			 | 
			
			
				-    #sed -e 's|chown $USER:nogroup $PIDFILE.*|chown $USER:nogroup $PIDFILE /var/lib/$NAME/media|g' -i /etc/init.d/matrix-synapse 
			 | 
		
	
		
			
			| 
				381
			 | 
			
				
			 | 
			
			
				-    #diff -u /etc/init.d/matrix-synapse.orig /etc/init.d/matrix-synapse 
			 | 
		
	
		
			
			| 
				382
			 | 
			
				
			 | 
			
			
				-    #cp -av /etc/matrix-synapse/homeserver.yaml /etc/matrix-synapse/homeserver.yaml.orig 
			 | 
		
	
		
			
			| 
				383
			 | 
			
				
			 | 
			
			
				-    #sed -i 's|enable_registration: False|enable_registration: True|g' -i /etc/matrix-synapse/homeserver.yaml 
			 | 
		
	
		
			
			| 
				384
			 | 
			
				
			 | 
			
			
				-    #rm -f /etc/matrix-synapse/conf.d/*.orig /etc/matrix-synapse/conf.d/*~ 
			 | 
		
	
		
			
			| 
				385
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				386
			 | 
			
				
			 | 
			
			
				-    update_default_domain 
			 | 
		
	
		
			
			| 
				387
			 | 
			
				
			 | 
			
			
				-    systemctl stop matrix-synapse 
			 | 
		
	
		
			
			| 
				388
			 | 
			
				
			 | 
			
			
				-    systemctl start matrix-synapse 
			 | 
		
	
		
			
			| 
				389
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				390
			 | 
			
				
			 | 
			
			
				-    firewall_add synapse ${SYNAPSE_PORT} 
			 | 
		
	
		
			
			| 
				391
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				392
			 | 
			
				
			 | 
			
			
				-    SYNAPSE_ONION_HOSTNAME=$(add_onion_service synapse ${SYNAPSE_PORT} ${SYNAPSE_PORT}) 
			 | 
		
	
		
			
			| 
				393
			 | 
			
				
			 | 
			
			
				-    if [ ! ${SYNAPSE_PASSWORD} ]; then 
			 | 
		
	
		
			
			| 
				394
			 | 
			
				
			 | 
			
			
				-        if [ -f ${IMAGE_PASSWORD_FILE} ]; then 
			 | 
		
	
		
			
			| 
				395
			 | 
			
				
			 | 
			
			
				-            SYNAPSE_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" 
			 | 
		
	
		
			
			| 
				396
			 | 
			
				
			 | 
			
			
				-        else 
			 | 
		
	
		
			
			| 
				397
			 | 
			
				
			 | 
			
			
				-            SYNAPSE_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})" 
			 | 
		
	
		
			
			| 
				398
			 | 
			
				
			 | 
			
			
				-        fi 
			 | 
		
	
		
			
			| 
				399
			 | 
			
				
			 | 
			
			
				-    fi 
			 | 
		
	
		
			
			| 
				400
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				401
			 | 
			
				
			 | 
			
			
				-    add_user_synapse "${MY_USERNAME}" "${SYNAPSE_PASSWORD}" 
			 | 
		
	
		
			
			| 
				402
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				403
			 | 
			
				
			 | 
			
			
				-    #install_matrix_irc_bridge 
			 | 
		
	
		
			
			| 
				404
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				405
			 | 
			
				
			 | 
			
			
				-    APP_INSTALLED=1 
			 | 
		
	
		
			
			| 
				406
			 | 
			
				
			 | 
			
			
				-} 
			 | 
		
	
		
			
			| 
				407
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				408
			 | 
			
				
			 | 
			
			
				-# NOTE: deliberately no exit 0 
			 |