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.

58 lines
1.5 KiB

  1. #!/bin/bash
  2. ## Init is run on host
  3. ## For now it is run every time the script is launched, but
  4. ## it should be launched only once after build.
  5. ## Accessible variables are:
  6. ## - SERVICE_NAME Name of current service
  7. ## - DOCKER_BASE_IMAGE Base image from which this service might be built if any
  8. ## - SERVICE_DATASTORE Location on host of the DATASTORE of this service
  9. ## - SERVICE_CONFIGSTORE Location on host of the CONFIGSTORE of this service
  10. . lib/common
  11. APACHE_LOG_DIR=/var/log/apache2
  12. set -e
  13. cat <<EOF | file_put "$SERVICE_DATASTORE/var/www/html/.htaccess"
  14. <IfModule mod_rewrite.c>
  15. RewriteEngine On
  16. RewriteCond %{HTTPS} off
  17. RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  18. </IfModule>
  19. EOF
  20. rm -fv "$SERVICE_CONFIGSTORE/etc/apache2/sites-enabled/"*".conf"
  21. cat <<EOF | file_put "$SERVICE_CONFIGSTORE/etc/apache2/sites-enabled/000-default.conf"
  22. <VirtualHost *:80>
  23. ServerAdmin webmaster@localhost
  24. DocumentRoot /var/www/html
  25. <Directory />
  26. Options FollowSymLinks
  27. AllowOverride None
  28. </Directory>
  29. <Directory /var/www/html>
  30. Options Indexes FollowSymLinks MultiViews
  31. AllowOverride all
  32. Order allow,deny
  33. allow from all
  34. </Directory>
  35. ErrorLog ${APACHE_LOG_DIR}/error.log
  36. CustomLog ${APACHE_LOG_DIR}/access.log combined
  37. </VirtualHost>
  38. EOF
  39. ssh_tunnel_cfg=$(options-get ssh-tunnel 2>/dev/null) || true
  40. if [ "$ssh_tunnel_cfg" ]; then
  41. apache_ssh_tunnel "$ssh_tunnel_cfg"
  42. fi