-
Notifications
You must be signed in to change notification settings - Fork 1
/
make_site.sh
executable file
·60 lines (49 loc) · 2.24 KB
/
make_site.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
#!/bin/bash
export site=$1
export platform=drupal7.gizmo
export uri=$site.$platform
export root=/var/www/drupal7
echo Making a site $site
rm -r $site
rsync -a template/ $site
chmod g+w $site/
ln -s $site $site.$platform
# Adjust the prefix and sitename (a rough substitution)
sed -i bak "s/SITE/$site/" $site/template.alias.drushrc.php
sed -i bak "s/URI/$uri/" $site/template.alias.drushrc.php
sed -i bak "s@ROOT@$root@" $site/template.alias.drushrc.php
mv $site/template.alias.drushrc.php $site/$site.alias.drushrc.php
ln -s $site.alias.drushrc.php $site/$uri.alias.drushrc.php
export db=d7_$site;
echo "DROP DATABASE $db;" | mysql -u root -pswordfish ;
echo "CREATE DATABASE $db; GRANT ALL ON $db.* to phpuser" | mysql -u root -pswordfish ;
echo Created a new site directory called $site, and linked to it for use with multisites.
## Hints for HOSTNAME setup.
#
# To genuinely be able to just invent local websites on the fly,
# You also need DNS to be co-operating.
# If this were a live hostname, you can set DNS to wildcard *.hostname and win.
# But for local devs, it's trickier.
# Option A: Hand-edit /etc/hosts all the time. Boo.
# Option B: run you own local, limited DNS server and wildcard your own computer name.
# To do B.
# On OSX Yosemite. (ndsmasq also works on other systems, but the install steps are different)
#
# hostname='gizmo'; # Name this whatever suits you. My sites will be on *.gizmo
# brew tap homebrew/services
# brew install -v dnsmasq
# echo "address=/.${hostname}/127.0.0.1" > $(brew --prefix)/etc/dnsmasq.conf
# echo "listen-address=127.0.0.1' >> $(brew --prefix)/etc/dnsmasq.conf
# echo 'port=35353' >> $(brew --prefix)/etc/dnsmasq.conf
# brew services start dnsmasq
# sudo mkdir -v /etc/resolver
# sudo bash -c "echo 'nameserver 127.0.0.1' > /etc/resolver/${hostname}"
# sudo bash -c "echo 'port 35353' >> /etc/resolver/${hostname}"
# Now restart your network (eg disable wireless and re-anable it)
# ping -c 3 mynewwildcard.${hostname}
# And you should see 127.0.0.1
#
# This quickstart is distilled from process I developed on Ubuntu with Vagrant, then OSX,
# Updated 2015 thanks to some OSX10 updates from ALAN IVEY
# https://echo.co/blog/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew
#