Created
March 29, 2017 05:25
-
-
Save omarkdev/32a2fad614a80bb704468b43f828f8a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ask_yesno() { | |
question="$1 [y|N] " | |
read -p "$question" answer | |
if [[ -z $answer ]] | |
then | |
answer=n | |
fi | |
echo "$answer" | |
} | |
env_database_config () { | |
read -p " Enter DB_DATABASE (default=tests): " database | |
if [[ -z $database ]] | |
then | |
database='tests' | |
fi | |
read -p " Enter DB_USERNAME (default=root): " username | |
if [[ -z $username ]] | |
then | |
username='root' | |
fi | |
read -p " Enter DB_PASSWORD (default=toor): " password | |
if [[ -z $password ]] | |
then | |
password='toor' | |
fi | |
read -p " Enter DB_PORT (default=3306): " port | |
if [[ -z $port ]] | |
then | |
port='3306' | |
fi | |
sed -i 's/DB_USERNAME=.*/DB_USERNAME='$username'/' .env | |
sed -i 's/DB_PASSWORD=.*/DB_PASSWORD='$password'/' .env | |
sed -i 's/DB_PORT=.*/DB_PORT='$port'/' .env | |
sed -i 's/DB_DATABASE=.*/DB_DATABASE='$database'/' .env | |
if [[ $(ask_yesno " Do you want to set the defaultStringLength for Schema to 191?") =~ ^[Yy]$ ]] | |
then | |
echo -e "\n\nSCHEMA_LENGTH=191" >> .env | |
fi | |
echo -e "\n Configured database variables!" | |
} | |
echo -e "\n" | |
if [[ $(ask_yesno " Install composer dependencies?") =~ ^[Yy]$ ]] | |
then | |
composer install | |
fi | |
echo -e "\n" | |
if [[ $(ask_yesno " Install node dependencies?") =~ ^[Yy]$ ]] | |
then | |
npm install | |
fi | |
echo -e "\nCopying .env.example" | |
cp .env.example .env | |
echo -e "\nGenerating key with artisan" | |
php artisan key:generate | |
echo -e "\n" | |
if [[ $(ask_yesno " Do you want to configure the database variables?") =~ ^[Yy]$ ]] | |
then | |
echo -e "\n" | |
env_database_config | |
fi | |
echo -e "\n" | |
if [[ $(ask_yesno ' Run the "migrate" command of the artisan?') =~ ^[Yy]$ ]] | |
then | |
php artisan migrate | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment