docker-run.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh
  2. if [[ -z "$GID" ]]; then
  3. GID="$UID"
  4. fi
  5. # Define functions.
  6. function fixperms {
  7. chown -R $UID:$GID /data
  8. # /opt/mautrix-whatsapp is read-only, so disable file logging if it's pointing there.
  9. if [[ "$(yq e '.logging.directory' /data/config.yaml)" == "./logs" ]]; then
  10. yq -I4 e -i '.logging.file_name_format = ""' /data/config.yaml
  11. fi
  12. }
  13. if [[ ! -f /data/config.yaml ]]; then
  14. cp /opt/mautrix-whatsapp/example-config.yaml /data/config.yaml
  15. echo "Didn't find a config file."
  16. echo "Copied default config file to /data/config.yaml"
  17. echo "Modify that config file to your liking."
  18. echo "Start the container again after that to generate the registration file."
  19. exit
  20. fi
  21. if [[ ! -f /data/registration.yaml ]]; then
  22. /usr/bin/mautrix-whatsapp -g -c /data/config.yaml -r /data/registration.yaml || exit $?
  23. echo "Didn't find a registration file."
  24. echo "Generated one for you."
  25. echo "See https://docs.mau.fi/bridges/general/registering-appservices.html on how to use it."
  26. exit
  27. fi
  28. cd /data
  29. fixperms
  30. exec su-exec $UID:$GID /usr/bin/mautrix-whatsapp