├── .gitignore ├── LICENSE ├── README.md ├── Vagrantfile ├── codespell-install.sh ├── compass-install.sh ├── git-config.sh ├── hosts.sh ├── less-install.sh ├── phpmyadmin-install.sh ├── restart-lemp.sh ├── site-db.sh ├── site-files.sh ├── site-fix.sh ├── site-install.sh ├── site-log.sh ├── site-sync.sh ├── ssh-config.sh ├── vim-install.sh ├── webmin-install.sh ├── xdebug-install.sh └── xhprof-install.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore configuration files that may contain sensitive information. 2 | sites/*/*settings*.php 3 | 4 | # Ignore paths that contain generated content. 5 | files/ 6 | sites/*/files 7 | sites/*/private 8 | 9 | # Ignore default text files 10 | robots.txt 11 | /CHANGELOG.txt 12 | /COPYRIGHT.txt 13 | /INSTALL*.txt 14 | /LICENSE.txt 15 | /MAINTAINERS.txt 16 | /UPGRADE.txt 17 | /README.txt 18 | sites/all/README.txt 19 | sites/all/modules/README.txt 20 | sites/all/themes/README.txt 21 | 22 | # Ignore everything but the "sites" folder ( for non core developer ) 23 | .htaccess 24 | web.config 25 | authorize.php 26 | cron.php 27 | index.php 28 | install.php 29 | update.php 30 | xmlrpc.php 31 | /includes 32 | /misc 33 | /modules 34 | /profiles 35 | /scripts 36 | /themes 37 | 38 | # Ignore Vagrant files 39 | .vagrant/* 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Introduction 2 | ------------ 3 | The purpose of this project is to create a useful local development environment to build Drupal sites hosted on Pantheon. Since the infrastructure is built on VirtualBox, this configuration can work on virtually any host operating system. The entire LEMP stack is installed and configured. Drupal installations are fully automated based on existing Pantheon Site Names. This includes Nginx virtual hosts, PHP configuration, MySQL databases and user permissions, and Drupal site installs via installation profiles. 4 | 5 | Updates 6 | ------- 7 | 2015-10-13: This project is now using Nginx, which more closely resembles the Pantheon infrastructure. Also, Debian has been upgraded from version 7 (aka wheezy) to 8 (aka jessie). 8 | 9 | Prerequisites 10 | ------------- 11 | Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads). 12 | 13 | Install [VirtualBox Extension Pack](https://www.virtualbox.org/wiki/Downloads). 14 | 15 | Install [Vagrant](http://www.vagrantup.com/downloads.html). 16 | 17 | Install Git (MAC/BSD/Linux) via your package manager or Git Bash (Windows). See [Git for Windows](https://msysgit.github.io/). 18 | 19 | Installation 20 | ------------ 21 | Open Terminal (MAC/BSD/Linux) or Git Bash (Windows). Windows users should run as administrator. 22 | 23 | See [Configure Applications to Always Run as an Administrator](https://technet.microsoft.com/en-us/magazine/ff431742.aspx). 24 | 25 | Although not necessary, if you want to open VirtualBox, you should also run as administrator. 26 | 27 | **Replace *site* with the Pantheon Site Name and optionally *[env]* with the environment.** 28 | 29 | > $ git config --global core.autocrlf false **This step is important** 30 | 31 | > $ git clone https://github.com/uberhacker/pantheon-local-drupal-development.git 32 | 33 | > $ cd pantheon-local-drupal-development 34 | 35 | > $ vagrant up 36 | 37 | > $ vagrant ssh 38 | 39 | > vagrant@debian:~$ ssh-config 40 | 41 | > vagrant@debian:~$ git-config (follow prompts) 42 | 43 | > vagrant@debian:~$ site-install (follow prompts) 44 | 45 | > vagrant@debian:~$ exit 46 | 47 | > $ hosts.sh add *site* *[env]* 48 | 49 | Visit http://*site*-*env*.site in your favorite browser (Example: http://my-pantheon-dev.site where my-pantheon is the Pantheon Site Name and dev is the environment). Enjoy. 50 | 51 | Usage 52 | ----- 53 | Once the VM has been provisioned, if you want to create additional sites, simply execute the following: 54 | 55 | > $ cd /path/to/pantheon-local-drupal-development 56 | 57 | > $ vagrant up 58 | 59 | > $ vagrant ssh 60 | 61 | > vagrant@debian:~$ site-install *site* *env* *profile* *multisite* 62 | 63 | **Replace *site* with the Pantheon Site Name, *env* with the environment, *profile* with the Drupal install profile and *multisite* with the Drupal multisite domain** 64 | On site-install, if you don't provide *site*, *env*, *profile* or *multisite*, you will be prompted to enter the appropriate values if needed. 65 | 66 | > vagrant@debian:~$ exit 67 | 68 | > $ hosts.sh add *site* *[env]* 69 | 70 | The default value for *env* is dev. The only time you would want to provide *env* is if you are installing a multi-dev site. 71 | 72 | Maintenance 73 | ----------- 74 | To restart the LEMP stack: 75 | > vagrant@debian:~$ restart-lemp 76 | 77 | To repair the database and file permissions: 78 | > vagrant@debian:~$ site-fix *site* 79 | 80 | To display the Nginx logs: 81 | > vagrant@debian:~$ site-log *site* *env* [access|error] [less|tail] 82 | 83 | The *site* and *env* arguments are not needed if you are within the Drupal root directory and want to accept the defaults. 84 | The default value for *env* is dev. If the third or fourth arguments are omitted, the default values are error and tail. 85 | 86 | To download the latest database and upload to your local database: 87 | > vagrant@debian:~$ site-db *site* *env* 88 | 89 | To download the latest files backup to your local environment: 90 | > vagrant@debian:~$ site-files *site* *env* 91 | 92 | To download the latest code, files and database backup to your local environment: 93 | > vagrant@debian:~$ site-sync *site* *env* 94 | 95 | To list hosts: 96 | > $ hosts.sh list 97 | 98 | Optional 99 | -------- 100 | Install phpMyAdmin: 101 | > vagrant@debian ~$ phpmyadmin-install 102 | 103 | Install vim configured for Drupal: 104 | > vagrant@debian ~$ vim-install 105 | 106 | Install webmin: 107 | > vagrant@debian ~$ webmin-install 108 | 109 | Install codespell: 110 | > vagrant@debian ~$ codespell-install 111 | 112 | Install compass: 113 | > vagrant@debian ~$ compass-install 114 | 115 | Install less: 116 | > vagrant@debian ~$ less-install 117 | 118 | Install XHProf: 119 | > vagrant@debian ~$ xhprof-install 120 | 121 | Install Xdebug: 122 | > vagrant@debian ~$ xdebug-install 123 | 124 | Troubleshooting 125 | --------------- 126 | **If you notice an error similar to the following:** 127 | > ./hosts.sh: line 17: /C/Windows/System32/drivers/etc/hosts: Permission denied 128 | 129 | > Make sure the hosts file is not read only. Navigate to C:\Windows\System32\drivers\etc in File Explorer. Right click on hosts, select Properties, uncheck the Read-only box next to Attributes: and then click OK. 130 | 131 | **If you forgot to execute the first step: git config --global core.autocrlf false, you may not be able to execute git-config or site-install. To fix, execute the following:** 132 | > vagrant@debian:~$ dos2unix /vagrant/git-config.sh 133 | 134 | > vagrant@debian:~$ dos2unix /vagrant/site-install.sh 135 | 136 | **If you are having trouble with rsync during vagrant up in Windows with a message as follows:** 137 | > "rsync" could not be found on your PATH. Make sure that rsync 138 | is properly installed on your system and available on the PATH. 139 | 140 | > Download cwRsync Free Edition, extract and copy into your Git bin directory (usually in C:\Program Files\Git\bin or C:\Program Files (x86)\Git\bin). 141 | 142 | > $ vagrant plugin install vagrant-rsync 143 | 144 | > $ vagrant reload 145 | 146 | **If you installed cwRsync as instructed above and execute vagrant ssh, you may get a message similar to the following:** 147 | > cygwin warning: 148 | MS-DOS style path detected: .../.vagrant/machines/default/virtualbox/private_key 149 | Preferred POSIX equivalent is: .../.vagrant/machines/default/virtualbox/private_key 150 | CYGWIN environment variable option "nodosfilewarning" turns off this warning. 151 | Consult the user's guide for more details about POSIX paths: 152 | http://cygwin.com/cygwin-ug-net/using.html#using-pathnames 153 | 154 | > *If you don't get a vagrant@debian:~$ prompt, press Ctrl+C and try connecting via iTerm 2 (MAC) or PuTTY (Windows). See Tips section below for more details.* 155 | 156 | **If rsync still doesn't work with Vagrant 1.8:** 157 | > See this workaround: https://github.com/mitchellh/vagrant/issues/6702#issuecomment-166503021 158 | 159 | **If you get a message that states GuestAdditions are missing or not matching the host version during vagrant up, try the following:** 160 | > $ cd /path/to/pantheon-local-drupal-development 161 | 162 | > $ cp "C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso" . <<< Don't forget the trailing dot 163 | 164 | > $ vagrant reload 165 | 166 | > $ vagrant ssh (see previous troubleshooting tip if you have issues) 167 | 168 | > vagrant@debian:~$ sudo mkdir /media/vb 169 | 170 | > vagrant@debian:~$ sudo mount -t iso9660 -o loop /vagrant/VBoxGuestAdditions.iso /media/vb 171 | 172 | > vagrant@debian:~$ cd /media/vb 173 | 174 | > vagrant@debian:~$ sudo ./VBoxLinuxAdditions.run 175 | 176 | > vagrant@debian:~$ exit 177 | 178 | > $ vagrant reload 179 | 180 | Alternatively, you could install from the iso on the VM if you know the host version is the same. 181 | 182 | Just replace /vagrant/VBoxGuestAdditions.iso with /usr/share/virtualbox/VBoxGuestAdditions.iso on the mount line above. 183 | 184 | Follow the steps below: 185 | 186 | > vagrant@debian:~$ sudo mkdir /media/vb 187 | 188 | > vagrant@debian:~$ sudo mount -t iso9660 -o loop /usr/share/virtualbox/VBoxGuestAdditions.iso /media/vb 189 | 190 | > vagrant@debian:~$ cd /media/vb 191 | 192 | > vagrant@debian:~$ sudo ./VBoxLinuxAdditions.run 193 | 194 | > vagrant@debian:~$ exit 195 | 196 | > $ vagrant reload 197 | 198 | **If you are unable to bring up the site in your browser after vagrant up in Windows 10, try reinstalling VirtualBox to get the bridged network working again.** 199 | 200 | Tips 201 | ---- 202 | **Use iTerm 2 (MAC) or PuTTY (Windows) to connect via 192.168.33.10 with username vagrant and password vagrant to improve your terminal experience.** 203 | 204 | > Download iTerm 2 (MAC) or PuTTY (Windows). 205 | 206 | **To check your code syntax for errors:** 207 | > vagrant@debian:~$ cd /path/to/custom/code/directory 208 | 209 | > vagrant@debian:~$ drupalcs my_custom_module/ 210 | 211 | **To automatically fix code syntax errors:** 212 | > vagrant@debian:~$ cd /path/to/custom/code/directory 213 | 214 | > vagrant@debian:~$ drupalcbf my_custom_module/ 215 | 216 | **To spell check your code for errors:** 217 | > vagrant@debian ~$ codespell-install 218 | 219 | > vagrant@debian:~$ cd /path/to/custom/code/directory 220 | 221 | > vagrant@debian:~$ codespell my_custom_module/ 222 | 223 | **To examine your database:** 224 | > vagrant@debian ~$ phpmyadmin-install 225 | 226 | > Browse to http://192.168.33.10:8080 and login with Username: drupal and Password: drupal 227 | 228 | **To update all composer installed apps (drush, terminus, etc.):** 229 | > vagrant@debian ~$ composer-up 230 | 231 | **To get the ip address of the server:** 232 | > vagrant@debian ~$ ip 233 | 234 | **To adjust the VM resources:** 235 | > If your host system supports it, you can increase the vb.cpus and vb.memory values in Vagrantfile to improve performance of the VM. Remember to vagrant reload after making changes. 236 | 237 | **A warning about synced folders:** 238 | > If you want to reinstall a site using site-install and you have enabled synced folders, you should clear out your synced folder locally beforehand, otherwise you may notice errors when the script attempts to remove existing files. 239 | 240 | Faq 241 | --- 242 | Q. Can I install more than one site? 243 | 244 | A. Absolutely. Just execute site-install and make sure the site name is not the same as an existing site, otherwise, it will be overwrote. Also, the site must first exist in your Pantheon dashboard. 245 | 246 | 247 | Q. Can I install a multi-dev site? 248 | 249 | A. Absolutely. Just make sure the site already exists in your Pantheon dashboard and include the multi-site name in the *env* argument. 250 | 251 | 252 | Q. Where do I access my site on the server? 253 | 254 | A. All sites are subdirectories of /var/www. So if your site is a dev environment of my-site, it would be located at /var/www/my-site-dev. 255 | 256 | 257 | Q. Why don't I see my VM instance running after I launch VirtualBox in Windows? 258 | 259 | A. Did you launch VirtualBox as administrator? If you started Git Bash as administrator, you must also start VirtualBox as administrator, otherwise, you will not see any running instances. Another reason might be you didn't execute "vagrant up" in the Git Bash terminal. 260 | 261 | 262 | Q. Why do I get the message "The Pantheon site cannot be located." when attempting to load the live environment database into my local environment? 263 | 264 | A. In order to pull down the live envirnoment database, you must execute the "site-db my-site live" command within the Drupal root of your local environment, otherwise, the command will not be able to locate your local "cloneable" environment. 265 | 266 | 267 | Q. Where is Solr? 268 | 269 | A. I may plan to install Solr in a future release. 270 | 271 | 272 | Q. Where is Varnish? 273 | 274 | A. I may plan to install Varnish in a future release. 275 | 276 | 277 | Q. Why did you choose Debian instead of Ubuntu or CentOS? 278 | 279 | A. This is a very good question. I felt Debian was lightweight and included everything I needed for a barebones development environment I could build around. I also figured it would be easier to upgrade without having to reconfigure or reinstall the entire operating system. 280 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # All Vagrant configuration is done below. The "2" in Vagrant.configure 5 | # configures the configuration version (we support older styles for 6 | # backwards compatibility). Please don't change it unless you know what 7 | # you're doing. 8 | Vagrant.configure(2) do |config| 9 | # The most common configuration options are documented and commented below. 10 | # For a complete reference, please see the online documentation at 11 | # https://docs.vagrantup.com. 12 | 13 | # Every Vagrant development environment requires a box. You can search for 14 | # boxes at https://atlas.hashicorp.com/search. 15 | config.vm.box = "debian/jessie64" 16 | 17 | # Disable automatic box update checking. If you disable this, then 18 | # boxes will only be checked for updates when the user runs 19 | # `vagrant box outdated`. This is not recommended. 20 | # config.vm.box_check_update = false 21 | 22 | # Create a forwarded port mapping which allows access to a specific port 23 | # within the machine from a port on the host machine. In the example below, 24 | # accessing "localhost:8080" will access port 80 on the guest machine. 25 | # config.vm.network "forwarded_port", guest: 80, host: 8080 26 | 27 | # Create a private network, which allows host-only access to the machine 28 | # using a specific IP. 29 | config.vm.network "private_network", ip: "192.168.33.10" 30 | 31 | # Create a public network, which generally matched to bridged network. 32 | # Bridged networks make the machine appear as another physical device on 33 | # your network. 34 | # config.vm.network "public_network" 35 | 36 | # Share an additional folder to the guest VM. The first argument is 37 | # the path on the host to the actual folder. The second argument is 38 | # the path on the guest to mount the folder. And the optional third 39 | # argument is a set of non-required options. 40 | # config.vm.synced_folder "../data", "/vagrant_data" 41 | 42 | # SSH Agent Forwarding 43 | # 44 | # Enable agent forwarding on vagrant ssh commands. This allows you to use ssh keys 45 | # on your host machine inside the guest. See the manual for `ssh-add`. 46 | # config.ssh.private_key_path = '~/.ssh/id_rsa' 47 | # config.ssh.forward_agent = true 48 | 49 | # Provider-specific configuration so you can fine-tune various 50 | # backing providers for Vagrant. These expose provider-specific options. 51 | # Example for VirtualBox: 52 | # 53 | config.vm.provider "virtualbox" do |vb| 54 | vb.name = "debian-jessie64" 55 | # Display the VirtualBox GUI when booting the machine 56 | # vb.gui = true 57 | # Customize the number of CPUs on the VM: 58 | vb.cpus = "1" 59 | # Customize the amount of memory on the VM: 60 | vb.memory = "2048" 61 | end 62 | # 63 | # View the documentation for the provider you are using for more 64 | # information on available options. 65 | 66 | # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies 67 | # such as FTP and Heroku are also available. See the documentation at 68 | # https://docs.vagrantup.com/v2/push/atlas.html for more information. 69 | # config.push.define "atlas" do |push| 70 | # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" 71 | # end 72 | 73 | # Enable provisioning with a shell script. Additional provisioners such as 74 | # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the 75 | # documentation for more information about their specific syntax and use. 76 | config.vm.provision "shell", inline: <<-SHELL 77 | sudo sed -i "s/$(hostname -f)/debian.dev/g" /etc/hosts 78 | sudo sed -i "s/$(hostname -s)/debian/g" /etc/hosts 79 | sudo sh -c "echo debian.dev > /etc/hostname" 80 | sudo hostname debian.dev 81 | sudo /etc/init.d/hostname.sh start 82 | sudo apt-get -y install software-properties-common 83 | sudo rm /etc/apt/sources.list 84 | sudo touch /etc/apt/sources.list 85 | sudo add-apt-repository 'deb http://mirrors.kernel.org/debian jessie main contrib non-free' 86 | sudo add-apt-repository 'deb http://security.debian.org/ jessie/updates main contrib non-free' 87 | sudo add-apt-repository 'deb http://mirrors.kernel.org/debian jessie-updates main contrib non-free' 88 | sudo add-apt-repository 'deb http://download.virtualbox.org/virtualbox/debian jessie contrib' 89 | wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add - 90 | sudo apt-get update 91 | sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" install dos2unix git php5 php5-curl php5-fpm php5-gd php5-mcrypt php5-mysqlnd php5-redis php-pear redis-server mariadb-server nginx virtualbox-5.0 92 | sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" dist-upgrade 93 | sudo apt-get autoremove --purge -y 94 | sudo apt-get autoclean 95 | sudo apt-get clean 96 | curl -sS https://getcomposer.org/installer | php 97 | chmod +x composer.phar 98 | sudo mv composer.phar /usr/local/bin/composer 99 | curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -o /home/vagrant/.git-prompt.sh 100 | curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o /home/vagrant/.git-completion.bash 101 | export HOME=/home/vagrant 102 | export COMPOSER_HOME=/home/vagrant/.composer 103 | composer global require drush/drush 104 | composer global require drupal/coder 105 | composer global require squizlabs/php_codesniffer 106 | composer global require pantheon-systems/terminus 107 | cat << "EOF" >> .bashrc 108 | export PATH="$HOME/.composer/vendor/bin:/sbin:/usr/sbin:$PATH" 109 | source $HOME/.composer/vendor/drush/drush/examples/example.bashrc 110 | source $HOME/.composer/vendor/drush/drush/drush.complete.sh 111 | source $HOME/.composer/vendor/pantheon-systems/terminus/utils/terminus-completion.bash 112 | source $HOME/.git-prompt.sh 113 | source $HOME/.git-completion.bash 114 | export GIT_PS1_SHOWDIRTYSTATE=1 115 | if [ "$(type -t __git_ps1)" ] && [ "$(type -t __drush_ps1)" ]; then 116 | if [ "$color_prompt" = yes ]; then 117 | PS1='${debian_chroot:+($debian_chroot)}\\[\\033[01;32m\\]$(whoami)@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]$(__git_ps1 " (%s)")$(__drush_ps1 "[%s]")\\$ ' 118 | else 119 | PS1='${debian_chroot:+($debian_chroot)}$(whoami)@\\h:\\w$(__git_ps1 " (%s)")$(__drush_ps1 "[%s]")\\$ ' 120 | fi 121 | fi 122 | EOF 123 | cat << "EOF" >> .bash_aliases 124 | alias ll='ls -lA' 125 | alias la='ls -A' 126 | alias l='ls -CF' 127 | alias grep='grep --color=auto' 128 | alias egrep='egrep --color=auto' 129 | alias fgrep='fgrep --color=auto' 130 | alias ip='ifconfig | grep "inet " | grep -v 127.0.0.1 | cut -d":" -f2 | cut -d" " -f1' 131 | alias git-who='git log --oneline --pretty=format:"%cn" | sort | uniq' 132 | alias composer-up="cd $HOME/.composer \&\& composer update \&\& cd -" 133 | alias vim-up="cd $HOME/.vim \&\& git submodule foreach git pull \&\& cd -" 134 | alias drupalcs="phpcs --standard=$HOME/.composer/vendor/drupal/coder/coder_sniffer/Drupal --report=full --extensions=php,module,inc,install,test,profile,theme,js,css,info,txt" 135 | alias drupalcbf="phpcbf --standard=$HOME/.composer/vendor/drupal/coder/coder_sniffer/Drupal --report=full --extensions=php,module,inc,install,test,profile,theme,js,css,info,txt" 136 | alias git-config='/vagrant/git-config.sh' 137 | alias ssh-config='/vagrant/ssh-config.sh' 138 | alias restart-lemp='/vagrant/restart-lemp.sh' 139 | alias site-fix='/vagrant/site-fix.sh' 140 | alias site-install='/vagrant/site-install.sh' 141 | alias site-log='/vagrant/site-log.sh' 142 | alias site-db='/vagrant/site-db.sh' 143 | alias site-files='/vagrant/site-files.sh' 144 | alias site-sync='/vagrant/site-sync.sh' 145 | alias phpmyadmin-install='/vagrant/phpmyadmin-install.sh' 146 | alias vim-install='/vagrant/vim-install.sh' 147 | alias webmin-install='/vagrant/webmin-install.sh' 148 | alias codespell-install='/vagrant/codespell-install.sh' 149 | alias compass-install='/vagrant/compass-install.sh' 150 | alias less-install='/vagrant/less-install.sh' 151 | alias xhprof-install='/vagrant/xhprof-install.sh' 152 | alias xdebug-install='/vagrant/xdebug-install.sh' 153 | EOF 154 | sed -i 's/^#force_color_prompt/force_color_prompt/g' .bashrc 155 | sed -i 's/^unset color_prompt/#unset color_prompt/g' .bashrc 156 | sudo chown -R vagrant:vagrant /home/vagrant 157 | sudo chown -R vagrant:vagrant /var/www 158 | source .bashrc 159 | $HOME/.composer/vendor/bin/phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer 160 | cd /etc/php5/fpm/ 161 | sudo sed -i 's/^memory_limit = 128M/memory_limit = 256M/' php.ini 162 | sudo sed -i 's/^max_execution_time = 30/max_execution_time = 90/' php.ini 163 | sudo sed -i 's/^max_input_time = 60/max_input_time = 90/' php.ini 164 | sudo sed -i 's/^post_max_size = 8M/post_max_size = 128M/' php.ini 165 | sudo sed -i 's/^upload_max_filesize = 2M/upload_max_filesize = 128M/' php.ini 166 | sudo sed -i 's/^error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT/error_reporting = E_ALL/' php.ini 167 | sudo sed -i 's/^display_errors = Off/display_errors = On/' php.ini 168 | sudo sed -i 's/^display_startup_errors = Off/display_startup_errors = On/' php.ini 169 | sudo sed -i 's/^track_errors = Off/track_errors = On/' php.ini 170 | sudo sed -i 's/^;always_populate_raw_post_data = -1/always_populate_raw_post_data = -1/' php.ini 171 | sudo sed -i 's/^;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' php.ini 172 | cd /etc/php5/fpm/pool.d 173 | sudo sed -i 's,^listen = 127.0.0.1:9000,listen = /var/run/php5-fpm.sock,' www.conf 174 | sudo sed -i 's,^;listen.owner = www-data,listen.owner = www-data,' www.conf 175 | sudo sed -i 's,^;listen.group = www-data,listen.group = www-data,' www.conf 176 | sudo sed -i 's,^;listen.mode = 0660,listen.mode = 0660,' www.conf 177 | sudo sh -c 'cat << "EOF" > /etc/nginx/conf.d/drupal.conf.example 178 | # Example Drupal Recipe 179 | # See https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/ 180 | server { 181 | listen 80; 182 | server_name example.com; 183 | root /var/www/drupal7; 184 | index index.php; 185 | access_log /var/log/nginx/drupal7-access.log; 186 | error_log /var/log/nginx/drupal7-error.log; 187 | 188 | location = /favicon.ico { 189 | log_not_found off; 190 | access_log off; 191 | } 192 | 193 | location = /robots.txt { 194 | allow all; 195 | log_not_found off; 196 | access_log off; 197 | } 198 | 199 | # Very rarely should these ever be accessed outside of your lan 200 | location ~* \\.(txt|log)$ { 201 | allow 192.168.0.0/16; 202 | deny all; 203 | } 204 | 205 | location ~ \\..*/.*\\.php$ { 206 | return 403; 207 | } 208 | 209 | location ~ ^/sites/.*/private/ { 210 | return 403; 211 | } 212 | 213 | # Block access to "hidden" files and directories whose names begin with a 214 | # period. This includes directories used by version control systems such 215 | # as Subversion or Git to store control files. 216 | location ~ (^|/)\\. { 217 | return 403; 218 | } 219 | 220 | location / { 221 | # try_files $uri @rewrite; # For Drupal <= 6 222 | try_files $uri /index.php?$query_string; # For Drupal >= 7 223 | } 224 | 225 | location @rewrite { 226 | rewrite ^/(.*)$ /index.php?q=$1; 227 | } 228 | 229 | location ~ \\.php$ { 230 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 231 | #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini 232 | include fastcgi_params; 233 | fastcgi_param SCRIPT_FILENAME $request_filename; 234 | fastcgi_intercept_errors on; 235 | fastcgi_pass unix:/var/run/php5-fpm.sock; 236 | #fastcgi_pass 127.0.0.1:9000; 237 | fastcgi_index index.php; 238 | } 239 | 240 | # Fighting with Styles? This little gem is amazing. 241 | # location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6 242 | location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7 243 | try_files $uri @rewrite; 244 | } 245 | 246 | location ~* \\.(js|css|png|jpg|jpeg|gif|ico)$ { 247 | expires max; 248 | log_not_found off; 249 | } 250 | } 251 | EOF' 252 | sudo /etc/init.d/php5-fpm restart 253 | sudo /etc/init.d/redis-server restart 254 | sudo /etc/init.d/nginx restart 255 | sudo /etc/init.d/mysql restart 256 | cd 257 | SHELL 258 | end 259 | -------------------------------------------------------------------------------- /codespell-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -d "$HOME/.codespell" ]; then 3 | echo "Codespell is already installed." 4 | exit 5 | fi 6 | sudo apt-get install python3 help2man -y 7 | git clone https://github.com/lucasdemarchi/codespell.git $HOME/.codespell 8 | cd $HOME/.codespell 9 | sudo make install 10 | -------------------------------------------------------------------------------- /compass-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo apt-get install ruby ruby-dev -y 3 | sudo gem install compass 4 | -------------------------------------------------------------------------------- /git-config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | GIT=$(which git) 3 | if [ -z "$GIT" ]; then 4 | echo "git is not installed." 5 | exit 6 | fi 7 | echo -n "Enter your full name: "; read NAME 8 | if [ -z "$NAME" ]; then 9 | exit 10 | fi 11 | echo -n "Enter your email address: "; read EMAIL 12 | if [ -z "$EMAIL" ]; then 13 | exit 14 | fi 15 | git config --global user.name "$NAME" 16 | git config --global user.email $EMAIL 17 | git config --global core.autocrlf input 18 | git config --global core.editor vim 19 | git config --global alias.amend 'commit --amend' 20 | git config --global alias.br branch 21 | git config --global alias.ci commit 22 | git config --global alias.cl 'config --list' 23 | git config --global alias.co checkout 24 | git config --global alias.dc 'diff --cached' 25 | git config --global alias.ds 'diff --staged' 26 | git config --global alias.graph 'log --graph --oneline --decorate --pretty=format:"%cn %s %cr"' 27 | git config --global alias.last 'log -1 HEAD' 28 | git config --global alias.rb rebase 29 | git config --global alias.st status 30 | git config --global alias.unstage 'reset HEAD --' 31 | git config --global color.ui true 32 | git config --global help.autocorrect 1 33 | git config --global push.default matching 34 | -------------------------------------------------------------------------------- /hosts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | MSG1="Precondition: This script must be run as administrator in Git Bash if the operating system is Windows" 3 | MSG2="Usage: $0 [list|add] site [env] where site is the Nginx virtual host or Pantheon Site Name and" 4 | MSG3=" [env] is the optional environment. The default environment is dev." 5 | if test $1; then 6 | if [[ "$1" != "list" && "$1" != "add" ]]; then 7 | echo $MSG1 8 | echo $MSG2 9 | echo $MSG3 10 | else 11 | if [ "$OSTYPE" == "msys" ]; then 12 | HOSTS=/C/Windows/System32/drivers/etc/hosts 13 | else 14 | HOSTS=/etc/hosts 15 | fi 16 | if [ "$1" == "add" ]; then 17 | if test $2; then 18 | ENV=dev 19 | if test $3; then 20 | ENV=$3 21 | fi 22 | if [ "$OSTYPE" == "msys" ]; then 23 | echo $'\r\n'"192.168.33.10 $2-$ENV.site" >> $HOSTS 24 | else 25 | sudo sh -c "echo '192.168.33.10 $2-$ENV.site' >> $HOSTS" 26 | fi 27 | else 28 | echo $MSG1 29 | echo $MSG2 30 | echo $MSG3 31 | fi 32 | else 33 | if [ "$OSTYPE" == "msys" ]; then 34 | notepad $HOSTS 35 | else 36 | cat $HOSTS 37 | fi 38 | fi 39 | fi 40 | else 41 | echo $MSG1 42 | echo $MSG2 43 | echo $MSG3 44 | fi 45 | -------------------------------------------------------------------------------- /less-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | curl --silent --location https://deb.nodesource.com/setup_0.12 | sudo bash - 3 | sudo apt-get install nodejs -y 4 | sudo npm install -g less 5 | -------------------------------------------------------------------------------- /phpmyadmin-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo DEBIAN_FRONTEND=noninteractive apt-get install phpmyadmin -y 3 | sudo sh -c 'cat << "EOF" > /etc/nginx/sites-available/phpmyadmin 4 | server { 5 | listen 8080; 6 | root /usr/share/phpmyadmin; 7 | 8 | access_log /var/log/nginx/phpmyadmin-access.log; 9 | error_log /var/log/nginx/phpmyadmin-error.log; 10 | 11 | location / { 12 | index index.php; 13 | try_files $uri/ $uri /index.php?$args; 14 | } 15 | 16 | location ~ ^/(.+\.php)$ { 17 | try_files $uri =404; 18 | fastcgi_pass unix:/var/run/php5-fpm.sock; 19 | fastcgi_index index.php; 20 | fastcgi_param SCRIPT_FILENAME $request_filename; 21 | include /etc/nginx/fastcgi_params; 22 | fastcgi_param PATH_INFO $fastcgi_script_name; 23 | fastcgi_buffer_size 128k; 24 | fastcgi_buffers 256 4k; 25 | fastcgi_busy_buffers_size 256k; 26 | fastcgi_temp_file_write_size 256k; 27 | fastcgi_intercept_errors on; 28 | } 29 | } 30 | EOF' 31 | sudo ln -s /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/phpmyadmin 32 | /vagrant/restart-lemp.sh 33 | echo "Browse to http://192.168.33.10:8080 and login with Username: drupal and Password: drupal" 34 | -------------------------------------------------------------------------------- /restart-lemp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ ! "$(pidof php5-fpm)" ]; then 3 | sudo /etc/init.d/php5-fpm start 4 | else 5 | sudo /etc/init.d/php5-fpm restart 6 | fi 7 | if [ ! "$(pidof redis-server)" ]; then 8 | sudo /etc/init.d/redis-server start 9 | else 10 | sudo /etc/init.d/redis-server restart 11 | fi 12 | if [ ! "$(pidof nginx)" ]; then 13 | sudo /etc/init.d/nginx start 14 | else 15 | sudo /etc/init.d/nginx restart 16 | fi 17 | if [ ! "$(pidof mysqld)" ]; then 18 | sudo /etc/init.d/mysql start 19 | else 20 | sudo /etc/init.d/mysql restart 21 | fi 22 | -------------------------------------------------------------------------------- /site-db.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check for prerequisites 4 | GIT=$(which git) 5 | if [ $? == 1 ]; then 6 | echo "Git is not installed. See https://github.com/git/git." 7 | exit 8 | fi 9 | TERMINUS=$(which terminus) 10 | if [ $? == 1 ]; then 11 | echo "Terminus is not installed. See https://github.com/pantheon-systems/cli." 12 | exit 13 | fi 14 | DRUSH=$(which drush) 15 | if [ $? == 1 ]; then 16 | echo "Drush is not installed. See http://www.drush.org/en/master/install." 17 | exit 18 | fi 19 | 20 | # Get the Pantheon site name 21 | SITE="" 22 | if test $1; then 23 | SITE=$1 24 | fi 25 | 26 | # Get the environment 27 | ENV=dev 28 | if test $2; then 29 | ENV=$2 30 | fi 31 | 32 | # Set the Drupal root directory 33 | ROOT=$($DRUSH status root --format=list) 34 | if [ -z $ROOT ]; then 35 | ROOT=/var/www/$SITE-$ENV 36 | fi 37 | 38 | # Validate the Drupal root directory 39 | if [ ! -d $ROOT ]; then 40 | echo "The Pantheon site cannot be located." 41 | exit 42 | fi 43 | 44 | # Get the Pantheon site name from Drupal root 45 | if [ -z $SITE ]; then 46 | BASE=${ROOT:0:8} 47 | if [ $BASE == "/var/www" ]; then 48 | DIR=${ROOT:9} 49 | END="-$ENV" 50 | LEN=${#END} 51 | SITE=${DIR:0:(-$LEN)} 52 | fi 53 | fi 54 | 55 | if [ ! -z $SITE ]; then 56 | # Validate the environment 57 | $TERMINUS site environment-info --site=$SITE --env=$ENV --field=id 58 | if [ $? == 1 ]; then 59 | $TERMINUS site environments --site=$SITE 60 | exit 61 | fi 62 | 63 | # Retrieve stored Terminus credentials 64 | EMAIL="" 65 | PASSWORD="" 66 | HTTPUSER="" 67 | HTTPPASS="" 68 | if [ -f $HOME/.terminus_auth ]; then 69 | while read line; do 70 | for pair in $line; do 71 | set -- $(echo $pair | tr '=' ' ') 72 | if [ "$1" == "email" ]; then 73 | EMAIL=${line#"$1="} 74 | fi 75 | if [ "$1" == "password" ]; then 76 | PASSWORD=${line#"$1="} 77 | fi 78 | if [ "$1" == "httpuser" ]; then 79 | HTTPUSER=${line#"$1="} 80 | fi 81 | if [ "$1" == "httppass" ]; then 82 | HTTPPASS=${line#"$1="} 83 | fi 84 | done 85 | done < $HOME/.terminus_auth 86 | fi 87 | 88 | # Terminus authentication prompts 89 | WHOAMI=$($TERMINUS auth whoami) 90 | if [ $? == 1 ]; then 91 | if [ -z "$EMAIL" ]; then 92 | echo -n "Enter your Pantheon email address: "; read EMAIL 93 | if [ -z "$EMAIL" ]; then 94 | exit 95 | else 96 | echo -n "Save email address? (Y/n): "; read -n 1 SAVEMAIL 97 | if [ -z "$SAVEMAIL" ]; then 98 | SAVEMAIL=y 99 | fi 100 | if [ "$SAVEMAIL" == "Y" ]; then 101 | SAVEMAIL=y 102 | fi 103 | if [ "$SAVEMAIL" == "y" ]; then 104 | echo "email=$EMAIL" > $HOME/.terminus_auth 105 | fi 106 | fi 107 | fi 108 | if [ -z "$PASSWORD" ]; then 109 | echo -n "Enter your Pantheon password: "; read -s PASSWORD 110 | if [ -z "$PASSWORD" ]; then 111 | exit 112 | else 113 | echo -n "Save password? (y/N): "; read -n 1 SAVEPASS 114 | echo $'\n' 115 | if [ "$SAVEPASS" == "Y" ]; then 116 | SAVEPASS=y 117 | fi 118 | if [ "$SAVEPASS" == "y" ]; then 119 | echo "password=$PASSWORD" >> $HOME/.terminus_auth 120 | fi 121 | fi 122 | fi 123 | if [ -z "$HTTPUSER" ]; then 124 | echo -n "Enter the HTTP Basic Authentication username: "; read HTTPUSER 125 | if [ ! -z "$HTTPUSER" ]; then 126 | echo "httpuser=$HTTPUSER" >> $HOME/.terminus_auth 127 | fi 128 | fi 129 | if [ -z "$HTTPPASS" ]; then 130 | echo -n "Enter the HTTP Basic Authentication password: "; read -s HTTPPASS 131 | if [ ! -z "$HTTPPASS" ]; then 132 | echo "httppass=$HTTPPASS" >> $HOME/.terminus_auth 133 | fi 134 | fi 135 | # Change email to match commits to Pantheon 136 | GITEMAIL=$($GIT config --get user.email) 137 | if [ "$GITEMAIL" != "$EMAIL" ]; then 138 | $GIT config --global user.email $EMAIL 139 | fi 140 | $TERMINUS auth login $EMAIL --password="$PASSWORD" 141 | fi 142 | 143 | # Remove saved credentials if unable to login 144 | WHOAMI=$($TERMINUS auth whoami) 145 | if [ $? == 1 ]; then 146 | if [ -f $HOME/.terminus_auth ]; then 147 | rm -f $HOME/.terminus_auth 148 | fi 149 | exit 150 | fi 151 | 152 | # Set multisite 153 | MULTISITE="" 154 | MULTISITES="" 155 | DEFAULTSITE="default" 156 | cd $ROOT/sites 157 | SITES=$(echo $(ls -d */) | sed 's,/,,g') 158 | for S in $SITES; do 159 | if [[ "$S" != "all" && -f "$ROOT/sites/$S/settings.php" ]]; then 160 | if [ -z "$MULTISITES" ]; then 161 | MULTISITES="$S" 162 | else 163 | MULTISITES="$MULTISITES $S" 164 | fi 165 | DEFAULTSITE="$S" 166 | fi 167 | done 168 | if [ "$DEFAULTSITE" == "$MULTISITES" ]; then 169 | MULTISITE="$DEFAULTSITE" 170 | fi 171 | if [[ "$MULTISITE" == "default" && "$MULTISITES" != "default" ]]; then 172 | echo "" 173 | echo "The following multisites are available:" 174 | echo $MULTISITES 175 | echo "" 176 | echo -n "Enter the multisite ($DEFAULTSITE): "; read MULTISITE 177 | if [ -z "$MULTISITE" ]; then 178 | MULTISITE="$DEFAULTSITE" 179 | fi 180 | fi 181 | if [ "$MULTISITE" != "$DEFAULTSITE" ]; then 182 | VALID=no 183 | for MULTI in $MULTISITES; do 184 | if [ "$MULTI" == "$MULTISITE" ]; then 185 | VALID=yes 186 | fi 187 | done 188 | if [ "$VALID" == "no" ]; then 189 | echo "$MULTISITE is not a valid multisite." 190 | exit 191 | fi 192 | fi 193 | if [ ! -f $HOME/.drush/registry_rebuild/registry_rebuild.php ]; then 194 | $DRUSH dl registry_rebuild -y 195 | $DRUSH cc drush 196 | fi 197 | if [ ! -z "$MULTISITE" ]; then 198 | DRUSH="$DRUSH -l $MULTISITE" 199 | fi 200 | 201 | # Download the latest database backup 202 | cd $ROOT 203 | DB=$($TERMINUS site backups get --site=$SITE --env=$ENV --element=db --latest) 204 | if [ ! -z "$DB" ]; then 205 | LABEL=${DB:0:11} 206 | if [ "$LABEL" == "Backup URL:" ]; then 207 | DB=${DB:12} 208 | fi 209 | NEW_DB="$SITE-$ENV.sql" 210 | rm -f $NEW_DB $NEW_DB.gz 211 | echo "Downloading $DB to $NEW_DB ..." 212 | curl -o $NEW_DB.gz $DB && gunzip $NEW_DB.gz 213 | $DRUSH sql-drop -y 214 | echo "Loading $NEW_DB ..." 215 | $DRUSH sqlc < $NEW_DB 216 | fi 217 | # Make sure the Drupal admin user login is admin/admin 218 | $DRUSH sqlq "update users set name = 'admin' where uid = 1" 219 | $DRUSH upwd admin --password=admin 220 | $DRUSH rr 221 | 222 | # Make sure the Redis service is running 223 | REDIS_PID=$(pidof redis-server) 224 | if [ -z "$REDIS_PID" ]; then 225 | REDIS_PKG=$(dpkg -l | grep redis-server) 226 | if [ -z "$REDIS_PKG" ]; then 227 | sudo apt-get install redis-server -y 228 | else 229 | sudo service redis-server start 230 | fi 231 | fi 232 | 233 | # Prompt to enable Redis only if the service is running 234 | REDIS_PID=$(pidof redis-server) 235 | if [ ! -z "$REDIS_PID" ]; then 236 | REDIS_MOD=$($DRUSH pml --status=Enabled | grep redis) 237 | if [ -z "$REDIS_MOD" ]; then 238 | echo -n "Would you like to enable Redis? (Y/n): "; read -n 1 REDIS 239 | if [ -z "$REDIS" ]; then 240 | REDIS=y 241 | fi 242 | if [ "$REDIS" == "Y" ]; then 243 | REDIS=y 244 | fi 245 | if [ "$REDIS" == "y" ]; then 246 | REDISAUTOLOAD=$(find sites/ -name redis.autoload.inc) 247 | REDISLOCK=$(find sites/ -name redis.lock.inc) 248 | if [[ -z "$REDISAUTOLOAD" || -z "$REDISLOCK" ]]; then 249 | $DRUSH dl -y redis 250 | REDISAUTOLOAD=$(find sites/ -name redis.autoload.inc) 251 | REDISLOCK=$(find sites/ -name redis.lock.inc) 252 | fi 253 | $DRUSH en -y redis 254 | REDIS_CONFIG=$(grep "Use Redis for caching." $LOCALSETTINGS) 255 | if [ -z "$REDIS_CONFIG" ]; then 256 | cat << EOF >> $LOCALSETTINGS 257 | // Use Redis for caching. 258 | \$conf['redis_client_interface'] = 'PhpRedis'; 259 | \$conf['cache_backends'][] = '$REDISAUTOLOAD'; 260 | \$conf['cache_default_class'] = 'Redis_Cache'; 261 | // Do not use Redis for cache_form (no performance difference). 262 | \$conf['cache_class_cache_form'] = 'DrupalDatabaseCache'; 263 | // Use Redis for Drupal locks (semaphore). 264 | \$conf['lock_inc'] = '$REDISLOCK'; 265 | EOF 266 | fi 267 | fi 268 | fi 269 | fi 270 | 271 | # Prompt to enable XHProf 272 | echo -n "Would you like to enable XHProf? (y/N): "; read -n 1 XHPROF 273 | if [ "$XHPROF" == "Y" ]; then 274 | XHPROF=y 275 | fi 276 | if [ "$XHPROF" == "y" ]; then 277 | XHPROF_MOD=$(dpkg -l | grep php5-xhprof) 278 | if [ -z "$XHPROF_MOD" ]; then 279 | /vagrant/xhprof-install.sh 280 | fi 281 | XHPROF_PATH="$ROOT/sites/all/modules/contrib/xhprof" 282 | if [ ! -d "$XHPROF_PATH" ]; then 283 | $DRUSH dl xhprof 284 | fi 285 | $DRUSH rr 286 | $DRUSH en -y xhprof 287 | # Apply patch to expose paths. See https://www.drupal.org/node/2354853. 288 | if [ ! -f "$XHPROF_PATH/xhprof-2354853-paths-d7-4.patch" ]; then 289 | cd $XHPROF_PATH 290 | wget https://www.drupal.org/files/issues/xhprof-2354853-paths-d7-4.patch 291 | patch -p1 < xhprof-2354853-paths-d7-4.patch 292 | fi 293 | $DRUSH vset xhprof_default_class 'XHProfRunsFile' 294 | $DRUSH vset xhprof_disable_admin_paths 1 295 | $DRUSH vset xhprof_enabled 1 296 | $DRUSH vset xhprof_flags_cpu 1 297 | $DRUSH vset xhprof_flags_memory 1 298 | $DRUSH vset xhprof_interval '' 299 | fi 300 | 301 | # Prompt to enable Xdebug 302 | XDEBUG_MOD=$(dpkg -l | grep php5-xdebug) 303 | if [ -z "$XDEBUG_MOD" ]; then 304 | echo -n "Would you like to enable Xdebug? (y/N): "; read -n 1 XDEBUG 305 | if [ "$XDEBUG" == "Y" ]; then 306 | XDEBUG=y 307 | fi 308 | if [ "$XDEBUG" == "y" ]; then 309 | /vagrant/xdebug-install.sh 310 | fi 311 | fi 312 | 313 | # Prompt to enable Stage File Proxy 314 | echo "" 315 | echo -n "Would you like to enable Stage File Proxy? (Y/n): "; read -n 1 PROXY 316 | echo "" 317 | if [ -z "$PROXY" ]; then 318 | PROXY=y 319 | fi 320 | if [ "$PROXY" == "Y" ]; then 321 | PROXY=y 322 | fi 323 | if [ "$PROXY" == "y" ]; then 324 | $DRUSH dl -n stage_file_proxy 325 | $DRUSH en -y stage_file_proxy 326 | DOMAIN=$(echo $($TERMINUS site hostnames list --site=$SITE --env=$ENV) | cut -d" " -f4) 327 | if [ ! -z "$DOMAIN" ]; then 328 | $DRUSH vset stage_file_proxy_hotlink 1 329 | if [[ ! -z "$HTTPUSER" && ! -z "$HTTPPASS" ]]; then 330 | $DRUSH vset stage_file_proxy_origin "https://$HTTPUSER:$HTTPPASS@$DOMAIN" 331 | else 332 | $DRUSH vset stage_file_proxy_origin "https://$DOMAIN" 333 | fi 334 | fi 335 | else 336 | cd $ROOT/sites/$MULTISITE/files 337 | FILES=$($TERMINUS site backups get --site=$SITE --env=$ENV --element=files --latest) 338 | if [ ! -z "$FILES" ]; then 339 | LABEL=${FILES:0:11} 340 | if [ "$LABEL" == "Backup URL:" ]; then 341 | FILES=${FILES:12} 342 | fi 343 | NEW_FILES=$SITE-$ENV-files.tar.gz 344 | echo "Downloading latest files backup $FILES to $NEW_FILES..." 345 | curl -o $NEW_FILES $FILES 346 | tar zxvf $NEW_FILES 347 | cp -r files_$ENV/* . 348 | rm -rf files_$ENV/ 349 | cd .. 350 | sudo chown -R vagrant:www-data files/ 351 | sudo chmod -R g+w files/ 352 | fi 353 | fi 354 | 355 | # Enable development modules 356 | #$DRUSH dl -n migrate migrate_extras coder devel devel_themer hacked redis simplehtmldom-7.x-1.12 stage_file_proxy 357 | #$DRUSH en -y migrate_extras coder devel_themer hacked redis stage_file_proxy 358 | 359 | # Disable unused/unwanted modules 360 | $DRUSH dis -y overlay 361 | 362 | # Disable cron 363 | ELYSIA=$($DRUSH pml --status=Enabled | grep elysia_cron) 364 | if [ ! -z "$ELYSIA" ]; then 365 | $DRUSH vset elysia_cron_disabled 1 366 | fi 367 | $DRUSH vset cron_safe_threshold 0 368 | 369 | # Restart web services 370 | /vagrant/restart-lemp.sh 371 | 372 | else 373 | echo "" 374 | echo "Purpose: Downloads the latest database and uploads to your local database" 375 | echo "" 376 | echo "Usage: $0 [site] [env] where [site] is a" 377 | echo " valid Nginx virtual host or Pantheon Site Name" 378 | echo " and [env] is the environment (dev, test or live)." 379 | echo "" 380 | echo " The default [site] is the current Drupal root" 381 | echo " and the default [env] is dev." 382 | echo "" 383 | fi 384 | -------------------------------------------------------------------------------- /site-files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check for prerequisites 4 | GIT=$(which git) 5 | if [ $? == 1 ]; then 6 | echo "Git is not installed. See https://github.com/git/git." 7 | exit 8 | fi 9 | TERMINUS=$(which terminus) 10 | if [ $? == 1 ]; then 11 | echo "Terminus is not installed. See https://github.com/pantheon-systems/cli." 12 | exit 13 | fi 14 | DRUSH=$(which drush) 15 | if [ $? == 1 ]; then 16 | echo "Drush is not installed. See http://www.drush.org/en/master/install." 17 | exit 18 | fi 19 | 20 | # Get the Pantheon site name 21 | SITE="" 22 | if test $1; then 23 | SITE=$1 24 | fi 25 | 26 | # Get the environment 27 | ENV=dev 28 | if test $2; then 29 | ENV=$2 30 | fi 31 | 32 | # Set the Drupal root directory 33 | ROOT=$($DRUSH status root --format=list) 34 | if [ -z $ROOT ]; then 35 | ROOT=/var/www/$SITE-$ENV 36 | fi 37 | 38 | # Validate the Drupal root directory 39 | if [ ! -d $ROOT ]; then 40 | echo "The Pantheon site cannot be located." 41 | exit 42 | fi 43 | 44 | # Get the Pantheon site name from Drupal root 45 | if [ -z $SITE ]; then 46 | BASE=${ROOT:0:8} 47 | if [ $BASE == "/var/www" ]; then 48 | DIR=${ROOT:9} 49 | END="-$ENV" 50 | LEN=${#END} 51 | SITE=${DIR:0:(-$LEN)} 52 | fi 53 | fi 54 | 55 | if [ ! -z $SITE ]; then 56 | # Validate the environment 57 | $TERMINUS site environment-info --site=$SITE --env=$ENV --field=id 58 | if [ $? == 1 ]; then 59 | $TERMINUS site environments --site=$SITE 60 | exit 61 | fi 62 | 63 | # Retrieve stored Terminus credentials 64 | EMAIL="" 65 | PASSWORD="" 66 | HTTPUSER="" 67 | HTTPPASS="" 68 | if [ -f $HOME/.terminus_auth ]; then 69 | while read line; do 70 | for pair in $line; do 71 | set -- $(echo $pair | tr '=' ' ') 72 | if [ "$1" == "email" ]; then 73 | EMAIL=${line#"$1="} 74 | fi 75 | if [ "$1" == "password" ]; then 76 | PASSWORD=${line#"$1="} 77 | fi 78 | if [ "$1" == "httpuser" ]; then 79 | HTTPUSER=${line#"$1="} 80 | fi 81 | if [ "$1" == "httppass" ]; then 82 | HTTPPASS=${line#"$1="} 83 | fi 84 | done 85 | done < $HOME/.terminus_auth 86 | fi 87 | 88 | # Terminus authentication prompts 89 | WHOAMI=$($TERMINUS auth whoami) 90 | if [ $? == 1 ]; then 91 | if [ -z "$EMAIL" ]; then 92 | echo -n "Enter your Pantheon email address: "; read EMAIL 93 | if [ -z "$EMAIL" ]; then 94 | exit 95 | else 96 | echo -n "Save email address? (Y/n): "; read -n 1 SAVEMAIL 97 | if [ -z "$SAVEMAIL" ]; then 98 | SAVEMAIL=y 99 | fi 100 | if [ "$SAVEMAIL" == "Y" ]; then 101 | SAVEMAIL=y 102 | fi 103 | if [ "$SAVEMAIL" == "y" ]; then 104 | echo "email=$EMAIL" > $HOME/.terminus_auth 105 | fi 106 | fi 107 | fi 108 | if [ -z "$PASSWORD" ]; then 109 | echo -n "Enter your Pantheon password: "; read -s PASSWORD 110 | if [ -z "$PASSWORD" ]; then 111 | exit 112 | else 113 | echo -n "Save password? (y/N): "; read -n 1 SAVEPASS 114 | echo $'\n' 115 | if [ "$SAVEPASS" == "Y" ]; then 116 | SAVEPASS=y 117 | fi 118 | if [ "$SAVEPASS" == "y" ]; then 119 | echo "password=$PASSWORD" >> $HOME/.terminus_auth 120 | fi 121 | fi 122 | fi 123 | if [ -z "$HTTPUSER" ]; then 124 | echo -n "Enter the HTTP Basic Authentication username: "; read HTTPUSER 125 | if [ ! -z "$HTTPUSER" ]; then 126 | echo "httpuser=$HTTPUSER" >> $HOME/.terminus_auth 127 | fi 128 | fi 129 | if [ -z "$HTTPPASS" ]; then 130 | echo -n "Enter the HTTP Basic Authentication password: "; read -s HTTPPASS 131 | if [ ! -z "$HTTPPASS" ]; then 132 | echo "httppass=$HTTPPASS" >> $HOME/.terminus_auth 133 | fi 134 | fi 135 | # Change email to match commits to Pantheon 136 | GITEMAIL=$($GIT config --get user.email) 137 | if [ "$GITEMAIL" != "$EMAIL" ]; then 138 | $GIT config --global user.email $EMAIL 139 | fi 140 | $TERMINUS auth login $EMAIL --password="$PASSWORD" 141 | fi 142 | 143 | # Remove saved credentials if unable to login 144 | WHOAMI=$($TERMINUS auth whoami) 145 | if [ $? == 1 ]; then 146 | if [ -f $HOME/.terminus_auth ]; then 147 | rm -f $HOME/.terminus_auth 148 | fi 149 | exit 150 | fi 151 | 152 | # Set multisite 153 | MULTISITE="" 154 | MULTISITES="" 155 | DEFAULTSITE="default" 156 | cd $ROOT/sites 157 | SITES=$(echo $(ls -d */) | sed 's,/,,g') 158 | for S in $SITES; do 159 | if [[ "$S" != "all" && -f "$ROOT/sites/$S/settings.php" ]]; then 160 | if [ -z "$MULTISITES" ]; then 161 | MULTISITES="$S" 162 | else 163 | MULTISITES="$MULTISITES $S" 164 | fi 165 | DEFAULTSITE="$S" 166 | fi 167 | done 168 | if [ "$DEFAULTSITE" == "$MULTISITES" ]; then 169 | MULTISITE="$DEFAULTSITE" 170 | fi 171 | if [[ "$MULTISITE" == "default" && "$MULTISITES" != "default" ]]; then 172 | echo "" 173 | echo "The following multisites are available:" 174 | echo $MULTISITES 175 | echo "" 176 | echo -n "Enter the multisite ($DEFAULTSITE): "; read MULTISITE 177 | if [ -z "$MULTISITE" ]; then 178 | MULTISITE="$DEFAULTSITE" 179 | fi 180 | fi 181 | if [ "$MULTISITE" != "$DEFAULTSITE" ]; then 182 | VALID=no 183 | for MULTI in $MULTISITES; do 184 | if [ "$MULTI" == "$MULTISITE" ]; then 185 | VALID=yes 186 | fi 187 | done 188 | if [ "$VALID" == "no" ]; then 189 | echo "$MULTISITE is not a valid multisite." 190 | exit 191 | fi 192 | fi 193 | if [ ! -f $HOME/.drush/registry_rebuild/registry_rebuild.php ]; then 194 | $DRUSH dl registry_rebuild -y 195 | $DRUSH cc drush 196 | fi 197 | if [ ! -z "$MULTISITE" ]; then 198 | DRUSH="$DRUSH -l $MULTISITE" 199 | fi 200 | 201 | # Prompt to enable Stage File Proxy 202 | cd $ROOT 203 | echo -n "Would you like to enable Stage File Proxy? (Y/n): "; read -n 1 PROXY 204 | echo "" 205 | if [ -z "$PROXY" ]; then 206 | PROXY=y 207 | fi 208 | if [ "$PROXY" == "Y" ]; then 209 | PROXY=y 210 | fi 211 | if [ "$PROXY" == "y" ]; then 212 | $DRUSH dl -n stage_file_proxy 213 | $DRUSH en -y stage_file_proxy 214 | DOMAIN=$(echo $($TERMINUS site hostnames list --site=$SITE --env=$ENV) | cut -d" " -f4) 215 | if [ ! -z "$DOMAIN" ]; then 216 | $DRUSH vset stage_file_proxy_hotlink 1 217 | if [[ ! -z "$HTTPUSER" && ! -z "$HTTPPASS" ]]; then 218 | $DRUSH vset stage_file_proxy_origin "https://$HTTPUSER:$HTTPPASS@$DOMAIN" 219 | else 220 | $DRUSH vset stage_file_proxy_origin "https://$DOMAIN" 221 | fi 222 | fi 223 | else 224 | cd $ROOT/sites/$MULTISITE/files 225 | FILES=$($TERMINUS site backups get --site=$SITE --env=$ENV --element=files --latest) 226 | if [ ! -z "$FILES" ]; then 227 | LABEL=${FILES:0:11} 228 | if [ "$LABEL" == "Backup URL:" ]; then 229 | FILES=${FILES:12} 230 | fi 231 | NEW_FILES=$SITE-$ENV-files.tar.gz 232 | echo "Downloading latest files backup $FILES to $NEW_FILES..." 233 | curl -o $NEW_FILES $FILES 234 | tar zxvf $NEW_FILES 235 | sudo cp -r files_$ENV/* . 236 | sudo rm -rf files_$ENV/ 237 | cd .. 238 | sudo chown -R vagrant:www-data files/ 239 | sudo chmod -R g+w files/ 240 | fi 241 | fi 242 | else 243 | echo "" 244 | echo "Purpose: Downloads the latest files backup to your local environment" 245 | echo "" 246 | echo "Usage: $0 [site] [env] where [site] is a" 247 | echo " valid Nginx virtual host or Pantheon Site Name" 248 | echo " and [env] is the environment (dev, test or live)." 249 | echo "" 250 | echo " The default [site] is the current Drupal root" 251 | echo " and the default [env] is dev." 252 | echo "" 253 | fi 254 | -------------------------------------------------------------------------------- /site-fix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check for prerequisite 4 | DRUSH=$(which drush) 5 | if [ $? == 1 ]; then 6 | echo "Drush is not installed. See http://www.drush.org/en/master/install." 7 | exit 8 | fi 9 | 10 | # Get the Pantheon site name 11 | SITE="" 12 | if test $1; then 13 | SITE=$1 14 | fi 15 | 16 | # Get the environment 17 | ENV=dev 18 | if test $2; then 19 | ENV=$2 20 | fi 21 | 22 | # Set the Drupal root directory 23 | ROOT=$($DRUSH status root --format=list) 24 | if [ -z $ROOT ]; then 25 | ROOT=/var/www/$SITE-$ENV 26 | fi 27 | 28 | # Validate the Drupal root directory 29 | if [ ! -d $ROOT ]; then 30 | echo "The Pantheon site cannot be located." 31 | exit 32 | fi 33 | 34 | # Get the Pantheon site name from Drupal root 35 | if [ -z $SITE ]; then 36 | BASE=${ROOT:0:8} 37 | if [ $BASE == "/var/www" ]; then 38 | DIR=${ROOT:9} 39 | END="-$ENV" 40 | LEN=${#END} 41 | SITE=${DIR:0:(-$LEN)} 42 | fi 43 | fi 44 | 45 | if [ ! -z $SITE ]; then 46 | if [ ! -f $HOME/.drush/registry_rebuild/registry_rebuild.php ]; then 47 | $DRUSH dl registry_rebuild -y 48 | $DRUSH cc drush 49 | fi 50 | 51 | # Set multisite 52 | MULTISITES="" 53 | DEFAULTSITE="default" 54 | cd $ROOT/sites 55 | SITES=$(echo $(ls -d */) | sed 's,/,,g') 56 | for S in $SITES; do 57 | if [[ "$S" != "all" && -f "$ROOT/sites/$S/settings.php" ]]; then 58 | if [ -z "$MULTISITES" ]; then 59 | MULTISITES="$S" 60 | else 61 | MULTISITES="$MULTISITES $S" 62 | fi 63 | DEFAULTSITE="$S" 64 | fi 65 | done 66 | if [ "$DEFAULTSITE" == "$MULTISITES" ]; then 67 | MULTISITE="$DEFAULTSITE" 68 | fi 69 | if [[ "$MULTISITE" == "default" && "$MULTISITES" != "default" ]]; then 70 | echo "" 71 | echo "The following multisites are available:" 72 | echo $MULTISITES 73 | echo "" 74 | echo -n "Enter the multisite ($DEFAULTSITE): "; read MULTISITE 75 | if [ -z "$MULTISITE" ]; then 76 | MULTISITE="$DEFAULTSITE" 77 | fi 78 | fi 79 | if [ "$MULTISITE" != "$DEFAULTSITE" ]; then 80 | VALID=no 81 | for MULTI in $MULTISITES; do 82 | if [ "$MULTI" == "$MULTISITE" ]; then 83 | VALID=yes 84 | fi 85 | done 86 | if [ "$VALID" == "no" ]; then 87 | echo "$MULTISITE is not a valid multisite." 88 | exit 89 | fi 90 | fi 91 | cd $ROOT 92 | # Make sure the directory is writable by Nginx so files can be saved. 93 | sudo chown -R vagrant:www-data sites/$MULTISITE/files 94 | sudo chmod -R g+w sites/$MULTISITE/files 95 | # Make sure the directory is writable by Nginx so features can be exported. 96 | if [ -d "$ROOT/sites/$MULTISITE/features" ]; then 97 | sudo chown -R vagrant:www-data sites/$MULTISITE/features 98 | sudo chmod -R g+w sites/$MULTISITE/features 99 | fi 100 | if [ -d "$ROOT/sites/$MULTISITE/modules/features" ]; then 101 | sudo chown -R vagrant:www-data sites/$MULTISITE/modules/features 102 | sudo chmod -R g+w sites/$MULTISITE/modules/features 103 | fi 104 | if [ -d "$ROOT/sites/$MULTISITE/modules/custom/features" ]; then 105 | sudo chown -R vagrant:www-data sites/$MULTISITE/modules/custom/features 106 | sudo chmod -R g+w sites/$MULTISITE/modules/custom/features 107 | fi 108 | drush -l $MULTISITE rr 109 | else 110 | echo "" 111 | echo "Purpose: Repairs the site database and file permissions" 112 | echo "" 113 | echo "Usage: $0 [site] [env] where [site] is a" 114 | echo " valid Nginx virtual host or Pantheon Site Name" 115 | echo " and [env] is the environment (dev, test or live)." 116 | echo "" 117 | echo " The default [site] is the current Drupal root" 118 | echo " and the default [env] is dev." 119 | echo "" 120 | fi 121 | -------------------------------------------------------------------------------- /site-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check for prerequisites 4 | GIT=$(which git) 5 | if [ $? == 1 ]; then 6 | echo "Git is not installed. See https://github.com/git/git." 7 | exit 8 | fi 9 | TERMINUS=$(which terminus) 10 | if [ $? == 1 ]; then 11 | echo "Terminus is not installed. See https://github.com/pantheon-systems/cli." 12 | exit 13 | fi 14 | DRUSH=$(which drush) 15 | if [ $? == 1 ]; then 16 | echo "Drush is not installed. See http://www.drush.org/en/master/install." 17 | exit 18 | fi 19 | 20 | # Store command arguments 21 | SITE="" 22 | if test $1; then 23 | SITE=$1 24 | fi 25 | ENV=dev 26 | if test $2; then 27 | ENV=$2 28 | fi 29 | PROFILE="" 30 | if test $3; then 31 | PROFILE=$3 32 | fi 33 | MULTISITE="default" 34 | if test $4; then 35 | MULTISITE=$4 36 | fi 37 | 38 | # Retrieve stored Terminus credentials 39 | EMAIL="" 40 | PASSWORD="" 41 | HTTPUSER="" 42 | HTTPPASS="" 43 | if [ -f $HOME/.terminus_auth ]; then 44 | while read line; do 45 | for pair in $line; do 46 | set -- $(echo $pair | tr '=' ' ') 47 | if [ "$1" == "email" ]; then 48 | EMAIL=${line#"$1="} 49 | fi 50 | if [ "$1" == "password" ]; then 51 | PASSWORD=${line#"$1="} 52 | fi 53 | if [ "$1" == "httpuser" ]; then 54 | HTTPUSER=${line#"$1="} 55 | fi 56 | if [ "$1" == "httppass" ]; then 57 | HTTPPASS=${line#"$1="} 58 | fi 59 | done 60 | done < $HOME/.terminus_auth 61 | fi 62 | 63 | # Terminus authentication prompts 64 | WHOAMI=$($TERMINUS auth whoami) 65 | if [ $? == 1 ]; then 66 | if [ -z "$EMAIL" ]; then 67 | echo -n "Enter your Pantheon dashboard email address: "; read EMAIL 68 | if [ -z "$EMAIL" ]; then 69 | exit 70 | else 71 | echo -n "Save email address? (Y/n): "; read -n 1 SAVEMAIL 72 | echo "" 73 | if [ -z "$SAVEMAIL" ]; then 74 | SAVEMAIL=y 75 | fi 76 | if [ "$SAVEMAIL" == "Y" ]; then 77 | SAVEMAIL=y 78 | fi 79 | if [ "$SAVEMAIL" == "y" ]; then 80 | echo "email=$EMAIL" > $HOME/.terminus_auth 81 | fi 82 | fi 83 | fi 84 | if [ -z "$PASSWORD" ]; then 85 | echo -n "Enter your Pantheon dashboard password: "; read -s PASSWORD 86 | if [ -z "$PASSWORD" ]; then 87 | exit 88 | else 89 | echo -n "Save password? (y/N): "; read -n 1 SAVEPASS 90 | echo "" 91 | if [ "$SAVEPASS" == "Y" ]; then 92 | SAVEPASS=y 93 | fi 94 | if [ "$SAVEPASS" == "y" ]; then 95 | echo "password=$PASSWORD" >> $HOME/.terminus_auth 96 | fi 97 | fi 98 | fi 99 | if [ -z "$HTTPUSER" ]; then 100 | echo -n "Enter the HTTP Basic Authentication username: "; read HTTPUSER 101 | if [ ! -z "$HTTPUSER" ]; then 102 | echo "httpuser=$HTTPUSER" >> $HOME/.terminus_auth 103 | fi 104 | fi 105 | if [ -z "$HTTPPASS" ]; then 106 | echo -n "Enter the HTTP Basic Authentication password: "; read -s HTTPPASS 107 | if [ ! -z "$HTTPPASS" ]; then 108 | echo "httppass=$HTTPPASS" >> $HOME/.terminus_auth 109 | fi 110 | fi 111 | # Change email to match commits to Pantheon 112 | GITEMAIL=$($GIT config --get user.email) 113 | if [ "$GITEMAIL" != "$EMAIL" ]; then 114 | $GIT config --global user.email $EMAIL 115 | fi 116 | $TERMINUS auth login $EMAIL --password="$PASSWORD" 117 | fi 118 | 119 | # Remove saved credentials if unable to login 120 | WHOAMI=$($TERMINUS auth whoami) 121 | if [ $? == 1 ]; then 122 | if [ -f $HOME/.terminus_auth ]; then 123 | rm -f $HOME/.terminus_auth 124 | fi 125 | exit 126 | fi 127 | 128 | # Prompt for the Pantheon Site Name 129 | if [ -z "$SITE" ]; then 130 | echo "" 131 | $TERMINUS sites list 132 | echo -n "Enter the Pantheon Site Name: "; read SITE 133 | if [ -z "$SITE" ]; then 134 | exit 135 | fi 136 | fi 137 | 138 | # Validate the Pantheon Site Name 139 | ID=$($TERMINUS site info --site=$SITE --field=id) 140 | if [ -z "$ID" ]; then 141 | echo "" 142 | echo "$SITE is not a valid Pantheon Site Name." 143 | echo "" 144 | exit 145 | fi 146 | 147 | 148 | # Validate the Pantheon environment 149 | GIT_CMD=$($TERMINUS site connection-info --site=$SITE --env=$ENV --field=git_command)-$ENV 150 | if [ $? == 1 ]; then 151 | echo "$ENV is not a cloneable Pantheon environment." 152 | exit 153 | fi 154 | 155 | # Remove existing site files if they exist 156 | DIR="$SITE-$ENV" 157 | if [ -d "/var/www/$DIR" ]; then 158 | sudo rm -rf /var/www/$DIR 159 | fi 160 | 161 | # Clone the Pantheon git repository 162 | cd /var/www 163 | $GIT_CMD 164 | if [ -d /var/www/$DIR ]; then 165 | DBNAME=${DIR//-/_} 166 | if [ ! -f /etc/nginx/sites-available/$DIR ]; then 167 | # Create MySQL/MariaDB database 168 | echo "drop database if exists $DBNAME" | mysql -u root 169 | echo "create database $DBNAME" | mysql -u root 170 | echo "grant all on $DBNAME.* to drupal@localhost identified by 'drupal'" | mysql -u root 171 | echo "flush privileges" | mysql -u root 172 | 173 | # Create Nginx virtual host 174 | cp /etc/nginx/conf.d/drupal.conf.example /tmp/$DIR 175 | sed -i "s,example.com,$DIR.site,g" /tmp/$DIR 176 | sed -i "s,drupal7,$DIR,g" /tmp/$DIR 177 | sudo mv /tmp/$DIR /etc/nginx/sites-available/$DIR 178 | sudo ln -s /etc/nginx/sites-available/$DIR /etc/nginx/sites-enabled/$DIR 179 | 180 | # Add synced folder 181 | FOLDER=$(grep -n "config.vm.synced_folder \"../$DIR\", \"/var/www/$DIR\"" /vagrant/Vagrantfile) 182 | if [ -z "$FOLDER" ]; then 183 | echo "" 184 | echo -n "Do you want to enable synced folders? (Y/n): "; read -n 1 SYNC 185 | echo "" 186 | if [ -z "$SYNC" ]; then 187 | SYNC=y 188 | fi 189 | if [ "$SYNC" == "Y" ]; then 190 | SYNC=y 191 | fi 192 | if [ "$SYNC" == "y" ]; then 193 | echo "" 194 | echo -n "Do you want to enable NFS? (Y/n): "; read -n 1 NFS 195 | echo "" 196 | if [ -z "$NFS" ]; then 197 | NFS=y 198 | fi 199 | if [ "$NFS" == "Y" ]; then 200 | NFS=y 201 | fi 202 | POS=$(grep -n '# config.vm.synced_folder "../data", "/vagrant_data"' /vagrant/Vagrantfile | cut -d':' -f1) 203 | head -$POS /vagrant/Vagrantfile > /tmp/$DIR 204 | if [ "$NFS" == "y" ]; then 205 | echo " config.vm.synced_folder \"../$DIR\", \"/var/www/$DIR\", type: \"nfs\"" >> /tmp/$DIR 206 | else 207 | echo " config.vm.synced_folder \"../$DIR\", \"/var/www/$DIR\"" >> /tmp/$DIR 208 | fi 209 | tail -$(($(cat /vagrant/Vagrantfile | wc -l)-$POS)) /vagrant/Vagrantfile >> /tmp/$DIR 210 | sudo mv -f /tmp/$DIR /vagrant/Vagrantfile 211 | echo "" 212 | echo "Synced folder configured from /var/www/$DIR to ../$DIR." 213 | echo "" 214 | echo "Before performing an installation with site-install, execute the following:" 215 | echo "" 216 | echo "vagrant@debian:~$ exit" 217 | echo "$ mkdir ../$DIR" 218 | if [ "$NFS" == "y" ]; then 219 | echo "$ vagrant plugin install vagrant-winnfsd (Windows host only)" 220 | fi 221 | echo "$ vagrant reload" 222 | echo "$ vagrant ssh" 223 | echo "vagrant@debian:~$ site-install $SITE $ENV" 224 | echo "" 225 | echo "Otherwise, the next time the VM is loaded with vagrant up, the existing site files will be removed." 226 | echo "" 227 | exit 228 | fi 229 | fi 230 | fi 231 | 232 | # Set install profile 233 | PROFS=$(ls /var/www/$DIR/profiles) 234 | if [ -z "$PROFILE" ]; then 235 | echo "" 236 | echo "The following install profiles are available:" 237 | echo $PROFS 238 | echo "" 239 | echo -n "Enter the install profile: "; read PROFILE 240 | if [ -z "$PROFILE" ]; then 241 | exit 242 | fi 243 | fi 244 | VALID=no 245 | for PROF in $PROFS; do 246 | if [ "$PROF" == "$PROFILE" ]; then 247 | VALID=yes 248 | fi 249 | done 250 | if [ "$VALID" == "no" ]; then 251 | echo "$PROFILE is not a valid install profile." 252 | exit 253 | fi 254 | 255 | # Set multisite 256 | MULTISITES="" 257 | DEFAULTSITE="default" 258 | cd /var/www/$DIR/sites 259 | SITES=$(echo $(ls -d */) | sed 's,/,,g') 260 | for S in $SITES; do 261 | if [[ "$S" != "all" && -f "/var/www/$DIR/sites/$S/settings.php" ]]; then 262 | if [ -z "$MULTISITES" ]; then 263 | MULTISITES="$S" 264 | else 265 | MULTISITES="$MULTISITES $S" 266 | fi 267 | DEFAULTSITE="$S" 268 | fi 269 | done 270 | if [ "$DEFAULTSITE" == "$MULTISITES" ]; then 271 | MULTISITE="$DEFAULTSITE" 272 | fi 273 | if [[ "$MULTISITE" == "default" && "$MULTISITES" != "default" ]]; then 274 | echo "" 275 | echo "The following multisites are available:" 276 | echo $MULTISITES 277 | echo "" 278 | echo -n "Enter the multisite ($DEFAULTSITE): "; read MULTISITE 279 | if [ -z "$MULTISITE" ]; then 280 | MULTISITE="$DEFAULTSITE" 281 | fi 282 | fi 283 | if [ "$MULTISITE" != "$DEFAULTSITE" ]; then 284 | VALID=no 285 | for MULTI in $MULTISITES; do 286 | if [ "$MULTI" == "$MULTISITE" ]; then 287 | VALID=yes 288 | fi 289 | done 290 | if [ "$VALID" == "no" ]; then 291 | echo "$MULTISITE is not a valid multisite." 292 | exit 293 | fi 294 | fi 295 | 296 | # Replace placeholder credentials if needed 297 | SETTINGS="/var/www/$DIR/sites/$MULTISITE/settings.php" 298 | sed -i "s/DATABASE/$DBNAME/g" $SETTINGS 299 | sed -i "s/USERNAME/drupal/g" $SETTINGS 300 | sed -i "s/PASSWORD/drupal/g" $SETTINGS 301 | 302 | # Perform the drush site install 303 | cd /var/www/$DIR 304 | $DRUSH site-install $PROFILE --account-name=admin --account-pass=admin --db-url=mysql://drupal:drupal@localhost/$DBNAME --site-name=$DIR --sites-subdir=$MULTISITE -v -y 305 | if [ -d /var/www/$DIR/sites/all/modules ]; then 306 | # Make sure essential directories exist 307 | if [ ! -d /var/www/$DIR/sites/all/modules/contrib ]; then 308 | mkdir /var/www/$DIR/sites/all/modules/contrib 309 | fi 310 | if [ ! -d /var/www/$DIR/sites/all/modules/custom ]; then 311 | mkdir /var/www/$DIR/sites/all/modules/custom 312 | fi 313 | if [ ! -d /var/www/$DIR/sites/all/modules/features ]; then 314 | mkdir /var/www/$DIR/sites/all/modules/features 315 | fi 316 | if [ ! -d /var/www/$DIR/sites/default/files ]; then 317 | mkdir /var/www/$DIR/sites/default/files 318 | fi 319 | 320 | # Fix file permissions 321 | for S in $SITES; do 322 | sudo chmod -R ug+w /var/www/$DIR/sites/$S 323 | if [ -d "/var/www/$DIR/sites/$S/files" ]; then 324 | sudo chown -R vagrant:www-data /var/www/$DIR/sites/$S/files 325 | fi 326 | done 327 | 328 | # Create settings.local.php 329 | LOCALSETTINGS=${SETTINGS//settings.php/settings.local.php} 330 | cp $SETTINGS $LOCALSETTINGS 331 | $GIT checkout $SETTINGS 332 | LOCAL="if (file_exists(dirname(__FILE__) . '/settings.local.php')) { 333 | include dirname(__FILE__) . '/settings.local.php'; 334 | }" 335 | LAST3=$(tail -3 $SETTINGS) 336 | if [ "$LAST3" != "$LOCAL" ]; then 337 | echo "" >> $SETTINGS 338 | echo "if (file_exists(dirname(__FILE__) . '/settings.local.php')) {" >> $SETTINGS 339 | echo " include dirname(__FILE__) . '/settings.local.php';" >> $SETTINGS 340 | echo "}" >> $SETTINGS 341 | else 342 | head -$(($(cat $LOCALSETTINGS | wc -l)-3)) $LOCALSETTINGS > /tmp/settings.local.php 343 | sudo mv -f /tmp/settings.local.php $LOCALSETTINGS 344 | fi 345 | 346 | # Install registry rebuild 347 | if [ ! -f "$HOME/.drush/registry_rebuild/registry_rebuild.php" ]; then 348 | $DRUSH dl registry_rebuild -y 349 | $DRUSH cc drush 350 | fi 351 | 352 | # Define drush based on multisite 353 | if [ "$MULTISITE" != "default" ]; then 354 | DRUSH="$DRUSH -l $MULTISITE" 355 | fi 356 | 357 | # Download and load the latest database backup if it exists 358 | DB=$($TERMINUS site backups get --site=$SITE --env=$ENV --element=db --latest) 359 | if [ ! -z "$DB" ]; then 360 | LABEL=${DB:0:11} 361 | if [ "$LABEL" == "Backup URL:" ]; then 362 | DB=${DB:12} 363 | fi 364 | NEW_DB="$DIR.sql" 365 | echo "Downloading latest database backup $DB to $NEW_DB.gz..." 366 | curl -o $NEW_DB.gz $DB 367 | gunzip $NEW_DB.gz 368 | $DRUSH sql-drop -y 369 | echo "Loading $NEW_DB..." 370 | $DRUSH sqlc < $NEW_DB 371 | # Make sure the Drupal admin user login is admin/admin 372 | $DRUSH sqlq "update users set name = 'admin' where uid = 1" 373 | $DRUSH upwd admin --password=admin 374 | $DRUSH rr 375 | fi 376 | 377 | # Make sure the Redis service is running 378 | REDIS_PID=$(pidof redis-server) 379 | if [ -z "$REDIS_PID" ]; then 380 | REDIS_PACKAGE=$(dpkg -l | grep redis-server) 381 | if [ -z "$REDIS_PACKAGE" ]; then 382 | sudo apt-get install redis-server -y 383 | else 384 | sudo service redis-server start 385 | fi 386 | fi 387 | 388 | # Prompt to enable Redis only if the service is running 389 | REDIS_PID=$(pidof redis-server) 390 | if [ ! -z "$REDIS_PID" ]; then 391 | echo "" 392 | echo -n "Would you like to enable Redis? (Y/n): "; read -n 1 REDIS 393 | echo "" 394 | if [ -z "$REDIS" ]; then 395 | REDIS=y 396 | fi 397 | if [ "$REDIS" == "Y" ]; then 398 | REDIS=y 399 | fi 400 | if [ "$REDIS" == "y" ]; then 401 | REDISAUTOLOAD=$(find sites/ -name redis.autoload.inc) 402 | REDISLOCK=$(find sites/ -name redis.lock.inc) 403 | if [[ -z "$REDISAUTOLOAD" || -z "$REDISLOCK" ]]; then 404 | $DRUSH dl -y redis 405 | REDISAUTOLOAD=$(find sites/ -name redis.autoload.inc) 406 | REDISLOCK=$(find sites/ -name redis.lock.inc) 407 | fi 408 | $DRUSH en -y redis 409 | REDIS_CONFIG=$(grep "Use Redis for caching." $LOCALSETTINGS) 410 | if [ -z "$REDIS_CONFIG" ]; then 411 | cat << EOF >> $LOCALSETTINGS 412 | // Use Redis for caching. 413 | \$conf['redis_client_interface'] = 'PhpRedis'; 414 | \$conf['cache_backends'][] = '$REDISAUTOLOAD'; 415 | \$conf['cache_default_class'] = 'Redis_Cache'; 416 | // Do not use Redis for cache_form (no performance difference). 417 | \$conf['cache_class_cache_form'] = 'DrupalDatabaseCache'; 418 | // Use Redis for Drupal locks (semaphore). 419 | \$conf['lock_inc'] = '$REDISLOCK'; 420 | EOF 421 | fi 422 | fi 423 | fi 424 | 425 | # Prompt to enable XHProf 426 | echo "" 427 | echo -n "Would you like to enable XHProf? (y/N): "; read -n 1 XHPROF 428 | echo "" 429 | if [ "$XHPROF" == "Y" ]; then 430 | XHPROF=y 431 | fi 432 | if [ "$XHPROF" == "y" ]; then 433 | XHPROF_MOD=$(dpkg -l | grep php5-xhprof) 434 | if [ -z "$XHPROF_MOD" ]; then 435 | /vagrant/xhprof-install.sh 436 | fi 437 | XHPROF_PATH="/var/www/$DIR/sites/all/modules/contrib/xhprof" 438 | if [ ! -d "$XHPROF_PATH" ]; then 439 | $DRUSH dl xhprof 440 | fi 441 | $DRUSH rr 442 | $DRUSH en -y xhprof 443 | # Apply patch to expose paths. See https://www.drupal.org/node/2354853. 444 | if [ ! -f "$XHPROF_PATH/xhprof-2354853-paths-d7-4.patch" ]; then 445 | cd $XHPROF_PATH 446 | wget https://www.drupal.org/files/issues/xhprof-2354853-paths-d7-4.patch 447 | patch -p1 < xhprof-2354853-paths-d7-4.patch 448 | fi 449 | $DRUSH vset xhprof_default_class 'XHProfRunsFile' 450 | $DRUSH vset xhprof_disable_admin_paths 1 451 | $DRUSH vset xhprof_enabled 1 452 | $DRUSH vset xhprof_flags_cpu 1 453 | $DRUSH vset xhprof_flags_memory 1 454 | $DRUSH vset xhprof_interval '' 455 | fi 456 | 457 | # Prompt to enable Xdebug 458 | XDEBUG_MOD=$(dpkg -l | grep php5-xdebug) 459 | if [ -z "$XDEBUG_MOD" ]; then 460 | echo "" 461 | echo -n "Would you like to enable Xdebug? (y/N): "; read -n 1 XDEBUG 462 | echo "" 463 | if [ "$XDEBUG" == "Y" ]; then 464 | XDEBUG=y 465 | fi 466 | if [ "$XDEBUG" == "y" ]; then 467 | /vagrant/xdebug-install.sh 468 | fi 469 | fi 470 | 471 | # Prompt to enable Stage File Proxy 472 | echo "" 473 | echo -n "Would you like to enable Stage File Proxy? (Y/n): "; read -n 1 PROXY 474 | echo "" 475 | if [ -z "$PROXY" ]; then 476 | PROXY=y 477 | fi 478 | if [ "$PROXY" == "Y" ]; then 479 | PROXY=y 480 | fi 481 | if [ "$PROXY" == "y" ]; then 482 | $DRUSH dl -n stage_file_proxy 483 | $DRUSH en -y stage_file_proxy 484 | DOMAIN=$(echo $($TERMINUS site hostnames list --site=$SITE --env=$ENV) | cut -d" " -f4) 485 | if [ ! -z "$DOMAIN" ]; then 486 | $DRUSH vset stage_file_proxy_hotlink 1 487 | if [[ ! -z "$HTTPUSER" && ! -z "$HTTPPASS" ]]; then 488 | $DRUSH vset stage_file_proxy_origin "https://$HTTPUSER:$HTTPPASS@$DOMAIN" 489 | else 490 | $DRUSH vset stage_file_proxy_origin "https://$DOMAIN" 491 | fi 492 | fi 493 | else 494 | cd /var/www/$DIR/sites/$MULTISITE/files 495 | FILES=$($TERMINUS site backups get --site=$SITE --env=$ENV --element=files --latest) 496 | if [ ! -z "$FILES" ]; then 497 | LABEL=${FILES:0:11} 498 | if [ "$LABEL" == "Backup URL:" ]; then 499 | FILES=${FILES:12} 500 | fi 501 | NEW_FILES=$DIR-files.tar.gz 502 | echo "Downloading latest files backup $FILES to $NEW_FILES..." 503 | curl -o $NEW_FILES $FILES 504 | tar zxvf $NEW_FILES 505 | cp -r files_$ENV/* . 506 | rm -rf files_$ENV/ 507 | cd .. 508 | sudo chown -R vagrant:www-data files/ 509 | sudo chmod -R g+w files/ 510 | fi 511 | fi 512 | 513 | # Enable development modules 514 | #$DRUSH dl -n migrate migrate_extras coder devel devel_themer hacked redis simplehtmldom-7.x-1.12 stage_file_proxy 515 | #$DRUSH en -y migrate_extras coder devel_themer hacked redis stage_file_proxy 516 | 517 | # Disable unused/unwanted modules 518 | $DRUSH dis -y overlay 519 | 520 | # Disable cron 521 | ELYSIA=$($DRUSH pml --status=Enabled | grep elysia_cron) 522 | if [ ! -z "$ELYSIA" ]; then 523 | $DRUSH vset elysia_cron_disabled 1 524 | fi 525 | $DRUSH vset cron_safe_threshold 0 526 | 527 | # Restart web services 528 | /vagrant/restart-lemp.sh 529 | 530 | # Output final message 531 | echo "" 532 | echo "Make sure '192.168.33.10 $DIR.site' exists in your local hosts file and then open http://$DIR.site in your browser." 533 | echo "The local hosts file is located at /etc/hosts (MAC/BSD/Linux) or C:\Windows\System32\drivers\etc\hosts (Windows)." 534 | echo "" 535 | else 536 | echo "drush site-install failed." 537 | fi 538 | else 539 | echo "git clone failed." 540 | fi 541 | -------------------------------------------------------------------------------- /site-log.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get the Pantheon site name 4 | SITE="" 5 | if test $1; then 6 | SITE=$1 7 | fi 8 | 9 | # Get the environment 10 | ENV=dev 11 | if test $2; then 12 | ENV=$2 13 | fi 14 | 15 | # Set the Drupal root directory 16 | ROOT=$($DRUSH status root --format=list) 17 | if [ -z $ROOT ]; then 18 | ROOT=/var/www/$SITE-$ENV 19 | fi 20 | 21 | # Validate the Drupal root directory 22 | if [ ! -d $ROOT ]; then 23 | echo "The Pantheon site cannot be located." 24 | exit 25 | fi 26 | 27 | # Get the Pantheon site name from Drupal root 28 | if [ -z $SITE ]; then 29 | BASE=${ROOT:0:8} 30 | if [ $BASE == "/var/www" ]; then 31 | DIR=${ROOT:9} 32 | END="-$ENV" 33 | LEN=${#END} 34 | SITE=${DIR:0:(-$LEN)} 35 | fi 36 | fi 37 | 38 | if [ ! -z $SITE ]; then 39 | TYPE=error 40 | if test $3; then 41 | TYPE=$3 42 | fi 43 | if [[ "$TYPE" != "access" && "$TYPE" != "error" ]]; then 44 | echo "Valid options are access or error. The default value is error." 45 | exit 46 | fi 47 | CMD=tail 48 | if test $4; then 49 | CMD=$4 50 | fi 51 | if [[ "$CMD" != "less" && "$CMD" != "tail" ]]; then 52 | echo "Valid options are less or tail. The default value is tail." 53 | exit 54 | fi 55 | sudo $CMD /var/log/nginx/$SITE-$ENV-$TYPE.log 56 | else 57 | echo "" 58 | echo "Purpose: Display the web server logs for a site" 59 | echo "" 60 | echo "Usage: $0 [site] [env] [access|error] [less|tail] where [site]" 61 | echo " is a valid Nginx virtual host or Pantheon Site Name," 62 | echo " [env] is the environment (dev, test or live)," 63 | echo " [access|error] is the log type and" 64 | echo " [less|tail] is the command to execute." 65 | echo "" 66 | echo " The default [site] is the current Drupal root," 67 | echo " the default [env] is dev, the default type is error" 68 | echo " and the default command is tail." 69 | echo "" 70 | fi 71 | -------------------------------------------------------------------------------- /site-sync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check for prerequisites 4 | GIT=$(which git) 5 | if [ $? == 1 ]; then 6 | echo "Git is not installed. See https://github.com/git/git." 7 | exit 8 | fi 9 | TERMINUS=$(which terminus) 10 | if [ $? == 1 ]; then 11 | echo "Terminus is not installed. See https://github.com/pantheon-systems/cli." 12 | exit 13 | fi 14 | DRUSH=$(which drush) 15 | if [ $? == 1 ]; then 16 | echo "Drush is not installed. See http://www.drush.org/en/master/install." 17 | exit 18 | fi 19 | 20 | # Get the Pantheon site name 21 | SITE="" 22 | if test $1; then 23 | SITE=$1 24 | fi 25 | 26 | # Get the environment 27 | ENV=dev 28 | if test $2; then 29 | ENV=$2 30 | fi 31 | 32 | # Set the Drupal root directory 33 | ROOT=$($DRUSH status root --format=list) 34 | if [ -z $ROOT ]; then 35 | ROOT=/var/www/$SITE-$ENV 36 | fi 37 | 38 | # Validate the Drupal root directory 39 | if [ ! -d $ROOT ]; then 40 | echo "The Pantheon site cannot be located." 41 | exit 42 | fi 43 | 44 | # Get the Pantheon site name from Drupal root 45 | if [ -z $SITE ]; then 46 | BASE=${ROOT:0:8} 47 | if [ $BASE == "/var/www" ]; then 48 | DIR=${ROOT:9} 49 | END="-$ENV" 50 | LEN=${#END} 51 | SITE=${DIR:0:(-$LEN)} 52 | fi 53 | fi 54 | 55 | if [ ! -z $SITE ]; then 56 | # Validate the environment 57 | $TERMINUS site environment-info --site=$SITE --env=$ENV --field=id 58 | if [ $? == 1 ]; then 59 | $TERMINUS site environments --site=$SITE 60 | exit 61 | fi 62 | 63 | # Retrieve stored Terminus credentials 64 | EMAIL="" 65 | PASSWORD="" 66 | HTTPUSER="" 67 | HTTPPASS="" 68 | if [ -f $HOME/.terminus_auth ]; then 69 | while read line; do 70 | for pair in $line; do 71 | set -- $(echo $pair | tr '=' ' ') 72 | if [ "$1" == "email" ]; then 73 | EMAIL=${line#"$1="} 74 | fi 75 | if [ "$1" == "password" ]; then 76 | PASSWORD=${line#"$1="} 77 | fi 78 | if [ "$1" == "httpuser" ]; then 79 | HTTPUSER=${line#"$1="} 80 | fi 81 | if [ "$1" == "httppass" ]; then 82 | HTTPPASS=${line#"$1="} 83 | fi 84 | done 85 | done < $HOME/.terminus_auth 86 | fi 87 | 88 | # Terminus authentication prompts 89 | WHOAMI=$($TERMINUS auth whoami) 90 | if [ $? == 1 ]; then 91 | if [ -z "$EMAIL" ]; then 92 | echo -n "Enter your Pantheon email address: "; read EMAIL 93 | if [ -z "$EMAIL" ]; then 94 | exit 95 | else 96 | echo -n "Save email address? (Y/n): "; read -n 1 SAVEMAIL 97 | if [ -z "$SAVEMAIL" ]; then 98 | SAVEMAIL=y 99 | fi 100 | if [ "$SAVEMAIL" == "Y" ]; then 101 | SAVEMAIL=y 102 | fi 103 | if [ "$SAVEMAIL" == "y" ]; then 104 | echo "email=$EMAIL" > $HOME/.terminus_auth 105 | fi 106 | fi 107 | fi 108 | if [ -z "$PASSWORD" ]; then 109 | echo -n "Enter your Pantheon password: "; read -s PASSWORD 110 | if [ -z "$PASSWORD" ]; then 111 | exit 112 | else 113 | echo -n "Save password? (y/N): "; read -n 1 SAVEPASS 114 | echo $'\n' 115 | if [ "$SAVEPASS" == "Y" ]; then 116 | SAVEPASS=y 117 | fi 118 | if [ "$SAVEPASS" == "y" ]; then 119 | echo "password=$PASSWORD" >> $HOME/.terminus_auth 120 | fi 121 | fi 122 | fi 123 | if [ -z "$HTTPUSER" ]; then 124 | echo -n "Enter the HTTP Basic Authentication username: "; read HTTPUSER 125 | if [ ! -z "$HTTPUSER" ]; then 126 | echo "httpuser=$HTTPUSER" >> $HOME/.terminus_auth 127 | fi 128 | fi 129 | if [ -z "$HTTPPASS" ]; then 130 | echo -n "Enter the HTTP Basic Authentication password: "; read -s HTTPPASS 131 | if [ ! -z "$HTTPPASS" ]; then 132 | echo "httppass=$HTTPPASS" >> $HOME/.terminus_auth 133 | fi 134 | fi 135 | # Change email to match commits to Pantheon 136 | GITEMAIL=$($GIT config --get user.email) 137 | if [ "$GITEMAIL" != "$EMAIL" ]; then 138 | $GIT config --global user.email $EMAIL 139 | fi 140 | $TERMINUS auth login $EMAIL --password="$PASSWORD" 141 | fi 142 | 143 | # Remove saved credentials if unable to login 144 | WHOAMI=$($TERMINUS auth whoami) 145 | if [ $? == 1 ]; then 146 | if [ -f $HOME/.terminus_auth ]; then 147 | rm -f $HOME/.terminus_auth 148 | fi 149 | exit 150 | fi 151 | 152 | # Set multisite 153 | MULTISITE="" 154 | MULTISITES="" 155 | DEFAULTSITE="default" 156 | cd /var/www/$DIR/sites 157 | SITES=$(echo $(ls -d */) | sed 's,/,,g') 158 | for S in $SITES; do 159 | if [[ "$S" != "all" && -f "/var/www/$DIR/sites/$S/settings.php" ]]; then 160 | if [ -z "$MULTISITES" ]; then 161 | MULTISITES="$S" 162 | else 163 | MULTISITES="$MULTISITES $S" 164 | fi 165 | DEFAULTSITE="$S" 166 | fi 167 | done 168 | if [ "$DEFAULTSITE" == "$MULTISITES" ]; then 169 | MULTISITE="$DEFAULTSITE" 170 | fi 171 | if [[ "$MULTISITE" == "default" && "$MULTISITES" != "default" ]]; then 172 | echo "" 173 | echo "The following multisites are available:" 174 | echo $MULTISITES 175 | echo "" 176 | echo -n "Enter the multisite ($DEFAULTSITE): "; read MULTISITE 177 | if [ -z "$MULTISITE" ]; then 178 | MULTISITE="$DEFAULTSITE" 179 | fi 180 | fi 181 | if [ "$MULTISITE" != "$DEFAULTSITE" ]; then 182 | VALID=no 183 | for MULTI in $MULTISITES; do 184 | if [ "$MULTI" == "$MULTISITE" ]; then 185 | VALID=yes 186 | fi 187 | done 188 | if [ "$VALID" == "no" ]; then 189 | echo "$MULTISITE is not a valid multisite." 190 | exit 191 | fi 192 | fi 193 | if [ ! -f $HOME/.drush/registry_rebuild/registry_rebuild.php ]; then 194 | $DRUSH dl registry_rebuild -y 195 | $DRUSH cc drush 196 | fi 197 | if [ ! -z "$MULTISITE" ]; then 198 | DRUSH="$DRUSH -l $MULTISITE" 199 | fi 200 | 201 | # Pull the latest code changes from master 202 | cd /var/www/$DIR 203 | $GIT pull 204 | 205 | # Download the latest database backup 206 | DB=$($TERMINUS site backups get --site=$SITE --env=$ENV --element=db --latest) 207 | if [ ! -z "$DB" ]; then 208 | LABEL=${DB:0:11} 209 | if [ "$LABEL" == "Backup URL:" ]; then 210 | DB=${DB:12} 211 | fi 212 | NEW_DB="$DIR.sql" 213 | rm -f $NEW_DB $NEW_DB.gz 214 | echo "Downloading the latest database backup $DB to $NEW_DB ..." 215 | curl -o $NEW_DB.gz $DB && gunzip $NEW_DB.gz 216 | $DRUSH sql-drop -y 217 | echo "Loading $NEW_DB ..." 218 | $DRUSH sqlc < $NEW_DB 219 | fi 220 | # Make sure the Drupal admin user login is admin/admin 221 | $DRUSH sqlq "update users set name = 'admin' where uid = 1" 222 | $DRUSH upwd admin --password=admin 223 | $DRUSH rr 224 | 225 | # Prompt to enable Stage File Proxy 226 | echo -n "Would you like to enable Stage File Proxy? (Y/n): "; read -n 1 PROXY 227 | echo "" 228 | if [ -z "$PROXY" ]; then 229 | PROXY=y 230 | fi 231 | if [ "$PROXY" == "Y" ]; then 232 | PROXY=y 233 | fi 234 | if [ "$PROXY" == "y" ]; then 235 | $DRUSH dl -n stage_file_proxy 236 | $DRUSH en -y stage_file_proxy 237 | DOMAIN=$(echo $($TERMINUS site hostnames list --site=$SITE --env=$ENV) | cut -d" " -f4) 238 | if [ ! -z "$DOMAIN" ]; then 239 | $DRUSH vset stage_file_proxy_hotlink 1 240 | if [[ ! -z "$HTTPUSER" && ! -z "$HTTPPASS" ]]; then 241 | $DRUSH vset stage_file_proxy_origin "https://$HTTPUSER:$HTTPPASS@$DOMAIN" 242 | else 243 | $DRUSH vset stage_file_proxy_origin "https://$DOMAIN" 244 | fi 245 | fi 246 | else 247 | cd /var/www/$DIR/sites/$MULTISITE/files 248 | FILES=$($TERMINUS site backups get --site=$SITE --env=$ENV --element=files --latest) 249 | if [ ! -z "$FILES" ]; then 250 | LABEL=${FILES:0:11} 251 | if [ "$LABEL" == "Backup URL:" ]; then 252 | FILES=${FILES:12} 253 | fi 254 | NEW_FILES=$DIR-files.tar.gz 255 | rm -f $NEW_FILES 256 | echo "Downloading latest files backup $FILES to $NEW_FILES..." 257 | curl -o $NEW_FILES $FILES 258 | tar zxvf $NEW_FILES 259 | sudo cp -r files_$ENV/* . 260 | sudo rm -rf files_$ENV/ 261 | cd .. 262 | sudo chown -R vagrant:www-data files/ 263 | sudo chmod -R g+w files/ 264 | fi 265 | fi 266 | 267 | # Enable development modules 268 | #$DRUSH dl -n migrate migrate_extras coder devel devel_themer hacked redis simplehtmldom-7.x-1.12 stage_file_proxy 269 | #$DRUSH en -y migrate_extras coder devel_themer hacked redis stage_file_proxy 270 | 271 | # Disable unused/unwanted modules 272 | $DRUSH dis -y overlay 273 | 274 | # Disable cron 275 | ELYSIA=$($DRUSH pml --status=Enabled | grep elysia_cron) 276 | if [ ! -z "$ELYSIA" ]; then 277 | $DRUSH vset elysia_cron_disabled 1 278 | fi 279 | $DRUSH vset cron_safe_threshold 0 280 | 281 | # Restart web services 282 | /vagrant/restart-lemp.sh 283 | else 284 | echo "" 285 | echo "Purpose: Downloads the latest code, files and database to your local environment" 286 | echo "" 287 | echo "Usage: $0 [site] [env] where [site] is a" 288 | echo " valid Nginx virtual host or Pantheon Site Name" 289 | echo " and [env] is the environment (dev, test or live)." 290 | echo "" 291 | echo " The default [site] is the current Drupal root" 292 | echo " and the default [env] is dev." 293 | echo "" 294 | fi 295 | -------------------------------------------------------------------------------- /ssh-config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ssh-keygen -f $HOME/.ssh/id_rsa -t rsa -N '' 3 | echo "" 4 | echo "To enable passwordless access, add the public ssh key below to your Pantheon account. See https://pantheon.io/docs/articles/users/loading-ssh-keys/." 5 | echo "" 6 | cat $HOME/.ssh/id_rsa.pub 7 | echo "" 8 | -------------------------------------------------------------------------------- /vim-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo -n "Warning: This script will overwrite any existing vim settings. Are you sure you want to proceed? (y/N): "; read -n 1 PROCEED 3 | echo "" 4 | if [ -z "$PROCEED" ]; then 5 | exit 6 | fi 7 | if [ "$PROCEED" == "Y" ]; then 8 | PROCEED=y 9 | fi 10 | if [ "$PROCEED" != "y" ]; then 11 | exit 12 | fi 13 | VIM_NOX=$(dpkg -l | grep vim-nox) 14 | if [ -z "$VIM_NOX" ]; then 15 | sudo apt-get install vim-nox -y 16 | fi 17 | CTAGS=$(dpkg -l | grep exuberant-ctags) 18 | if [ -z "$CTAGS" ]; then 19 | sudo apt-get install exuberant-ctags -y 20 | fi 21 | SCREEN=$(dpkg -l | grep screen) 22 | if [ -z "$SCREEN" ]; then 23 | sudo apt-get install screen -y 24 | fi 25 | cd 26 | rm -f .vimrc 27 | rm -rf .vim/ 28 | mkdir .vim 29 | cd .vim 30 | mkdir bundle 31 | git init 32 | git submodule add https://github.com/tpope/vim-pathogen.git bundle/pathogen 33 | git submodule update --init 34 | ln -s bundle/pathogen/autoload/ autoload 35 | git submodule add https://github.com/flazz/vim-colorschemes.git bundle/colorschemes 36 | git submodule update --init 37 | ln -s bundle/colorschemes/colors/ colors 38 | git submodule add https://github.com/kien/ctrlp.vim.git bundle/ctrlp 39 | git submodule update --init 40 | git submodule add https://github.com/tpope/vim-fugitive.git bundle/fugitive 41 | git submodule update --init 42 | git submodule add https://github.com/wookiehangover/jshint.vim.git bundle/jshint 43 | git submodule update --init 44 | git submodule add https://github.com/scrooloose/nerdcommenter.git bundle/nerdcommenter 45 | git submodule update --init 46 | git submodule add https://github.com/scrooloose/nerdtree.git bundle/nerdtree 47 | git submodule update --init 48 | git submodule add https://github.com/Lokaltog/vim-powerline bundle/powerline 49 | git submodule update --init 50 | git submodule add https://github.com/ervandew/screen.git bundle/screen 51 | git submodule update --init 52 | git submodule add https://github.com/msanders/snipmate.vim.git bundle/snipmate 53 | git submodule update --init 54 | git submodule add https://github.com/ervandew/supertab.git bundle/supertab 55 | git submodule update --init 56 | git submodule add https://github.com/tpope/vim-surround.git bundle/surround 57 | git submodule update --init 58 | git submodule add https://github.com/scrooloose/syntastic.git bundle/syntastic 59 | git submodule update --init 60 | git submodule add https://github.com/vim-scripts/SyntaxComplete.git bundle/syntaxcomplete 61 | git submodule update --init 62 | git submodule add https://github.com/majutsushi/tagbar.git bundle/tagbar 63 | git submodule update --init 64 | git submodule add https://github.com/joonty/vdebug.git bundle/vdebug 65 | git submodule update --init 66 | git submodule add http://git.drupal.org/project/vimrc.git bundle/drupalvim 67 | git submodule update --init 68 | cat << "EOF" >> ~/.vimrc 69 | " Allow Vim-only settings even if they break vi keybindings. 70 | set nocompatible 71 | 72 | " Always edit in utf-8: 73 | set encoding=utf-8 74 | 75 | " Enable filetype detection 76 | filetype plugin on 77 | 78 | " General settings 79 | set incsearch "Find as you type 80 | set scrolloff=2 "Number of lines to keep above/below cursor 81 | set number "Show line numbers 82 | set wildmode=longest,list "Complete longest string, then list alternatives 83 | set pastetoggle= "Toggle paste mode 84 | set fileformats=unix "Use Unix line endings 85 | set history=300 "Number of commands to remember 86 | set showmode "Show whether in Visual, Replace, or Insert Mode 87 | set showmatch "Show matching brackets/parentheses 88 | set backspace=2 "Use standard backspace behavior 89 | set hlsearch "Highlight matches in search 90 | set ruler "Show line and column number 91 | set formatoptions=1 "Don't wrap text after a one-letter word 92 | set linebreak "Break lines when appropriate 93 | set expandtab 94 | set tabstop=2 95 | set shiftwidth=2 96 | set autoindent 97 | set smartindent 98 | 99 | " Enforce consistent line endings: if 'ff' is set to "unix" and there are any 100 | " stray '\r' characters at ends of lines, then automatically remove them. See 101 | " $VIMRUNTIME/indent/php.vim . 102 | let PHP_removeCRwhenUnix = 1 103 | 104 | " Persistent Undo (vim 7.3 and later) 105 | if exists('&undofile') && !&undofile 106 | set undodir=~/.vim_runtime/undodir 107 | set undofile 108 | endif 109 | 110 | " Enable syntax highlighting 111 | if &t_Co > 1 112 | syntax enable 113 | endif 114 | syntax on 115 | 116 | " When in split screen, map and to switch panes. 117 | nn  w 118 | nn  W 119 | 120 | " Custom key mapping 121 | map :redo 122 | map :tabn 123 | map :tabp 124 | 125 | " Uncomment the following to have Vim jump to the last position when 126 | " reopening a file 127 | if has("autocmd") 128 | au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") 129 | \| exe "normal! g'\"" | endif 130 | endif 131 | 132 | " Load plugins 133 | call pathogen#infect('~/.vim/bundle/drupalvim/bundle/vim-plugin-for-drupal/{}') 134 | call pathogen#infect() 135 | call pathogen#helptags() 136 | 137 | " Set the color scheme 138 | if ! has("gui_running") 139 | set t_Co=256 140 | endif 141 | " feel free to choose :set background=dark for a different style 142 | set background=light 143 | colors peaksea 144 | 145 | " Check syntax 146 | nnoremap :SyntasticCheck 147 | let g:syntastic_aggregate_errors = 1 148 | let g:syntastic_always_populate_loc_list = 1 149 | let g:syntastic_auto_jump = 2 150 | let g:syntastic_auto_loc_list = 1 151 | let g:syntastic_debug = 0 152 | let g:syntastic_enable_highlighting = 1 153 | let g:syntastic_enable_signs = 1 154 | let g:syntastic_error_symbol = '✗' 155 | let g:syntastic_php_checkers = ['php', 'phpcs', 'phpmd'] 156 | let g:syntastic_php_phpcs_args = '--standard=Drupal --report=csv --extensions=inc,install,module,php,profile,test,theme' 157 | let g:syntastic_phpcs_disable = 1 158 | let g:syntastic_quiet_messages = { "level": "warnings", "type": "syntax" } 159 | let g:syntastic_stl_format = '[%E{Errors: %e starting on line %fe}%B{, }%W{Warnings: %w starting on line %fw}]' 160 | let g:syntastic_style_error_symbol = 'S✗' 161 | let g:syntastic_style_warning_symbol = 'S⚠' 162 | let g:syntastic_warning_symbol = '⚠' 163 | highlight SyntasticErrorLine guibg=red 164 | highlight SyntasticWarningLine guibg=yellow 165 | 166 | " Toggle line numbers 167 | nnoremap :set invnumber 168 | 169 | " Highlight trailing whitespace 170 | highlight ExtraWhitespace ctermbg=red guibg=red 171 | match ExtraWhitespace /\s\+$/ 172 | autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ 173 | autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@ :ScreenShell compass watch 185 | 186 | " Toggle the NERDTree window 187 | nnoremap :NERDTreeToggle 188 | let NERDTreeShowHidden=1 189 | let NERDTreeDirArrows=1 190 | let NERDTreeAutoDeleteBuffer=1 191 | 192 | " Toggle the Tagbar window 193 | nnoremap :TagbarToggle 194 | 195 | " Toggle current fold open/closed 196 | nnoremap za 197 | EOF 198 | -------------------------------------------------------------------------------- /webmin-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | wget http://www.webmin.com/jcameron-key.asc 3 | sudo apt-key add jcameron-key.asc 4 | rm -f jcameron-key.asc 5 | sudo add-apt-repository 'deb http://download.webmin.com/download/repository sarge contrib' 6 | sudo add-apt-repository -r 'deb-src http://download.webmin.com/download/repository sarge contrib' 7 | sudo add-apt-repository 'deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib' 8 | sudo add-apt-repository -r 'deb-src http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib' 9 | sudo apt-get update 10 | sudo apt-get install webmin -y 11 | -------------------------------------------------------------------------------- /xdebug-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | XDEBUG=$(dpkg -l | grep php5-xdebug) 3 | if [ ! -z "$XDEBUG" ]; then 4 | echo "Xdebug is already installed." 5 | exit 6 | fi 7 | echo "Installing Xdebug..." 8 | sudo apt-get install php5-xdebug -y --force-yes 9 | if [ ! -d /var/log/xdebug ]; then 10 | sudo mkdir /var/log/xdebug 11 | sudo chown www-data:www-data /var/log/xdebug 12 | fi 13 | sudo sh -c 'cat << "EOF" >> /etc/php5/mods-available/xdebug.ini 14 | xdebug.default_enable=1 15 | xdebug.idekey="xdebug" 16 | xdebug.remote_enable=1 17 | xdebug.remote_autostart=0 18 | xdebug.remote_port=9000 19 | xdebug.remote_handler="dbgp" 20 | xdebug.remote_log="/var/log/xdebug/xdebug.log" 21 | xdebug.remote_host="192.168.33.10" 22 | EOF' 23 | /vagrant/restart-lemp.sh 24 | -------------------------------------------------------------------------------- /xhprof-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | XHPROF=$(dpkg -l | grep php5-xhprof) 3 | if [ ! -z "$XHPROF" ]; then 4 | echo "XHProf is already installed." 5 | exit 6 | fi 7 | echo "Installing XHProf..." 8 | sudo apt-get install php5-xhprof -y 9 | /vagrant/restart-lemp.sh 10 | --------------------------------------------------------------------------------