Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ask_yesno() {
  4. question="$1 [y|N] "
  5.  
  6. read -p "$question" answer
  7.  
  8. if [[ -z $answer ]]
  9. then
  10. answer=n
  11. fi
  12.  
  13. echo "$answer"
  14. }
  15.  
  16. env_database_config () {
  17. read -p " Enter DB_DATABASE (default=tests): " database
  18.  
  19. if [[ -z $database ]]
  20. then
  21. database='tests'
  22. fi
  23.  
  24. read -p " Enter DB_USERNAME (default=root): " username
  25.  
  26. if [[ -z $username ]]
  27. then
  28. username='root'
  29. fi
  30.  
  31. read -p " Enter DB_PASSWORD (default=toor): " password
  32.  
  33. if [[ -z $password ]]
  34. then
  35. password='toor'
  36. fi
  37.  
  38. read -p " Enter DB_PORT (default=3306): " port
  39.  
  40. if [[ -z $port ]]
  41. then
  42. port='3306'
  43. fi
  44.  
  45. sed -i 's/DB_USERNAME=.*/DB_USERNAME='$username'/' .env
  46. sed -i 's/DB_PASSWORD=.*/DB_PASSWORD='$password'/' .env
  47. sed -i 's/DB_PORT=.*/DB_PORT='$port'/' .env
  48. sed -i 's/DB_DATABASE=.*/DB_DATABASE='$database'/' .env
  49.  
  50. if [[ $(ask_yesno " Do you want to set the defaultStringLength for Schema to 191?") =~ ^[Yy]$ ]]
  51. then
  52. echo -e "\n\nSCHEMA_LENGTH=191" >> .env
  53. fi
  54.  
  55. echo -e "\n Configured database variables!"
  56. }
  57.  
  58. echo -e "\n"
  59. if [[ $(ask_yesno " Install composer dependencies?") =~ ^[Yy]$ ]]
  60. then
  61. composer install
  62. fi
  63.  
  64. echo -e "\n"
  65. if [[ $(ask_yesno " Install node dependencies?") =~ ^[Yy]$ ]]
  66. then
  67. npm install
  68. fi
  69.  
  70. echo -e "\nCopying .env.example"
  71. cp .env.example .env
  72.  
  73. echo -e "\nGenerating key with artisan"
  74. php artisan key:generate
  75.  
  76. echo -e "\n"
  77. if [[ $(ask_yesno " Do you want to configure the database variables?") =~ ^[Yy]$ ]]
  78. then
  79. echo -e "\n"
  80. env_database_config
  81. fi
  82.  
  83. echo -e "\n"
  84. if [[ $(ask_yesno ' Run the "migrate" command of the artisan?') =~ ^[Yy]$ ]]
  85. then
  86. php artisan migrate
  87. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement