bootstrap.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. export DEBIAN_FRONTEND=noninteractive
  4. apt-get update
  5. apt-get install -y --no-install-recommends \
  6. apache2 \
  7. mariadb-server \
  8. php \
  9. libapache2-mod-php \
  10. php-cli \
  11. php-curl \
  12. php-gd \
  13. php-intl \
  14. php-mbstring \
  15. php-mysql \
  16. php-xml \
  17. php-zip \
  18. unzip \
  19. curl \
  20. ca-certificates
  21. a2enmod rewrite headers expires
  22. echo "ServerName desktop-support.test" >/etc/apache2/conf-available/servername.conf
  23. a2enconf servername
  24. cat >/etc/apache2/sites-available/desktop-support.conf <<'APACHE'
  25. <VirtualHost *:80>
  26. ServerName desktop-support.test
  27. DocumentRoot /vagrant/public
  28. <Directory /vagrant/public>
  29. Options Indexes FollowSymLinks
  30. AllowOverride All
  31. Require all granted
  32. </Directory>
  33. ErrorLog ${APACHE_LOG_DIR}/desktop-support-error.log
  34. CustomLog ${APACHE_LOG_DIR}/desktop-support-access.log combined
  35. </VirtualHost>
  36. APACHE
  37. a2dissite 000-default.conf
  38. a2ensite desktop-support.conf
  39. cat >/etc/php/development-overrides.ini <<'PHP'
  40. display_errors = On
  41. display_startup_errors = On
  42. error_reporting = E_ALL
  43. date.timezone = America/New_York
  44. PHP
  45. PHP_VERSION="$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')"
  46. ln -sf /etc/php/development-overrides.ini "/etc/php/${PHP_VERSION}/apache2/conf.d/99-development.ini"
  47. ln -sf /etc/php/development-overrides.ini "/etc/php/${PHP_VERSION}/cli/conf.d/99-development.ini"
  48. systemctl enable --now mariadb apache2
  49. install -d -m 0750 -o root -g www-data /etc/desktop-resume
  50. if [ -f /vagrant/.env ]; then
  51. RESEND_KEY="$(sed -n 's/^RESEND_KEY=//p' /vagrant/.env | head -n 1 | tr -d '\r')"
  52. if [ -n "$RESEND_KEY" ]; then
  53. printf 'RESEND_API_KEY=%s\nRESEND_FROM=%s\n' "$RESEND_KEY" 'Desktop Support Portfolio <contact@jadenportfolio.com>' >/etc/desktop-resume/contact.env
  54. chown root:www-data /etc/desktop-resume/contact.env
  55. chmod 0640 /etc/desktop-resume/contact.env
  56. fi
  57. fi
  58. mariadb <<'SQL'
  59. CREATE DATABASE IF NOT EXISTS desktop_support
  60. CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  61. CREATE USER IF NOT EXISTS 'desktop_support'@'localhost' IDENTIFIED BY 'development_only';
  62. GRANT ALL PRIVILEGES ON desktop_support.* TO 'desktop_support'@'localhost';
  63. FLUSH PRIVILEGES;
  64. SQL
  65. apache2ctl configtest
  66. systemctl restart apache2
  67. echo "LAMP provisioning complete: http://localhost:8080"