forked from Hasnayeen/invobook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·104 lines (81 loc) · 2.17 KB
/
install.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
red=`tput setaf 1`
green=`tput setaf 2`
pink=`tput setaf 5`
blue=`tput setaf 4`
reset=`tput sgr0`
echo -n "${blue}Install for production environment? (Y/n):${reset}"
read -n 1 ans
echo ''
echo "${pink}"
if [[ ( "$ans" == "Y" ) || ( "$ans" == "y" ) ]]
then
local=''
echo 'Installing for production environment'
else
local='local'
echo 'Installing for local environment'
fi
echo "${reset}"
echo ''
if [[ ! -e docker-compose.yml && ! $local == "local" ]]
then
echo "${pink}Creating docker-compose.yml file...${reset}"
cp docker-compose.yml.example docker-compose.yml
echo "${green}Created docker-compose.yml file${reset}"
fi
# Check for docker installation
which docker && docker --version | grep "Docker version"
if [ $? -eq 0 ]
then
echo ""
echo "${green}Docker is installed${reset}"
echo ""
else
echo ""
echo "${red}Error: Please install docker before installing Goodwork software${reset}"
echo ""
exit 1
fi
# Check for docker-compose installation
which docker-compose && docker-compose --version | grep "docker-compose version"
if [ $? -eq 0 ]
then
echo ""
echo "${green}Docker-compose is installed${reset}"
echo ""
else
echo ""
echo "${red}Error: Please install docker-compose before installing Goodwork software${reset}"
echo ""
exit 1
fi
if [[ $local == "local" ]]
then
COMPOSE="docker-compose -f docker-compose.dev.yml"
else
COMPOSE="docker-compose"
fi
$COMPOSE build php
if [[ $local == "local" ]]
then
$COMPOSE run --rm -w /var/www php composer install
else
$COMPOSE run --rm -w /var/www php composer install --optimize-autoloader --no-dev
fi
$COMPOSE up -d
$COMPOSE run --rm -w /var/www php php artisan key:generate
$COMPOSE run --rm -w /var/www php chmod -R 777 /var/www/storage
$COMPOSE run --rm -w /var/www php php artisan migrate:fresh --seed --force
$COMPOSE run --rm -w /var/www php php artisan route:cache
$COMPOSE run --rm -w /var/www php php artisan storage:link
echo ""
echo "${green}Installation complete.${reset}"
echo ""
echo ""
echo "${blue}Your application is running at :"
awk 'BEGIN{FS="=";RS="\n"}{if($1 == "APP_URL") print $2}' .env
echo "${reset}"
echo ""
# Exit from the script with success (0)
exit 0