forked from webchick/drupal8-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmi.sh
executable file
·102 lines (82 loc) · 3.23 KB
/
cmi.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
#!/bin/bash
# Increment this as needed.
export D8_RELEASE="drupal-8.0-alpha9"
# @TODO: Variable-ize this up.
#WEBROOT="/Users/webchick/Sites"
#RELEASE="8.x-dev"
#PROD="prod"
#DEV="dev"
# Move to the web root.
cd ~/Sites
# Set up a 'bare' working repo.
rm -rf d8demo.git
mkdir d8demo.git
git init --bare --shared d8demo.git
chgrp -R staff d8demo.git
# Make a 'prod' site.
sudo rm -rf prod
git clone file:///Users/webchick/Sites/d8demo.git prod
cd prod
# Grab a "shallow copy" of the latest D8 code, since we just want the files, not
# the whole history. Then blow away its .git folder so ours doesn't conflict.
git clone --branch 8.x --depth 1 http://git.drupal.org/project/drupal.git dee-eight
rm -rf dee-eight/.git
# Move all of the D8 files into prod and destroy the temp folder.
# @todo I could avoid all of this fuckery if git supported "svn export." :P
shopt -s dotglob
mv dee-eight/* .
rmdir dee-eight
# Grab latest D8 release.
#wget http://ftp.drupal.org/files/projects/drupal-8.0-alpha9.tar.gz
#tar --strip-components=1 -zxvf drupal-8.0-alpha9.tar.gz
#rm drupal-8.0-alpha9.tar.gz
# Now populate the prod Git repo.
git add .
git commit -m "Initial commit: Add all the D8 code files."
git push origin master
# @TODO: Patches?
# This one no longer applies and I don't really have time to screw with it, so commenting it out for now.
#wget https://drupal.org/files/issues/responsive-preview-1741498-422.patch
#git apply --index responsive-preview-1741498-422.patch
#git commit -am "Applying responsive preview patch."
# Install Drupal 8: prod.
mysql -e "DROP DATABASE IF EXISTS prod; CREATE DATABASE prod;" -uroot -h127.0.0.1 -P33067
drush si --db-url=mysql://root:@127.0.0.1:33067/prod --account-pass=admin -y
# Hard-code site name to differentiate between sites.
echo "
\$config['system.site']['name'] = 'Drupal 8';" | sudo tee -a sites/default/settings.php
# Clear zee cache.
drush cache-rebuild
# Add the new files to Git.
git add sites/default/files/config_*
git add sites/default/files/php/service_container/.htaccess
git commit -m "Add CMI and compiled PHP files after initial installation."
git push
# Now, make the dev site, based on prod.
cd ~/Sites
sudo rm -rf dev
git clone file:///Users/webchick/Sites/d8demo.git dev
cd dev
# Copy over the database.
mysql -e "DROP DATABASE IF EXISTS dev; CREATE DATABASE dev;" -uroot -h127.0.0.1 -P33067
mysqldump -uroot -h127.0.0.1 -P33067 prod | mysql -uroot -h127.0.0.1 -P33067 dev
# Set the database/config directories for dev.
cp ../prod/sites/default/settings.php sites/default
echo "
\$databases['default']['default']['database'] = 'dev';
\$config_directories['active'] .= '_dev';
\$config_directories['staging'] .= '_dev';
\$config['system.site']['name'] = 'Drupal 8 [Dev]';
" | sudo tee -a sites/default/settings.php
# Copy over the prod config files to dev's directories.
export CONFIG_DIR=`find sites/default/files -type d -name "config*"`
mkdir `echo $CONFIG_DIR`/active_dev
mkdir `echo $CONFIG_DIR`/staging_dev
cp -r `echo $CONFIG_DIR`/active/* `echo $CONFIG_DIR`/active_dev/
cp -r `echo $CONFIG_DIR`/staging/* `echo $CONFIG_DIR`/staging_dev/
git add `echo $CONFIG_DIR`/active_dev
git add `echo $CONFIG_DIR`/staging_dev
git commit -m "Adding dev CMI files."
git push origin master
# Clear zee cache.
drush cache-rebuild