forked from redhat-developer/developers.redhat.com
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup_local_drupal.sh
executable file
·120 lines (95 loc) · 3.19 KB
/
setup_local_drupal.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
# These locations should not need to change
USER=$(whoami)
GROUP=$(groups | awk '{ print $1 }')
PROJ=$(pwd)
DRUPAL="${PROJ}/_docker/drupal"
DRUPAL_FILESYSTEM="${DRUPAL}/drupal-filesystem"
WEB="${DRUPAL_FILESYSTEM}/web"
THEME="${WEB}/themes/custom/rhdp"
ENVIRON="${PROJ}/_docker/environments/drupal-dev"
# Getting the database going, because we can't really do much until this is up
docker-compose -p drupaldev -f "${ENVIRON}/docker-compose.yml" up -d drupalmysql
echo "Waiting until the database is up..."
php <<'DBCHECK'
<?php
$conn = NULL;
while ($conn === NULL) {
try {
$conn = new PDO('mysql:host=docker;dbname=rhd_mysql', 'drupal', 'drupal');
$conn->query('SELECT 1;');
} catch (PDOException $exception) {
sleep(5);
}
}
$conn = NULL;
DBCHECK
echo "Running composer install"
# Install Drupal
cd ${DRUPAL_FILESYSTEM}
composer install
# Symlink the rest of the files and folders needed
echo "Creating symlinks if needed"
if [ ! -f "${WEB}/sites/default/rhd.settings.php" ]
then
sudo ln -s ${ENVIRON}/rhd.settings.php ${WEB}/sites/default/rhd.settings.php
fi
# Symlink the static images directory
if [ ! -d "${WEB}/images" ]
then
sudo ln -s ${DRUPAL_FILESYSTEM}/static/images/ ${WEB}/images
fi
# Symlink the static rhdp-apps folder
if [ ! -d "${WEB}/rhdp-apps" ]
then
sudo ln -s ${DRUPAL_FILESYSTEM}/static/rhdp-apps/ ${WEB}/rhdp-apps
fi
# ADD from docker active config, files
echo "\nAdding the active config from the prod dump"
rm -rf ${WEB}/config/active
mkdir ${WEB}/config/active
# Get the running docker full name from partial name
runingDockerName=$(docker ps --format '{{.Names}}' --filter 'name=drupaldev_drupalmysql_' | head -n 1)
if [ $runingDockerName == "" ]
then
echo "No Container found"
exit 1
else
echo "Found Container: $runingDockerName"
fi
#Test contaner found starts with correct name exit script if not
if [[ $runingDockerName == drupaldev_drupalmysql_* ]]
then
echo "We have a container of the correct name"
sudo docker cp $runingDockerName:/var/www/drupal/web/config/active ${WEB}/config
sudo chown -R ${USER}:${GROUP} ${WEB}/config/active
echo "Adding site/files"
sudo docker cp $runingDockerName:/var/www/drupal/web/sites/default/files ${WEB}/sites/default
sudo chown -R ${USER}:${GROUP} ${WEB}/sites/default/files
else
echo "Cant find Docker container starting with drupaldev_drupalmysql_"
exit 1
fi
echo "Building css/js for theme"
cd ${THEME}/rhd-frontend
npm install && npm run-script build
cd ${PROJ}
echo "Sanitizing the database"
${WEB}/../vendor/bin/drush --root=${WEB} sqlsan --sanitize-password=drupal --sanitize-email=user+%uid@example.com
echo "Running drush cr"
${WEB}/../vendor/bin/drush --root=${WEB} cr
# Import config and update the database
echo "Running drush updb"
${WEB}/../vendor/bin/drush --root=${WEB} -y updb --entity-updates
echo "Running drush cr"
${WEB}/../vendor/bin/drush --root=${WEB} cr
echo "Running drush cr"
${WEB}/../vendor/bin/drush --root=${WEB} cr
echo "Running drush cim"
${WEB}/../vendor/bin/drush --root=${WEB} -y cim
echo "Running DB Migrations"
cd ${DRUPAL_FILESYSTEM}
vendor/bin/phinx migrate
cd ${PROJ}
echo "Starting the server"
${WEB}/../vendor/bin/drush --root=${WEB} rs