A Road-Warrior type install script for a matrix bot manager.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

secure-db-install.sh 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #! /bin/bash
  2. panic(){ echo -e "$@"; echo "Exiting."; exit 2; }
  3. spacer(){ echo -e "\n - - - - - - - - - "; }
  4. info(){ echo -e "\e[0;32m$@\e[0m"; }
  5. [[ "root" == $(whoami) ]] || panic "Must run as root."
  6. #
  7. cd /opt/maubot
  8. . bin/activate
  9. packageList=()
  10. packageList+=("libolm-dev")
  11. packageList+=("python3-dev")
  12. packageList+=("build-essential")
  13. pip3_packages=()
  14. pip3_packages+=("asyncpg")
  15. pip3_packages+=("python-olm")
  16. pip3_packages+=("pycryptodome")
  17. pip3_packages+=("unpaddedbase64")
  18. pip3_packages+=("urllib3")
  19. pip3_packages+=("maubot[all]==0.2.2a1")
  20. info "Updating packages informations"
  21. apt-get update >/dev/null
  22. info "Installing packages ${packageList[@]}"
  23. apt-get install --no-install-recommends -y ${packageList[@]} >/dev/null
  24. info "Installing python packages ${pip3_packages[@]}"
  25. pip3 install ${pip3_packages[@]} >/dev/null
  26. systemctl stop maubot.service
  27. if egrep -q "^crypto_database" config.yaml; then
  28. if egrep -q "^crypto_database: default" config.yaml ; then
  29. sed -i -E 's=^(crypto_database:.*)=crypto_database: sqlite:///crypto.db=' config.yaml
  30. fi
  31. else
  32. sed -i -E 's=^(database:.*)=\1\ncrypto_database: sqlite:///crypto.db=' config.yaml
  33. fi
  34. rm /opt/maubot/maubot.db
  35. systemctl start maubot.service
  36. alembic upgrade head
  37. systemctl status maubot.service
  38. cat << EOF
  39. 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
  40. Connect to the panel using the login and password provided earlier for install.sh
  41. EOF
  42. bin/mbc login
  43. cat << EOF
  44. 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)
  45. It is important that the user used has www-data rights, otherwise the authentication will not work.
  46. Generate the token and the device ID by connecting with the matrix user.
  47. EOF
  48. bin/mbc auth --update-client
  49. EOF