install_primaria 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. # reset shell colors
  3. tput init
  4. # https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself
  5. SOURCE="${BASH_SOURCE[0]}"
  6. while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
  7. PROJECT_ROOT="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
  8. SOURCE="$(readlink "$SOURCE")"
  9. [[ $SOURCE != /* ]] && SOURCE="$PROJECT_ROOT/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
  10. done
  11. PROJECT_ROOT="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
  12. # required imports
  13. source "${PROJECT_ROOT}"/variables/manifest.sh
  14. source "${PROJECT_ROOT}"/utils/manifest.sh
  15. source "${PROJECT_ROOT}"/lib/manifest.sh
  16. # user configs file
  17. if [[ ! -e "${PROJECT_ROOT}"/config ]]; then
  18. cat << EOF > "${PROJECT_ROOT}"/config
  19. deploy_password=${deploy_password}
  20. mysql_root_password=${mysql_root_password}
  21. db_pass=${db_pass}
  22. EOF
  23. fi
  24. # this file has passwords
  25. sudo su - root <<EOF
  26. chown root:root "${PROJECT_ROOT}"/config
  27. chmod 700 "${PROJECT_ROOT}"/config
  28. EOF
  29. source "${PROJECT_ROOT}"/config
  30. # interactive CLI
  31. inquiry_options
  32. # dependencies related
  33. system_update
  34. system_node_install
  35. system_pm2_install
  36. system_docker_install
  37. system_puppeteer_dependencies
  38. system_snapd_install
  39. system_nginx_install
  40. system_certbot_install
  41. # system config
  42. system_create_user
  43. # backend related
  44. system_git_clone
  45. backend_set_env
  46. backend_redis_create
  47. backend_node_dependencies
  48. backend_node_build
  49. backend_db_migrate
  50. backend_db_seed
  51. backend_start_pm2
  52. backend_nginx_setup
  53. # frontend related
  54. frontend_set_env
  55. frontend_node_dependencies
  56. frontend_node_build
  57. frontend_start_pm2
  58. frontend_nginx_setup
  59. # network related
  60. system_nginx_conf
  61. system_nginx_restart
  62. system_certbot_setup