Advertisement
Guest User

Untitled

a guest
Jul 18th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. function lara(){
  2. RED='\033[0;31m'
  3. GREEN='\033[0;32m'
  4. NC='\033[0m'
  5.  
  6. printf "${GREEN}What is the name of the project:${NC}"
  7. read PROJECT_NAME
  8.  
  9. if [ ! -z $PROJECT_NAME ]; # Check if project name is set.
  10. then
  11. SECONDS=0
  12.  
  13. # Prompt user for db details.
  14. printf "${GREEN}Specify database name:${NC}"
  15. read DATABASE_NAME
  16.  
  17. printf "${GREEN}Specify database user:${NC}"
  18. read DATABASE_USER
  19.  
  20. printf "${GREEN}Specify database password:${NC}"
  21. read DATABASE_PASS
  22.  
  23. # Run laravel installer.
  24. laravel new $PROJECT_NAME
  25. cd $PROJECT_NAME
  26.  
  27. # Chmod storage directory.
  28. chmod -R 777 storage/
  29.  
  30. # Init git and perform first commit.
  31. git init
  32. git add -A
  33. git commit -m "Initial commit."
  34.  
  35. if [ ! -z $DATABASE_USER ] && [ ! -z $DATABASE_NAME ] && [ ! -z $DATABASE_PASS ] ; # Check if db details are set.
  36. then
  37.  
  38. # Create the database.
  39. mysql -u $DATABASE_USER -p${DATABASE_USER} -e "CREATE DATABASE IF NOT EXISTS ${DATABASE_NAME}; "
  40.  
  41. if [ -f ./.env ];
  42. then
  43. # Set properties in .env file.
  44. sed -i '' -e "s/DB_DATABASE=.*/DB_DATABASE=${DATABASE_NAME}/" ./.env
  45. sed -i '' -e "s/DB_USERNAME=.*/DB_USERNAME=${DATABASE_USER}/" ./.env
  46. sed -i '' -e "s/DB_PASSWORD=.*/DB_PASSWORD=${DATABASE_PASS}/" ./.env
  47. fi
  48.  
  49. fi
  50. echo "$(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds elapsed."
  51. else
  52. printf "${RED}No project name specified.${NC}"
  53. fi
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement