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.

135 lines
3.0 KiB

  1. #!/bin/bash
  2. # Warning: This BASH script is UNTESTED !!!
  3. # Before you start: Set DNS Record of Domain Name to this servers IP
  4. # More Infos: https://help.nextcloud.com/t/onlyoffice-compiled-with-mobile-edit-back/79282
  5. # Change your parameters here:
  6. DOMAIN_NAME="office.notice.at"
  7. CERT_EMAIL="certbot-announcements@notice.at"
  8. SECRET="changeme"
  9. # Select Container (should already be ok)
  10. CONTAINER_NAME="nemskiller007/officeunleashed"
  11. # Install Docker
  12. apt-get update
  13. apt-get install docker docker.io
  14. # Install Docker Image
  15. docker pull $CONTAINER_NAME
  16. # Run Docker Image
  17. docker run -i -t -d -p 8000:80 --restart=always $CONTAINER_NAME
  18. # Lookup Container ID
  19. # Manually: docker ps -a
  20. CONTAINER_ID=$(docker ps -aqf "$CONTAINER_NAME")
  21. # Change passwords (secret)
  22. # Set request/inbox and request/outbox to true
  23. # MANUAL approach:
  24. #docker exec -it $CONTAINER_ID /bin/bash
  25. #nano /out/linux_64/onlyoffice/documentserver/server/Common/config/default.jsoni
  26. # Go on line 155 and replace every string with secret
  27. # written in it with your own password :
  28. # Example:
  29. # "browser": {"string": "myNewSuperSecurePassw0rd", "file": "", "tenants": {}},
  30. #
  31. # Then on line 163 to 170 change all false by true
  32. # Example:
  33. # "request": {
  34. # "inbox": true,
  35. # "outbox": true
  36. # }
  37. #exit
  38. # Automated approach:
  39. CONFIG_PATH="/out/linux_64/onlyoffice/documentserver/server/Common/config/default.json"
  40. docker exec -i $CONTAINER_ID bash <<EOF
  41. sed -i 's/"secret"/"${SECRET}"/g' ${CONFIG_PATH}
  42. sed -i 's/"inbox": false,/"inbox": true,/g' ${CONFIG_PATH}
  43. sed -i 's/"outbox": false/"outbox": true/g' ${CONFIG_PATH}
  44. EOF
  45. # Restart the Docker Image
  46. docker stop $CONTAINER_ID
  47. docker start $CONTAINER_ID
  48. # Now, we've got a local installation.
  49. # but we may need to serve it for external domains.
  50. # With nginx ... and https
  51. # Install more tools
  52. apt-get install nginx certbot python3-certbot-nginx
  53. # create NGINX config
  54. cat >/etc/nginx/sites-available/$DOMAIN_NAME <<EOL
  55. upstream docservice {
  56. server ${DOMAIN_NAME}:8000;
  57. }
  58. map $http_host $this_host {
  59. "" $host;
  60. default $http_host;
  61. }
  62. map $http_x_forwarded_proto $the_scheme {
  63. default $http_x_forwarded_proto;
  64. "" $scheme;
  65. }
  66. map $http_x_forwarded_host $the_host {
  67. default $http_x_forwarded_host;
  68. "" $this_host;
  69. }
  70. map $http_upgrade $proxy_connection {
  71. default upgrade;
  72. "" close;
  73. }
  74. proxy_set_header Upgrade $http_upgrade;
  75. proxy_set_header Connection $proxy_connection;
  76. proxy_set_header X-Forwarded-Host $the_host;
  77. proxy_set_header X-Forwarded-Proto $the_scheme;
  78. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  79. server {
  80. server_tokens off;
  81. server_name ${DOMAIN_NAME};
  82. location / {
  83. proxy_pass http://docservice;
  84. proxy_http_version 1.1;
  85. }
  86. listen 0.0.0.0:80;
  87. listen [::]:80;
  88. server_name ${DOMAIN_NAME};
  89. }
  90. EOL
  91. # symlink for enabling nginx config
  92. ln -s /etc/nginx/sites-available/$DOMAIN_NAME /etc/nginx/sites-enabled/$DOMAIN_NAME
  93. # reload nginx
  94. systemctl reload nginx.service
  95. # Obtain new certificate
  96. certbot certonly -n --agree-tos --email $CERT_EMAIL --redirect -d $DOMAIN_NAME
  97. # DONE!