73 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
#! /bin/bash
 | 
						|
 | 
						|
 | 
						|
panic(){ echo -e "$@"; echo "Exiting."; exit 2; }
 | 
						|
spacer(){ echo -e "\n - - - - - - - - - "; }
 | 
						|
info(){ echo -e "\e[0;32m$@\e[0m"; }
 | 
						|
 | 
						|
[[ "root" == $(whoami) ]] || panic "Must run as root."
 | 
						|
 | 
						|
# 
 | 
						|
cd /opt/maubot
 | 
						|
. bin/activate
 | 
						|
 | 
						|
packageList=()
 | 
						|
packageList+=("libolm-dev")
 | 
						|
packageList+=("python3-dev") 
 | 
						|
packageList+=("build-essential")
 | 
						|
 | 
						|
pip3_packages=()
 | 
						|
pip3_packages+=("asyncpg")
 | 
						|
pip3_packages+=("python-olm")
 | 
						|
pip3_packages+=("pycryptodome")
 | 
						|
pip3_packages+=("unpaddedbase64")
 | 
						|
pip3_packages+=("urllib3")
 | 
						|
pip3_packages+=("maubot[all]==0.2.2a1")
 | 
						|
info "Updating packages informations"
 | 
						|
apt-get update >/dev/null
 | 
						|
info "Installing packages ${packageList[@]}"
 | 
						|
apt-get install --no-install-recommends -y ${packageList[@]} >/dev/null
 | 
						|
 | 
						|
info "Installing python packages ${pip3_packages[@]}"
 | 
						|
 | 
						|
pip3 install ${pip3_packages[@]} >/dev/null 
 | 
						|
 | 
						|
systemctl stop maubot.service
 | 
						|
 | 
						|
if egrep -q "^crypto_database" config.yaml; then
 | 
						|
    if egrep -q "^crypto_database: default" config.yaml ; then 
 | 
						|
        sed -i -E 's=^(crypto_database:.*)=crypto_database: sqlite:///crypto.db=' config.yaml 
 | 
						|
    fi
 | 
						|
else 
 | 
						|
    sed -i -E 's=^(database:.*)=\1\ncrypto_database: sqlite:///crypto.db=' config.yaml
 | 
						|
fi 
 | 
						|
 | 
						|
rm /opt/maubot/maubot.db
 | 
						|
 | 
						|
systemctl start maubot.service
 | 
						|
alembic upgrade head
 | 
						|
systemctl status maubot.service
 | 
						|
 | 
						|
 | 
						|
cat << EOF
 | 
						|
Now we have to authenticate on our maubot account that we created during the installation of maubot and that is accessible from its web-panel, but we will have to do it from the terminal with the mbc tool
 | 
						|
 | 
						|
Connect to the panel using the login and password provided earlier for install.sh
 | 
						|
EOF
 | 
						|
 | 
						|
bin/mbc login
 | 
						|
 | 
						|
 | 
						|
cat << EOF
 | 
						|
Once the authentication is done, we will use the same tool again to connect to our user account (bot client) that we created on the Matrix homeserver, to generate a unique token code and a device-id in order to allow the bot to have full control over the client (It is important to do it from the terminal, not from a classic matrix client)
 | 
						|
 | 
						|
It is important that the user used has www-data rights, otherwise the authentication will not work.
 | 
						|
 | 
						|
Generate the token and the device ID by connecting with the matrix user.
 | 
						|
EOF
 | 
						|
 | 
						|
bin/mbc auth --update-client
 | 
						|
 | 
						|
 | 
						|
EOF
 |