-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-magento
65 lines (47 loc) · 1.59 KB
/
setup-magento
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
#!/bin/bash
echo "ENTER BASE PATH"
read BASE_PATH
if [ ! -d $BASE_PATH ]
then
echo "Directory $BASE_PATH DOES NOT exists."
exit 1
fi
echo "ENTER PROJECT NAME"
read PROJECT_NAME
#Create project directory
PROJECT_PATH=$BASE_PATH/$PROJECT_NAME
if [ -d $PROJECT_PATH ]
then
echo "Directory already exist."
exit 1
fi
mkdir $PROJECT_PATH
if [ ! -d $PROJECT_PATH ]
then
echo "Directory $PROJECT_PATH does not created. Please check"
exit 1
fi
echo "ENTER MAGENTO HOST"
read MAGENTO_HOST
echo "ENTER MAGENTO VERSION"
read MAGENTO_VERSION
#Copy compose file and enviroment file to PROJECT PATH
cp -r magento/. $PROJECT_PATH
# move to project path
cd $PROJECT_PATH
sed -i "s/MAGENTO_VERSION=latest/MAGENTO_VERSION=$MAGENTO_VERSION/g" .env
sed -i "s/MAGENTO_HOST=local.test/MAGENTO_HOST=$MAGENTO_HOST/g" env/magento.env
sed -i "s/VIRTUAL_HOST=local.test/VIRTUAL_HOST=$MAGENTO_HOST/g" env/magento.env
sed -i "s/MAGENTO_DATABASE_NAME=magento/MAGENTO_DATABASE_NAME=$PROJECT_NAME/g" env/magento.env
sed -i "s/magento_data/$PROJECT_NAME/g" docker-compose.yaml
sed -i "s/container-name/$PROJECT_NAME/g" docker-compose.yaml
sed -i "s/service_name/$PROJECT_NAME/g" docker-compose.yaml
#Create database
docker exec -i mariadb mysql -u magento -e "create database $PROJECT_NAME"
docker compose up -d
if [ $( docker ps -a | grep $PROJECT_NAME | wc -l ) -gt 0 ]; then
echo "use comand: docker logs -f $PROJECT_NAME to check if all is ok"
echo "Remember to create url $MAGENTO_HOST to be able to connect to magento"
else
echo "magento seems not to be started. Please check with docker command "
fi