├── .gitignore ├── .gitignore.wpengine ├── build-wpengine.sh ├── composer.json ├── license.txt ├── readme.md ├── ssh ├── known_hosts └── ssh_hosts ├── vvv-hosts ├── vvv-init.sh ├── vvv-nginx.conf ├── wp-cli.yml └── wrapper-composer.sh /.gitignore: -------------------------------------------------------------------------------- 1 | initial-data.sql 2 | build 3 | package 4 | 5 | ## START WordPress show/ignore 6 | ## So we don't get the core files in git 7 | 8 | # DO ignore htdocs… 9 | htdocs/*.* 10 | htdocs/*/* 11 | 12 | # …except do NOT ignore 13 | !htdocs/wp-content/mu-plugins/*.php 14 | !htdocs/wp-content/*.php 15 | 16 | # … except DO ignore 17 | htdocs/wp-contents/*/* 18 | htdocs/wp-content/mu-plugins/*/* 19 | htdocs/wp-content/db.php 20 | htdocs/wp-content/index.php 21 | htdocs/wp-content/object-cache.php 22 | 23 | # END WordPress show/ignore 24 | -------------------------------------------------------------------------------- /.gitignore.wpengine: -------------------------------------------------------------------------------- 1 | *~ 2 | .DS_Store 3 | .svn 4 | .cvs 5 | *.bak 6 | *.swp 7 | Thumbs.db 8 | 9 | # wordpress specific 10 | wp-config.php 11 | wp-content/uploads/ 12 | wp-content/blogs.dir/ 13 | wp-content/upgrade/* 14 | wp-content/backup-db/* 15 | wp-content/advanced-cache.php 16 | wp-content/wp-cache-config.php 17 | wp-content/cache/* 18 | wp-content/cache/supercache/* 19 | 20 | # wpengine specific 21 | .smushit-status 22 | .gitattributes 23 | _wpeprivate 24 | wp-content/object-cache.php 25 | wp-content/mu-plugins/mu-plugin.php 26 | wp-content/mu-plugins/slt-force-strong-passwords.php 27 | wp-content/mu-plugins/limit-login-attempts 28 | wp-content/mu-plugins/wpengine-common 29 | wp-content/mysql.sql 30 | 31 | # large/disallowed file types 32 | # a CDN should be used for these 33 | *.hqx 34 | *.bin 35 | *.exe 36 | *.dll 37 | *.deb 38 | *.dmg 39 | *.iso 40 | *.img 41 | *.msi 42 | *.msp 43 | *.msm 44 | *.mid 45 | *.midi 46 | *.kar 47 | *.mp3 48 | *.ogg 49 | *.m4a 50 | *.ra 51 | *.3gpp 52 | *.3gp 53 | *.mp4 54 | *.mpeg 55 | *.mpg 56 | *.mov 57 | *.webm 58 | *.flv 59 | *.m4v 60 | *.mng 61 | *.asx 62 | *.asf 63 | *.wmv 64 | *.avi -------------------------------------------------------------------------------- /build-wpengine.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Intended to deploy a composer controlled repo to WPEngine. 3 | # 1. Clones the WPEngine repo into a "package" directory 4 | # 2. Builds a clean copy of the site in a "build" directory 5 | # 3. Transfers the elements we need (e.g. not .git dirs, etc) 6 | # from "build" to "package" 7 | # 4. Creates a commit in "package" ready to be pushed to WPE 8 | # 9 | # Usage: ./build-wpengine.sh -m "Code to support new product range" -s somesite 10 | 11 | ( 12 | # Uncomment these lines to profile the script 13 | # set -x 14 | # PS4='$(date "+%s.%N ($LINENO) + ")' 15 | 16 | # SETUP AND SANITY CHECKS 17 | # ======================= 18 | while getopts m:s:u: OPTION 2>/dev/null; do 19 | case $OPTION 20 | in 21 | m) COMMIT_MSG=${OPTARG};; 22 | s) SITENAME=${OPTARG};; 23 | u) COMPOSER_UPDATE=${OPTARG};; 24 | esac 25 | done 26 | 27 | # Variables for the various directories, some temp dirs 28 | INITIAL=`pwd` 29 | WHOAMI=`whoami` 30 | BUILD="$INITIAL/build" 31 | PACKAGE="$INITIAL/package" 32 | rm -rf $BUILD 33 | rm -rf $PACKAGE 34 | 35 | RED='\e[0;31m' 36 | GREEN='\e[0;32m' 37 | NC='\e[0m' # No Color 38 | 39 | # VALIDATIONS 40 | 41 | if [ -z "$COMMIT_MSG" ]; then 42 | echo -e "${RED}Please provide a commit message, e.g. 'sh ./build.sh -m \"Phase 2 beta\"'${NC}" 43 | exit 1 44 | fi 45 | 46 | if [ -z "$SITENAME" ]; then 47 | echo -e "${RED}Please provide a sitename within WP Engine, this will control the Git repo we clone and commit to, e.g. 'sh ./build.sh -s \"somesitename\"'${NC}" 48 | exit 2 49 | fi 50 | 51 | # Check for uncommitted changes in htdocs, and refuse to proceed if there are any 52 | echo "Checking for untracked or changed files…" 53 | if [ -n "$(git ls-files htdocs --exclude-standard --others)" ]; then 54 | echo -e "${RED}You have untracked files, please remove or commit them before building:${NC}" 55 | git ls-files . --exclude-standard --others 56 | exit 3 57 | fi 58 | if ! git -c core.fileMode=false diff --quiet --exit-code htdocs; then 59 | echo -e "${RED}You have changes to tracked files, please reset or commit them before building:${NC}" 60 | git -c core.fileMode=false diff --stat 61 | exit 4 62 | fi 63 | 64 | # Maybe run a composer update too, then commit the lock? 65 | if [[ $COMPOSER_UPDATE == "yes" ]]; then 66 | ./wrapper-composer.sh update 67 | if [ 0 != $? ]; then 68 | echo -e "${RED}Composer update to regenerate the lock file failed with code $?, something went wrong.${NC}" 69 | exit 5 70 | fi 71 | git add ./composer.lock 72 | git commit -m "Composer lock for: $COMMIT_MSG" 73 | echo "Composer updated, new composer.lock committed" 74 | fi 75 | 76 | # @FIXME: This code is pretty much duplicated in the vvv-init.sh script 77 | mkdir -p ~/.ssh 78 | touch ~/.ssh/known_hosts 79 | while read FINGERPRINT; do 80 | if ! grep -Fxq "$FINGERPRINT" ~/.ssh/known_hosts; then 81 | echo "Adding $(echo $FINGERPRINT |cut -d ' ' -f1) $(echo $FINGERPRINT |cut -d ' ' -f2) to ~$WHOAMI/.ssh/known_hosts" 82 | echo $FINGERPRINT >> ~/.ssh/known_hosts 83 | fi 84 | done < ssh/known_hosts 85 | 86 | echo "Testing authentication with $SITENAME on WPEngine…" 87 | # The quickest command I can find is `help`, but it still takes approx 2 seconds 88 | # (The command is executed on Gitolite at the WPEngine end, AFAICT) 89 | ssh -o "BatchMode yes" git@git.wpengine.com help 2>/dev/null 1>&2 90 | if [ 0 != $? ]; then 91 | echo -e "${RED}You need to add some SSH keys to this Vagrant, to allow the '$WHOAMI' user to Git push to $SITENAME on WPEngine${NC}" 92 | exit 5 93 | fi 94 | 95 | echo "Checking you have a Git user setup…" 96 | if [[ $(git config --list) != *user.email* || $(git config --list) != *user.name* ]]; then 97 | echo -e "${RED}Please set your user information in git, e.g. 'git config --global --add user.email dev@example.com; git config --global --add user.name \"Alistair Developer\";'${NC}" 98 | exit 6 99 | fi 100 | 101 | # BUILD THE PROJECT 102 | # ================= 103 | 104 | echo "Creating a clean 'build' directory: git clone $INITIAL $INITIAL/build" 105 | git clone $INITIAL "$INITIAL/build" 106 | if [[ 0 != $? ]]; then 107 | echo -e "${RED}Failed to clone the working Git repository${NC}" 108 | exit 7 109 | fi 110 | echo "Creating a clean 'package' directory: git clone git@git.wpengine.com:production/$SITENAME.git $INITIAL/package" 111 | git clone git@git.wpengine.com:production/$SITENAME.git "$INITIAL/package" 112 | if [[ 0 != $? ]]; then 113 | echo -e "${RED}Failed to clone the WPEngine Git repository${NC}" 114 | exit 8 115 | fi 116 | cd $PACKAGE 117 | git remote rename origin production 118 | git remote add staging git@git.wpengine.com:staging/$SITENAME.git 119 | 120 | echo "Beginning the build…" 121 | cd $BUILD 122 | 123 | # This project doesn't include WP core in version control or in Composer 124 | echo "Downloading the latest core WordPress files…" 125 | wp core download --path=htdocs 126 | if [ 0 != $? ]; then 127 | echo -e "${RED}We could not download the WordPress core files.${NC}" 128 | exit 9 129 | fi 130 | echo "Running Composer…" 131 | # Preferring distribution, rather than source, should speed things up for WP.org 132 | # hosted plugins, and those plugins with stable releases for the versions we need. 133 | ssh-agent bash -c "ssh-add $INITIAL/ssh/cftp_deploy_id_rsa; composer install --prefer-dist" 134 | 135 | echo "Clean all the version control directories out of the build directory…" 136 | # Remove all version control directories 137 | find $BUILD/htdocs -name ".svn" -exec rm -rf {} \; 2> /dev/null 138 | find $BUILD/htdocs -name ".git*" -exec rm -rf {} \; 2> /dev/null 139 | 140 | echo "Removing the perfidious Hello Dolly (banned on WPEngine)" 141 | rm $BUILD/htdocs/wp-content/plugins/hello.php 142 | 143 | echo "Copying files to the package directory…" 144 | rm -rf $PACKAGE/* 145 | cp -pr htdocs/* $PACKAGE/ 146 | cp -prv htdocs/.[a-zA-Z0-9]* $PACKAGE 147 | 148 | # Use a relevant .gitignore 149 | cp $INITIAL/.gitignore.wpengine $PACKAGE/.gitignore 150 | 151 | echo "Creating a Git commit for the changes…" 152 | # Add all the things! Even the deleted things! 153 | cd $PACKAGE 154 | git add -A . 155 | git commit -am "$COMMIT_MSG" 156 | 157 | # TIDY UP 158 | # ======= 159 | 160 | rm -rf $BUILD 161 | echo -e "${GREEN}The site was built using the 'composer install' command, from 'composer.lock', and turned into a Git commit.${NC}" 162 | echo -e "${GREEN}Please examine the commit in the package directory ($PACKAGE) and push it to WP Engine if it is correct.${NC}" 163 | echo -e "${GREEN}You can delete the package directory after you're done.${NC}" 164 | exit 0 # Success! 165 | ) 166 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "cftp/vvv-init", 3 | "description" : "An auto-site setup for VVV", 4 | "homepage" : "https://github.com/cftp/vvv-init", 5 | "license" : "GPL-2.0", 6 | "authors" : [ 7 | { 8 | "name" : "Code For The People", 9 | "homepage": "http://codeforthepeople.com" 10 | } 11 | ], 12 | "type" : "project", 13 | "minimum-stability" : "dev", 14 | "repositories" : [ 15 | { "type" : "composer", "url" : "http://wpackagist.org" }, 16 | { "type" : "composer", "url" : "http://packages.codeforthepeople.com/" } 17 | ], 18 | "config" : { 19 | "vendor-dir": "htdocs/wp-content/vendor" 20 | }, 21 | "require" : { 22 | "wpackagist-plugin/query-monitor" : "@stable", 23 | "wpackagist-plugin/responsible" : "@stable", 24 | "wpackagist-plugin/stream" : "@stable", 25 | "wpackagist-plugin/user-switching" : "@stable", 26 | "wpackagist-plugin/wordpress-importer" : "@stable", 27 | "wpackagist-plugin/wordpress-seo" : "@stable", 28 | "wpackagist-plugin/wp-thumb" : "@stable", 29 | "php" : ">=5.2.4" 30 | }, 31 | "require-dev" : { 32 | }, 33 | "extra" : { 34 | "installer-paths": { 35 | "htdocs/wp-content/plugins/{$name}/" : ["type:wordpress-plugin"], 36 | "htdocs/wp-content/themes/{$name}/" : ["type:wordpress-theme"] 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | You may want to [read our overview](https://github.com/cftp/vvv-init/wiki). 2 | 3 | # How to use this example bootstrap 4 | 5 | ## Basic setup 6 | 7 | 1. Run a search and replace for `site-name` to whatever the subdomain for your development site will be 8 | 2. Run a search and replace for `site_name` to whatever the database name for your development site will be 9 | 3. Run a search and replace for `Site Name` to whatever the human readable name for your development site will be 10 | 4. Remove these initial instructions, leaving the "Development environment bootstrap" heading and everything below it 11 | 5. Create a deploy user on your GitHub repo, create a set of private and public keys for this user and upload the public key to GitHub. Copy the public *and private* keys for this user into the `ssh` folder of this bootstrap. Give this user pull permissions. **NOTE: You have a potential security issue if you give this user push (or GitHub admin) permissions, as you are distributing the private key for the user!** 12 | 6. Amend the "Development environment bootstrap" heading and paragraph below so it reflects your purpose for the particular development environment 13 | 7. Test everything works as expected in a [VVV](https://github.com/10up/varying-vagrant-vagrants/) context 14 | 8. Copy or `git push` to a new repo or new branch in an existing repo 15 | 9. Point people towards the `readme.md` in the repo you pushed to, so they can get going 16 | 17 | ## Using Composer 18 | 19 | See [Composer](https://github.com/cftp/vvv-init/wiki/Introduction#composer) and [Private Repos](https://github.com/cftp/vvv-init/wiki/Introduction#private-repos) 20 | 21 | The private and public keys are not included in this publically distributed repo, you will need to copy these into the `.ssh` folder. 22 | 23 | You will need to include the Composer autoload, so add this near the top of `wp-config.php` (which is a file you may wish to have under version control, separating out the environment specific portion into a non-version controlled `wp-config-local.php`): 24 | 25 | ```php 26 | // composer 27 | if ( file_exists( __DIR__ . '/wp-content/vendor/autoload.php' ) ) { 28 | require __DIR__ . '/wp-content/vendor/autoload.php'; 29 | } 30 | ``` 31 | 32 | You've then got the `wrapper-composer.sh` and `build-wpengine.sh` scripts available to you. 33 | 34 | # Development environment bootstrap 35 | 36 | This site bootstrap is designed to be used with [Varying Vagrants Vagrant](https://github.com/10up/varying-vagrant-vagrants/) and a WordPress single site, the code for which is stored as a monolithic (or submoduled, probably) Git(Hub) repo. 37 | 38 | To get started: 39 | 40 | 1. If you don't already have it, clone the [Vagrant repo](https://github.com/10up/varying-vagrant-vagrants/) (perhaps into your `~/Vagrants/` directory, you may need to create it if it doesn't already exist) 41 | 2. Install the Vagrant hosts updater: `vagrant plugin install vagrant-hostsupdater` 42 | 3. Clone this branch of this repo into the `www` directory of your Vagrant as `www/site-name` 43 | 4. If your Vagrant is running, from the Vagrant directory run `vagrant halt` 44 | 5. Followed by `vagrant up --provision`. Perhaps a cup of tea now? The initial provisioning may take a while. 45 | 6. If you want the user uploaded files, you'll need to download these separately 46 | 47 | Then you can visit: 48 | * [http://site-name.dev/](http://site-name.dev/) 49 | 50 | This script is free software, and is released under the terms of the GPL version 2 or (at your option) any later version. See license.txt. 51 | -------------------------------------------------------------------------------- /ssh/known_hosts: -------------------------------------------------------------------------------- 1 | bitbucket.org ssh-dss AAAAB3NzaC1kc3MAAACBAO53E7Kcxeak0luot3Z5ulOQJoLRBcnBQb0gpUfNL5rZW63fBubfXLbpZc2/GnHxRiFa2okTPvBULJZnjwXltyoRfjPICRLfH/ep3mZj6CVUyQgxES27CS1bEjMw8+S6hLlJF4dKqOIWH5+Ed+lo8ezzXbzcEj7R5h9xGgfY55HfAAAAFQDE/aqj+0sxv/ZRS3ArGxMHGYFebwAAAIEA6lZ68WgDMrR28iXIicJ7AnXPnZKzQK7xK68feKlYo9LcEkKTF3AZIE5nEvtn+ZYwZ5cKE3XKeU42aesAEAUxX9cUEzhi87q6PQagD6ZPcU89CCVlWsG8cKYCZ6VtMfcLU06grNfvl450KCHltWTaoBHdi9f8eFo3Gydg6JhyNJ8AAACAThcLJmru5QtpHo9wctg5jHKxv1BLPndKs3dVwAQwcd2sugoymGeH7IjBSFLqHsyl7XpDik4mH/YdkVwb1jAwA+JOu2gHpsSXLY22At+LKn6NHdL/qqbIf7ellnKXfEo+wz6DfGihaczY931WrjkEEsq1453/4BwQpAXrz2zbRSI= 2 | bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMn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GQk4d3zw9WAEURicE8rKJop3qGtdfFxLzrTuF/PAkKRDMmutT3hwZIOO8CFWOl1BiuUYTncJTeonrfAAAAFQCujauoy3Yy+ul72b/WsTECUPj9yQAAAIBIV2yyF7RZf7IYS8tsWcKP7Y5Bv9eFdbvbtsaxcFCHcmHIGoJQrIdPoueoOb5EUTYz0NgYKsKaZzDZkgFk28GsmLxKvhnPjaw0lJVSKRchEE5xVlamOlabiRMjQ7X/bAdejkBJe96AjZZL3UO4acpwfy3Tnnap0w6YCDeaxoyHpwAAAIAU+dyNaL3Hy15VIV32QwWMekvxeptUY/DW03LNcgZZDoin87TE9xuQhM0qF3pi2i2a2ExuslgdttmYWvrbEz8eW+RFgvT5pKwWpalKWetHvtN3oYZP37ZIO1Y3Hd5A4YVcpYp1ccRayveLlCRwxb4HdGXT2OmYU+lmvimIR8zQ6A== 8 | gitlab.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsj2bNKTBSpIYDEGk9KxsGh3mySTRgMtXL583qmBpzeQ+jqCMRgBqB98u3z++J1sKlXHWfM9dyhSevkMwSbhoR8XIq/U0tCNyokEi/ueaBMCvbcTHhO7FcwzY92WK4Yt0aGROY5qX2UKSeOvuP4D6TPqKF1onrSzH9bx9XUf2lEdWT/ia1NEKjunUqu1xOB/StKDHMoX4/OKyIzuS0q/T1zOATthvasJFoPrAjkohTyaDUz2LN5JoH839hViyEG82yB+MjcFV5MU3N1l1QL3cVUCh93xSaua1N85qivl+siMkPGbO5xR/En4iEY6K2XPASUEMaieWVNTRCtJ4S8H+9 9 | -------------------------------------------------------------------------------- /ssh/ssh_hosts: -------------------------------------------------------------------------------- 1 | bitbucket.org 2 | git.wpengine.com 3 | github.com 4 | gitlab.com 5 | -------------------------------------------------------------------------------- /vvv-hosts: -------------------------------------------------------------------------------- 1 | # Add as many hostnames as you need here 2 | site-name.dev 3 | -------------------------------------------------------------------------------- /vvv-init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Init script for a development site with a monolithic Git repo 3 | # v1.0 4 | 5 | # Edit these variables to suit your porpoises 6 | # ------------------------------------------- 7 | 8 | # Just a human readable description of this site 9 | SITE_NAME="Site Name" 10 | # The name (to be) used by MySQL for the DB 11 | DB_NAME="site_name" 12 | # The repo URL in SSH format, e.g. git@github.com:cftp/foo.git 13 | REPO_SSH_URL="git@github.com:cftp/site_name.git" 14 | # The multisite stuff for wp-config.php 15 | EXTRA_CONFIG=" 16 | // No extra config, but if there was multisite stuff, etc, 17 | // it would go here. 18 | " 19 | 20 | # ---------------------------------------------------------------- 21 | # You should not need to edit below this point. Famous last words. 22 | 23 | echo "---------------------------" 24 | echo "Commencing $SITE_NAME setup" 25 | 26 | # Add GitHub and GitLab to known_hosts, so we don't get prompted 27 | # to verify the server fingerprint. 28 | # The fingerprints in [this repo]/ssh/known_hosts are generated as follows: 29 | # 30 | # As the starting point for the ssh-keyscan tool, create an ASCII file 31 | # containing all the hosts from which you will create the known hosts 32 | # file, e.g. sshhosts. 33 | # Each line of this file states the name of a host (alias name or TCP/IP 34 | # address) and must be terminated with a carriage return line feed 35 | # (Shift + Enter), e.g. 36 | # 37 | # bitbucket.org 38 | # github.com 39 | # gitlab.com 40 | # 41 | # Execute ssh-keyscan with the following parameters to generate the file: 42 | # 43 | # ssh-keyscan -t rsa,dsa -f ssh_hosts >ssh/known_hosts 44 | # The parameter -t rsa,dsa defines the host’s key type as either rsa 45 | # or dsa. 46 | # The parameter -f /home/user/ssh_hosts states the path of the source 47 | # file ssh_hosts, from which the host names are read. 48 | # The parameter >ssh/known_hosts states the output path of the 49 | # known_host file to be created. 50 | # 51 | # From "Create Known Hosts Files" at: 52 | # http://tmx0009603586.com/help/en/entpradmin/Howto_KHCreate.html 53 | mkdir -p ~/.ssh 54 | touch ~/.ssh/known_hosts 55 | IFS=$'\n' 56 | for KNOWN_HOST in $(cat "ssh/known_hosts"); do 57 | if ! grep -Fxq "$KNOWN_HOST" ~/.ssh/known_hosts; then 58 | echo "Adding host to SSH known_hosts for user 'root': $(echo $KNOWN_HOST |cut -d '|' -f1)" 59 | echo $KNOWN_HOST >> ~/.ssh/known_hosts 60 | fi 61 | done 62 | 63 | # Clone the repo, if it's not there already 64 | if [ ! -d htdocs ] 65 | then 66 | ssh-agent bash -c "ssh-add ssh/cftp_deploy_id_rsa; git clone $REPO_SSH_URL htdocs;" 67 | echo "Cloning the repo" 68 | else 69 | echo "The htdocs directory already exists, and should contain the repo. If not, delete it and run Vagrant provisioning again." 70 | fi 71 | 72 | # Make a database, if we don't already have one 73 | mysql -u root --password=root -e "CREATE DATABASE IF NOT EXISTS $DB_NAME; GRANT ALL PRIVILEGES ON $DB_NAME.* TO wp@localhost IDENTIFIED BY 'wp';" 74 | 75 | # Let's get some config in the house 76 | if [ ! -f htdocs/wp-config.php ]; then 77 | wp core download --path=htdocs 78 | wp core config --dbname="$DB_NAME" --dbuser=wp --dbpass=wp --dbhost="localhost" --extra-php <&2 34 | shift 35 | ;; 36 | *) # no more options. Stop while loop 37 | break 38 | ;; 39 | esac 40 | done 41 | 42 | if [ ! $COMPOSER_COMMAND ]; then 43 | echo "Could not find a recognised composer command, only 'update' and 'install' currently work with this script." 44 | exit 4 45 | fi 46 | 47 | ssh-agent bash -c "ssh-add ssh/cftp_deploy_id_rsa; composer $COMPOSER_COMMAND $COMPOSER_NO_DEV;" 48 | COMPOSER_EXIT=$? 49 | 50 | exit $COMPOSER_EXIT 51 | --------------------------------------------------------------------------------