run.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env sh
  2. #
  3. # LEMP WordPress Reproducible Environment
  4. #
  5. # Currently only for development purposes
  6. #
  7. # Wishlist: Include XDebug
  8. if [ ! $# -eq 2 ]; then
  9. cat << EOF
  10. usage: $0 <shared_path> <public_path>
  11. shared_path: exchange directory
  12. public_path: public facing location, must be within shared_path
  13. ex: $0 /home/user/dev public_html
  14. EOF
  15. exit 1
  16. fi
  17. shared_path="$1"
  18. public_path="$1/$2"
  19. file_path=$(dirname "$0") # path to this file
  20. # Nginx
  21. grep -qF "root $public_path" $file_path/etc/nginx/nginx.conf ||\
  22. sed -i\
  23. -e "s|#public_path#|$public_path|"\
  24. -e "s/#worker_connections#/$(ulimit -n)/"\
  25. $file_path/etc/nginx/nginx.conf
  26. # MariaDB
  27. grep -qF "#mysqld_user#" $file_path/etc/my.cnf &&\
  28. sed -i -e "s|#mysqld_user#|$(whoami)|" $file_path/etc/my.cnf
  29. # Run the environment
  30. guix environment\
  31. --ad-hoc --container --network --no-cwd\
  32. php mariadb nginx nss-certs busybox\
  33. --share=$file_path/etc=/usr/etc\
  34. --share=$file_path/var/log=/var/log\
  35. --share=$file_path/var/lib/mysql/data=/var/lib/mysql/data\
  36. --share=$shared_path