-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.sh
executable file
·67 lines (51 loc) · 1.78 KB
/
init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# Initialize the project's environment.
# Set the project's name from directory.
base_path=$(pwd)
PROJECT_NAME=$(basename $(pwd))
ask_question(){
# ask_question <question> <default>
local ANSWER
read -r -p "$1 ($2): " ANSWER
echo "${ANSWER:-$2}"
}
ask_secure_question(){
# ask_secure_question <question> <default>
local ANSWER
if [ $2 ]; then
read -r -sp "$1 ($2): " ANSWER
else
read -r -sp "$1: " ANSWER
fi
echo "${ANSWER:-$2}"
}
# Let user write the app domain and the database name, username and password.
APP_DOMAIN=$(ask_question "Enter App Domain" "$PROJECT_NAME.test")
DB_DATABASE=$(ask_question "Enter The Database Name" "$PROJECT_NAME")
DB_USERNAME=$(ask_question "Enter The Database Username" "root")
DB_PASSWORD=$(ask_secure_question "Enter The Database Password" "")
echo " "
# Create the mysql database.
mysql -u root --password=$DB_PASSWORD -e "create database $DB_DATABASE CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"
# Create the project's .env file.
sed -e "s|DB_DATABASE=scaffolding|DB_DATABASE=$DB_DATABASE|"\
-e "s|DB_USERNAME=root|DB_USERNAME=$DB_USERNAME|"\
-e "s|DB_PASSWORD=|DB_PASSWORD=$DB_PASSWORD|"\
-e "s|APP_DOMAIN=127.0.0.1|APP_DOMAIN=$APP_DOMAIN|" ./.env.example > ./.env
# Install dependencies.
composer install
# Generate the app key.
php artisan key:generate
# Create symlink for storage and media files.
php artisan storage:link
# Migrate the tables and seed accounts and dummy data.
php artisan migrate:fresh --seed
# install npm dependencies.
npm install
# compiling assets
npm run dev
echo "Installer successfully INSTALLED on " `date +"%Y-%m-%d %T"` > $base_path/storage/installed
composer app:clear
composer dump-autoload
# Print the project's URL.
echo APP_URL: http://$APP_DOMAIN