Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function lara(){
- RED='\033[0;31m'
- GREEN='\033[0;32m'
- NC='\033[0m'
- printf "${GREEN}What is the name of the project:${NC}"
- read PROJECT_NAME
- if [ ! -z $PROJECT_NAME ]; # Check if project name is set.
- then
- SECONDS=0
- # Prompt user for db details.
- printf "${GREEN}Specify database name:${NC}"
- read DATABASE_NAME
- printf "${GREEN}Specify database user:${NC}"
- read DATABASE_USER
- printf "${GREEN}Specify database password:${NC}"
- read DATABASE_PASS
- # Run laravel installer.
- laravel new $PROJECT_NAME
- cd $PROJECT_NAME
- # Chmod storage directory.
- chmod -R 777 storage/
- # Init git and perform first commit.
- git init
- git add -A
- git commit -m "Initial commit."
- if [ ! -z $DATABASE_USER ] && [ ! -z $DATABASE_NAME ] && [ ! -z $DATABASE_PASS ] ; # Check if db details are set.
- then
- # Create the database.
- mysql -u $DATABASE_USER -p${DATABASE_USER} -e "CREATE DATABASE IF NOT EXISTS ${DATABASE_NAME}; "
- if [ -f ./.env ];
- then
- # Set properties in .env file.
- sed -i '' -e "s/DB_DATABASE=.*/DB_DATABASE=${DATABASE_NAME}/" ./.env
- sed -i '' -e "s/DB_USERNAME=.*/DB_USERNAME=${DATABASE_USER}/" ./.env
- sed -i '' -e "s/DB_PASSWORD=.*/DB_PASSWORD=${DATABASE_PASS}/" ./.env
- fi
- fi
- echo "$(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds elapsed."
- else
- printf "${RED}No project name specified.${NC}"
- fi
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement