├── .gitignore ├── LICENSE.txt ├── README.md ├── audit ├── README.md ├── code_audit.sh ├── common ├── functions.sh ├── module_audit.sh └── system_audit.sh ├── misc ├── README.md └── core-update.sh ├── provisioning ├── .my.conf ├── .mydevdesktop.conf ├── README.md ├── common ├── delete.sh ├── functions.sh └── install.sh └── scaffolding ├── README.md ├── common ├── functions.sh └── module.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # PhpStorm 2 | .idea 3 | 4 | # HEAD 5 | provisioning/HEAD 6 | misc/HEAD 7 | 8 | # Make files 9 | provisioning/*.make 10 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Drupal 8 Tools 2 | ============== 3 | 4 | This is a placeholder for simple D8 goodies that will hopefully help you speed up recurring tasks. 5 | 6 | Notes 7 | ----- 8 | 9 | - Those Shell scripts have been tested against **Ubuntu 12.04 LTS** (Precise Pangolin) and **14.04 LTS** (Trusty Tahr). If you're running a non LTS release, use at your own risk. 10 | - Make sure all scripts are executable (**chmod +x script.sh**) 11 | - It's safer to run those scripts from within a container or a VM (e.g. Docker or Vagrant) 12 | 13 | Recommended usage 14 | ----------------- 15 | 16 | Add the following bash aliases in your **.bash_aliases** file: 17 | 18 |
19 | alias saudit='sudo /path/to/drupal-8-tools/audit/system_audit.sh'
20 | alias maudit='sudo /path/to/drupal-8-tools/audit/module_audit.sh'
21 | alias install='sudo /path/to/drupal-8-tools/provisioning/install.sh'
22 | alias delete='sudo /path/to/drupal-8-tools/provisioning/delete.sh'
23 | alias update='sudo /path/to/drupal-8-tools/misc/core-update.sh'
24 | alias module='sudo /path/to/drupal-8-tools/scaffolding/module.sh'
25 | 
26 | 27 | Apply changes without rebooting: 28 | 29 | $ . ~/.bash_aliases 30 | 31 | To provision a Drupal 8 site, invoke the _install.sh_ or _delete.sh_ script directly and give it a sitename: 32 | 33 | $ install/delete {sitename} 34 | 35 | If you want a module scaffolding, invoke the _module.sh_ script: 36 | 37 | $ module 38 | 39 | Want to quickly try and update Drupal (there be dragons!)? Run: 40 | 41 | $ update 42 | 43 | To audit your system against Drupal 8 requirements, run: 44 | 45 | $ saudit 46 | 47 | If you wish to upgrade a Drupal 7 module to Drupal 8, there's also a script for that! Run the below command and enter the full Unix path to any D7 module to audit: 48 | 49 | $ maudit 50 | 51 | You might also want to run a quick system audit to make sure your LAMP stack is compatible with Drupal 8's minimum requirements. Simply run: 52 | 53 | $ audit 54 | -------------------------------------------------------------------------------- /audit/README.md: -------------------------------------------------------------------------------- 1 | audit/system_audit.sh 2 | ----------------------- 3 | 4 | _[WORK IN PROGRESS]_ 5 | 6 | Performs several server checks: 7 | 8 | - Minimum PHP version 9 | - php.ini requirements 10 | 11 | audit/module_audit.sh 12 | ---------------------- 13 | 14 | _[WORK IN PROGRESS]_ 15 | 16 | This script audits a Drupal 7 module directory for any deprecated function. On top of that, it provides for a carefully crafted mapping that will suggest a new function or methodology (when applicable) to embrace a Drupal 8-friendly API usage. 17 | 18 | audit/common 19 | ------------------- 20 | 21 | Common variables. 22 | -------------------------------------------------------------------------------- /audit/code_audit.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Invoke the script from anywhere (e.g .bashrc alias) 4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | 6 | # Required source files 7 | source "${DIR}"/common 8 | source "${DIR}"/functions.sh 9 | 10 | is_root 11 | 12 | # Set path to scan 13 | MODULE_PATH=$1 14 | if [[ -z $1 ]]; then 15 | echo -n "Enter the Unix path for the module to scan: " 16 | read VALID_PATH 17 | fi 18 | 19 | if [[ ! -d ${VALID_PATH} ]]; then 20 | echo -e "${RED}This is not a valid Unix path! Aborting...${COLOR_ENDING}" 21 | exit 0 22 | fi 23 | 24 | MODULE=`basename $(pwd)` 25 | BLOCK_FILES="$(pwd)/src/Plugin/Block/*" 26 | BLOCKBASE="BlockBase" 27 | FORMSTATEINTERFACE="FormStateInterface" 28 | BLOCK_ANNOTATION="@Block" 29 | BLOCK_ID="id = " 30 | BLOCK_LABEL="admin_label = " 31 | BLOCK_CATEGORY="category = " 32 | BLOCKFORM="blockForm" 33 | BLOCKSUBMIT="blockSubmit" 34 | BUILD="build" 35 | 36 | # File structure 37 | echo -e "${BLUE}Auditing block file structure...${COLOR_ENDING}" 38 | # namespace 39 | if [[ -z $(grep -w --color=auto "namespace Drupal\\\\${MODULE}\\\Plugin\\\Block;" "${BLOCK_FILES}") ]]; then 40 | echo -e "${RED}The namespace is missing or incorrectly set!${COLOR_ENDING}" 41 | echo "The correct namespace to use is: Drupal\\${MODULE}\Plugin\Block;" 42 | else 43 | echo "The namespace is correct." 44 | fi 45 | 46 | # BlockBase use statement 47 | if [[ -z $(grep -w --color=auto "use Drupal\\\Core\\\Block\\\\${BLOCKBASE};" "${BLOCK_FILES}") ]]; then 48 | echo -e "${RED}The use statement for ${BLOCKBASE} is missing or incorrectly set!${COLOR_ENDING}" 49 | echo "The correct use statement to invoke is: Drupal\\Core\\Block\\${BLOCKBASE};" 50 | else 51 | echo "The use statement for ${BLOCKBASE} is correct." 52 | fi 53 | 54 | # FormStateInterface use statement 55 | if [[ -z $(grep -w --color=auto "use Drupal\\\Core\\\Form\\\\${FORMSTATEINTERFACE};" "${BLOCK_FILES}") ]]; then 56 | echo -e "${RED}The use statement for ${FORMSTATEINTERFACE} is missing or incorrectly set!${COLOR_ENDING}" 57 | echo "The correct use statement to invoke is: Drupal\\Core\\Block\\${FORMSTATEINTERFACE};" 58 | else 59 | echo "The use statement for ${FORMSTATEINTERFACE} is correct." 60 | fi 61 | 62 | # @Block annotation 63 | if [[ -z $(grep -w --color=auto "${BLOCK_ANNOTATION}(" "${BLOCK_FILES}") ]]; then 64 | echo -e "${RED}The ${BLOCK_ANNOTATION} annotation is missing or not correctly set!${COLOR_ENDING}" 65 | echo "The correct annotation to use is: ${BLOCK_ANNOTATION}" 66 | else 67 | echo "The ${BLOCK_ANNOTATION} annotation exists." 68 | fi 69 | 70 | # @Block id annotation 71 | if [[ -z $(grep -w --color=auto "${BLOCK_ID}" "${BLOCK_FILES}") ]]; then 72 | echo -e "${RED}The ${BLOCK_ANNOTATION} id annotation is missing or not correctly set!${COLOR_ENDING}" 73 | echo "The correct id annotation to use is: ${BLOCK_ID}" 74 | else 75 | echo "The ${BLOCK_ANNOTATION} id annotation exists." 76 | fi 77 | 78 | # @Block admin_label annotation 79 | if [[ -z $(grep -w --color=auto "${BLOCK_LABEL}" "${BLOCK_FILES}") ]]; then 80 | echo -e "${RED}The ${BLOCK_ANNOTATION} label annotation is missing or not correctly set!${COLOR_ENDING}" 81 | echo "The correct label annotation to use is: ${BLOCK_LABEL}" 82 | else 83 | echo "The ${BLOCK_ANNOTATION} label annotation exists." 84 | fi 85 | 86 | # @Block category annotation 87 | if [[ -z $(grep -w --color=auto "${BLOCK_CATEGORY}" "${BLOCK_FILES}") ]]; then 88 | echo -e "${RED}The ${BLOCK_ANNOTATION} category annotation is missing or not correctly set!${COLOR_ENDING}" 89 | echo "The correct category annotation to use is: ${BLOCK_CATEGORY}" 90 | else 91 | echo "The ${BLOCK_ANNOTATION} category annotation exists." 92 | fi 93 | 94 | # Block methods 95 | echo -e "${BLUE}Auditing block methods...${COLOR_ENDING}" 96 | # blockForm() 97 | if [[ -z $(grep -w --color=auto "public function \"${BLOCKFORM}\"(\$form, ${FORMSTATEINTERFACE} \$form_state)" "${BLOCK_FILES}") ]]; then 98 | echo -e "${RED}The ${BLOCKFORM}() function is missing or not correctly instantiated!${COLOR_ENDING}" 99 | echo -e "\tThe correct implementation is: ${GREEN}public function ${BLOCKFORM}(\$form, FormStateInterface \$form_state)${COLOR_ENDING}" 100 | else 101 | echo "The ${BLOCKFORM}() function seems to be correctly implemented." 102 | fi 103 | 104 | # blockSubmit() 105 | if [[ -z $(grep -w --color=auto "public function ${BLOCKSUBMIT}(\$form, ${FORMSTATEINTERFACE} \$form_state)" "${BLOCK_FILES}") ]]; then 106 | echo -e "${RED}The ${BLOCKSUBMIT}() function is missing or not correctly instantiated!${COLOR_ENDING}" 107 | echo -e "\tThe correct implementation is: ${GREEN}public function ${BLOCKSUBMIT}(\$form, ${FORMSTATEINTERFACE} \$form_state)${COLOR_ENDING}" 108 | else 109 | echo "The ${BLOCKSUBMIT}() function seems to be correctly implemented." 110 | fi 111 | 112 | # build() 113 | if [[ -z $(grep -w --color=auto "public function ${BUILD}()" "${BLOCK_FILES}") ]]; then 114 | echo -e "${RED}The ${BUILD}() function is missing or not correctly instantiated!${COLOR_ENDING}" 115 | echo -e "\tThe correct implementation is: ${GREEN}public function ${BUILD}()${COLOR_ENDING}" 116 | else 117 | echo "The ${BUILD}() function seems to be correctly implemented." 118 | fi 119 | -------------------------------------------------------------------------------- /audit/common: -------------------------------------------------------------------------------- 1 | GREEN="\033[0;32m" 2 | RED="\033[0;31m" 3 | BLUE="\033[94m" 4 | COLOR_ENDING="\033[0m" 5 | -------------------------------------------------------------------------------- /audit/functions.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Shared functions 4 | is_root() { 5 | # Make sure only root can execute the script 6 | if [[ ! $(id -u) = 0 ]]; then 7 | echo -e "${RED}You are required to run this script as root or with sudo! Aborting...${COLOR_ENDING}" 8 | exit 1 9 | fi 10 | } 11 | -------------------------------------------------------------------------------- /audit/module_audit.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Invoke the script from anywhere (e.g .bashrc alias) 4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | 6 | # Required source files 7 | source "${DIR}"/common 8 | source "${DIR}"/functions.sh 9 | 10 | is_root 11 | 12 | # Set path to scan 13 | MODULE_PATH=$1 14 | if [[ -z $1 ]]; then 15 | echo -n "Enter the Unix path for the module to scan: " 16 | read VALID_PATH 17 | fi 18 | 19 | if [[ ! -d ${VALID_PATH} ]]; then 20 | echo -e "${RED}This is not a valid Unix path! Aborting...${COLOR_ENDING}" 21 | exit 0 22 | fi 23 | 24 | ############# 25 | # FUNCTIONS # 26 | ############# 27 | echo -e "${BLUE}Auditing functions...${COLOR_ENDING}" 28 | 29 | declare -A FUNCTIONS 30 | FUNCTIONS=( 31 | [_field_sort_items_value_helper]="_field_multiple_value_form_sort_helper()" 32 | [_external_url_is_local]="TODO" 33 | [_module_build_dependencies]="\Drupal::moduleHandler()->buildModuleDependencies(\$modules)" 34 | [_update_fetch_data]="UpdateProcessor::fetchData() / \Drupal::service('update.processor')->fetchData();" 35 | [_update_refresh]="UpdateManager::refreshUpdateData() / \Drupal::service('update.manager')->refreshUpdateData();" 36 | [ajax_deliver]="TODO" 37 | [block_list]="entity_load_multiple_by_properties() - See https://www.drupal.org/node/2291171" 38 | [block_get_blocks_by_region]="entity_load_multiple_by_properties() - See https://www.drupal.org/node/2291171" 39 | [cache_get]="\$this->cache()->get(\$key)" 40 | [check_plain]="\Drupal\Component\Utility\String::checkPlain()" 41 | [check_url]="TODO" 42 | [comment_count_unpublished]="CommentStorage::getUnapprovedCount()" 43 | [comment_get_display_page]="CommentStorage::getDisplayOrdinal()" 44 | [comment_get_display_ordinal]="CommentStorage::getDisplayOrdinal()" 45 | [comment_get_recent]="Removed. To render a list of recent comments, check the 'comments_recent' view." 46 | [comment_get_thread]="CommentStorage::loadThread()" 47 | [comment_load]="See https://www.drupal.org/node/2321599" 48 | [comment_new_page_count]="CommentStorage::getNewCommentPageNumber()" 49 | [comment_num_new]="CommentManager::getCountNewComments(\$entity, \$field_name, \$timestamp)" 50 | [comment_prepare_thread]="\Drupal\comment\CommentViewBuilder::buildComponents()" 51 | [conf_path]="\Drupal\Core\DrupalKernel::getSitePath()" 52 | [current_path]="Replaced by the route - See https://www.drupal.org/node/2382211" 53 | [decode_entities]="String::decodeEntities()" 54 | [drupal_add_css]="drupal_process_attached()" 55 | [drupal_add_http_header]="\$response->headers->set(\$name, \$value)" 56 | [drupal_add_js]="drupal_process_attached()" 57 | [drupal_add_library]="drupal_process_attached()" 58 | [drupal_alter]="\$module_handler->alter(\$type, &\$data, &\$context1 = NULL, &\$context2 = NULL)" 59 | [drupal_basename]="FileSystem::basename()" 60 | [drupal_bootstrap]="See https://www.drupal.org/node/2275139" 61 | [drupal_build_form]="\Drupal::formBuilder()->buildForm()" 62 | [drupal_chmod]="FileSystem::chmod()" 63 | [drupal_clean_css_identifier]="use Drupal\Component\Utility\Html; / Html::cleanCssIdentifier($foo);" 64 | [drupal_cron_run]="\Drupal::service('cron')->run();" 65 | [drupal_convert_to_utf8]="Unicode::convertToUtf8()" 66 | [drupal_deliver_html_page]="TODO" 67 | [drupal_deliver_page]="TODO" 68 | [drupal_dirname]="FileSystem::dirname()" 69 | [drupal_encode_path]="UrlHelper::encodePath('drupal')" 70 | [drupal_exit]="throw new ServiceUnavailableHttpException(3, t('Custom message goes here.'));" 71 | [drupal_form_submit]="\Drupal::formBuilder()->submitForm()" 72 | [drupal_get_bootstrap_phase]="See https://www.drupal.org/node/2275139" 73 | [drupal_get_complete_schema]="In .install: \$schema = drupal_get_schema_unprocessed(\$module, \$table); / There's no API for getting the schema of an entity table." 74 | [drupal_get_destination]="Url::fromRoute('route_name', [], ['query' => \Drupal::service('redirect.destination')->getAsArray()]); / Or / Url::fromRoute('route_name', [], ['query' => \Drupal::destination()->getAsArray()]);" 75 | [drupal_get_form]="\Drupal::formBuilder()->getForm()" 76 | [drupal_get_library]="\Drupal::service('library.discovery')->getLibrariesByExtension('module_name') / \Drupal::service('library.discovery')->getLibraryByName('module_name', 'library_name')" 77 | [drupal_get_query_array]="use \Drupal\Component\Utility\UrlHelper; / parse_str('foo=bar&bar=baz', \$query_array)" 78 | [drupal_get_query_parameters]="UrlHelper::filterQueryParameters('foo=bar&bar=baz')" 79 | [drupal_get_title]="Titles (static or dynamic) are now defined on routes - See https://www.drupal.org/node/2067859" 80 | [drupal_get_schema]="In .install: \$schema = drupal_get_schema_unprocessed(\$module, \$table); / There's no API for getting the schema of an entity table." 81 | [drupal_goto]="\$this->redirect(\$route_name)" 82 | [drupal_html_class]="use Drupal\Component\Utility\Html; / Html::getClass($foo);" 83 | [drupal_html_id]="use Drupal\Component\Utility\Html; / Html::getId($foo);" 84 | [drupal_html_to_text]="MailManagerInterface::mail() method - \Drupal::service('plugin.manager.mail')->mail($module, $key, $to, $langcode);" 85 | [drupal_http_build_query]="use Drupal\Component\Utility\UrlHelper; / UrlHelper::buildQuery" 86 | [drupal_http_request]="Use the Guzzle HTTP client library" 87 | [drupal_is_cli]="if (PHP_SAPI === 'cli') { // Do stuff }" 88 | [drupal_is_front_page]="\$is_front = \Drupal::service('path.matcher')->isFrontPage();" 89 | [drupal_json_decode]="use Drupal\Component\Serialization\Json; / \$data = Json::decode(\$json);" 90 | [drupal_json_encode]="use Drupal\Component\Serialization\Json; / \$json = Json::encode(\$data);" 91 | [drupal_mail]="MailManagerInterface::mail() method - \Drupal::service('plugin.manager.mail')->mail($module, $key, $to, $langcode);" 92 | [drupal_match_path]="\Drupal\Core\Path\PathMatcherInterface::matchPath()" 93 | [drupal_mkdir]="FileSystem::mkdir()" 94 | [drupal_move_uploaded_file]="FileSystem::moveUploadedFile()" 95 | [drupal_page_header]="TODO" 96 | [drupal_parse_url]="TODO" 97 | [drupal_prepare_form]="\Drupal::formBuilder()->prepareForm()" 98 | [drupal_process_form]="\Drupal::formBuilder()->processForm()" 99 | [drupal_realpath]="FileSystem::realpath()" 100 | [drupal_rebuild_form]="\Drupal::formBuilder()->rebuildForm()" 101 | [drupal_redirect_form]="\Drupal::formBuilder()->redirectForm()" 102 | [drupal_render_page]="There is no direct equivalent in Drupal 8. See https://www.drupal.org/node/2337551" 103 | [drupal_retrieve_form]="\Drupal::formBuilder()->retrieveForm()" 104 | [drupal_rmdir]="FileSystem::rmdir()" 105 | [drupal_schema_fields_sql]="Developers should use \Drupal::database()->merge() , the Entity API or one of the provided services, like key value" 106 | [drupal_send_headers]="TODO" 107 | [drupal_session_destroy_uid]="SessionManager: \$session_manager = \Drupal::service('session_manager') / \$session_manager->delete(\$uid)" 108 | [drupal_session_regenerate]="SessionManager: \$session_manager = \Drupal::service('session_manager') / \$session_manager->regenerate()" 109 | [drupal_session_start]="SessionManager: \$session_manager = \Drupal::service('session_manager') / \$session_manager->start()" 110 | [drupal_session_started]="SessionManager: \$session_manager = \Drupal::service('session_manager') / \$session_manager->isStarted()" 111 | [drupal_set_title]="Titles (static or dynamic) are now defined on routes - See https://www.drupal.org/node/2067859" 112 | [drupal_strlen]="Unicode::strlen()" 113 | [drupaland Apple products_strtoupper]="Unicode::strtoupper()" 114 | [drupal_substr]="Unicode::substr()" 115 | [drupal_tempnam]="FileSystem::tempnam()" 116 | [drupal_theme_access]="TODO" 117 | [drupal_truncate_bytes]="Unicode::truncateBytes()" 118 | [drupal_ucfirst]="Unicode::ucfirst()" 119 | [drupal_unlink]="FileSystem::unlink()" 120 | [drupal_validate_form]="\Drupal::formBuilder()->validateForm()" 121 | [drupal_validate_utf8]="Unicode::validateUtf8()" 122 | [drupal_wrap_mail]="MailManagerInterface::mail() method - \Drupal::service('plugin.manager.mail')->mail($module, $key, $to, $langcode);" 123 | [drupal_write_record]="Developers should use \Drupal::database()->merge(), the Entity API or one of the provided services, like key value" 124 | [element_child]="Element::child('foo')" 125 | [element_children]="Element::children(\$elements)" 126 | [element_get_visible_children]="Element::getVisibleChildren(\$elements)" 127 | [element_info]="\Drupal::ElementInfo()->getInfo()" 128 | [element_info_property]="\Drupal::ElementInfo()->getInfoProperty()" 129 | [element_property]="Element::property('#markup')" 130 | [element_properties]="Element::properties(\$elements['foo'])" 131 | [element_set_attributes]="Element::setAttributes(\$elements['foo'], array('#title' => 'Custom title'))" 132 | [entity_load]="\Drupal::entityManager()->getStorage(\$entity)->load(\$id);" 133 | [field_attach_extract_form_values]="Use the Entity API instead: https://drupal.org/developing/api/entity" 134 | [field_attach_form]="Use the Entity API instead: https://drupal.org/developing/api/entity" 135 | [field_attach_form_validate]="Use the Entity API instead: https://drupal.org/developing/api/entity" 136 | [field_form_get_state]="WidgetBaseInterface::getWidgetState()" 137 | [field_form_set_state]="WidgetBaseInterface::setWidgetState()" 138 | [field_info_field]="See https://www.drupal.org/node/2167167 and https://www.drupal.org/node/2260037" 139 | [field_info_field_by_id]="See https://www.drupal.org/node/2167167 and https://www.drupal.org/node/2260037" 140 | [field_info_field_by_ids]="See https://www.drupal.org/node/2167167 and https://www.drupal.org/node/2260037" 141 | [field_info_field_map]="See https://www.drupal.org/node/2167167 and https://www.drupal.org/node/2260037" 142 | [field_info_instance]="See https://www.drupal.org/node/2167167 and https://www.drupal.org/node/2260037" 143 | [field_info_instances]="See https://www.drupal.org/node/2167167 and https://www.drupal.org/node/2260037" 144 | [field_views_field_label]="TBD: https://www.drupal.org/node/2231863" 145 | [file_htaccess_lines]="FileStorage::htaccessLines(FALSE);" 146 | [file_stream_wrapper_valid_scheme]="FileSystem::validScheme()" 147 | [file_uri_scheme]="FileSystem::uriScheme()" 148 | [filter_xss]="Xss::filter()" 149 | [filter_xss_admin]="Xss::filterAdmin()" 150 | [filter_xss_bad_protocol]="UrlHelper::filterBadProtocol('javascript://example.com?foo&bar')" 151 | [form_clear_error]="\Drupal::formBuilder()->clearErrors()" 152 | [form_error]="\Drupal::formBuilder()->setError()" 153 | [form_execute_handlers]="\Drupal::formBuilder()->executeHandlers()" 154 | [form_get_cache]="\Drupal::formBuilder()->getCache()" 155 | [form_get_error]="\Drupal::formBuilder()->getError()" 156 | [form_get_errors]="\Drupal::formBuilder()->getErrors()" 157 | [form_load_include]="$form_state->loadInclude()" 158 | [form_options_flatten]="\$flattened_options = OptGroup::flattenOptions(\$options)" 159 | [form_set_cache]="\Drupal::formBuilder()->setCache()" 160 | [form_set_error]="\Drupal::formBuilder()->setErrorByName()" 161 | [form_set_value]="\Drupal::formBuilder()->setValue(\$element, \$value, \$form_state);" 162 | [form_state_defaults]="\Drupal::formBuilder()->getFormStateDefaults()" 163 | [form_state_values_clean]="$form_state->cleanValues()" 164 | [format_plural]="\Drupal::translation()->formatPlural() or \Drupal::service('date.formatter')->formatInterval() - See https://www.drupal.org/node/2173787" 165 | [get_t]="TODO" 166 | [hook_boot]="Create a mymodule.services.yml file and register an Event Subscriber. All details at https://www.drupal.org/node/1909596" 167 | [hook_comment_publish]="See https://www.drupal.org/node/2296867" 168 | [hook_comment_unpublish]="See https://www.drupal.org/node/2296867" 169 | [hook_date_formats]="system.date_format.{string}.yml" 170 | [hook_date_formats_alter]="system.date_format.{string}.yml" 171 | [hook_date_format_types]="system.date_format.{string}.yml" 172 | [hook_disable]="TODO" 173 | [hook_drupal_goto_alter]="Event Listener on kernel.response" 174 | [hook_enable]="TODO" 175 | [hook_field_attach_form]="Use the Entity API instead: https://drupal.org/developing/api/entity" 176 | [hook_field_attach_form_values]="Use the Entity API instead: https://drupal.org/developing/api/entity" 177 | [hook_file_download_access]="FileAccessController" 178 | [hook_init]="Register EventSubscriber in {module}.services.yml / use Symfony\Component\EventDispatcher\EventSubscriberInterface; / getSubscribedEvents()" 179 | [hook_library_alter]="hook_library_info_alter()" 180 | [hook_library_info]="{module}.libraries.yml" 181 | [hook_menu]="{module}.local_actions.yml / {module}.local_tasks.yml / {module}.menu_links.yml" 182 | [hook_menu_link_alter]="hook_menu_link_content_presave(\$entity)" 183 | [hook_menu_link_insert]="hook_menu_link_content_insert(\$entity)" 184 | [hook_menu_link_update]="hook_menu_link_content_update(\$entity)" 185 | [hook_menu_link_delete]="hook_menu_link_content_delete(\$entity)" 186 | [hook_menu_site_status_alter]="Register an EventSubscriber" 187 | [hook_modules_enabled]="TODO" 188 | [hook_modules_disabled]="TODO" 189 | [hook_node_validate]="See https://www.drupal.org/node/2420295" 190 | [hook_node_submit]="See https://www.drupal.org/node/2420295" 191 | [hook_page_alter]="TODO - See https://www.drupal.org/node/2357755" 192 | [hook_page_build]="TODO - See https://www.drupal.org/node/2357755" 193 | [hook_page_delivery_callback_alter]="TODO" 194 | [hook_url_outbound_alter]="Class implementing OutboundPathProcessorInterface and {module}.services.yml" 195 | [image_style_path]="buildUri()" 196 | [image_style_url]="buildUrl()" 197 | [image_style_flush]="flush()" 198 | [image_style_create_derivative]="createDerivative()" 199 | [image_style_transform_dimensions]="transformDimensions()" 200 | [image_style_path_token]="getPathToken()" 201 | [image_style_deliver]="deliver()" 202 | [l]="use Drupal\Core\Url; / \$internal_link = \$this->l(t('Book admin'), Url::fromRoute('book.admin')); / \$external_link = \$this->l(t('External link'), Url::fromUri('http://www.example.com/'));" 203 | [language]="LanguageManagerInterface::getCurrentLanguage" 204 | [language_default]="LanguageManagerInterface::getDefaultLanguage" 205 | [language_list]="LanguageManagerInterface::getLanguages" 206 | [language_load]="LanguageManagerInterface::getLanguage" 207 | [language_default_locked_languages]="LanguageManagerInterface::getDefaultLockedLanguages" 208 | [language_types_get_default]="LanguageManagerInterface::getLanguageTypes" 209 | [language_name]="LanguageManagerInterface::getLanguageName" 210 | [language_is_locked]="LanguageManagerInterface::isLanguageLocked" 211 | [language_negotiation_get_switch_links]="LanguageManagerInterface::getLanguageSwitchLinks" 212 | [language_types_info]="ConfigurableLanguageManagerInterface::getDefinedLanguageTypesInfo" 213 | [language_types_get_configurable]="ConfigurableLanguageManagerInterface::getLanguageTypes" 214 | [language_types_disable]="Removed, no actual use case for this." 215 | [language_update_locked_weights]="ConfigurableLanguageManagerInterface::updateLockedLanguageWeights" 216 | [language_types_get_all]="ConfigurableLanguageManagerInterface::getDefinedLanguageTypes" 217 | [language_types_set]="LanguageNegotiatorInterface::updateConfiguration" 218 | [language_types_initialize]="LanguageNegotiatorInterface::initializeType" 219 | [language_negotiation_method_get_first]="LanguageNegotiatorInterface::getPrimaryNegotiationMethod" 220 | [language_negotiation_method_enabled]="LanguageNegotiatorInterface::isNegotiationMethodEnabled" 221 | [language_negotiation_purge]="LanguageNegotiatorInterface::purgeConfiguration" 222 | [language_negotiation_set]="LanguageNegotiatorInterface::saveConfiguration" 223 | [language_negotiation_info]="LanguageNegotiatorInterface::getNegotiationMethods" 224 | [language_negotiation_method_invoke]="LanguageNegotiator::negotiateLanguage (protected)" 225 | [language_url_split_prefix]="LanguageNegotiationFoo::processInbound" 226 | [language_from_selected]="LanguageNegotiationSelected::getLangcode" 227 | [language_from_browser]="LanguageNegotiationBrowser::getLangcode" 228 | [language_from_user]="LanguageNegotiationUser::getLangcode" 229 | [language_from_user_admin]="LanguageNegotiationUserAdmin::getLangcode" 230 | [language_from_session]="LanguageNegotiationSession::getLangcode" 231 | [language_from_url]="LanguageNegotiationFoo::getLangcode" 232 | [language_url_fallback]="LanguageNegotiationFooFallback::getLangcode" 233 | [language_switcher_session]="LanguageNegotiationSession::getLanguageSwitchLinks" 234 | [language_switcher_url]="LanguageNegotiationFoo::getLanguageSwitchLinks" 235 | [language_url_rewrite_session]="LanguageNegotiationSession::processOutbound" 236 | [list_themes]="\$theme_handler = \Drupal::service('theme_handler')" 237 | [menu_get_active_trail]="\Drupal::service('menu_link.tree')->getActiveTrailIds(\$menu_name)" 238 | [menu_link_content_uninstall]="" 239 | [menu_set_active_item]="\Drupal::service('menu_link.tree')->getActiveTrailIds(\$menu_name)" 240 | [menu_set_active_trail]="\Drupal::service('menu_link.tree')->getActiveTrailIds(\$menu_name)" 241 | [mime_header_decode]="Unicode::mimeHeaderDecode()" 242 | [mime_header_encode]="Unicode::mimeHeaderEncode()" 243 | [module_exists]="\Drupal::moduleHandler()->moduleExists('module_name')" 244 | [module_invoke]="\$module_handler->invoke(\$module, \$hook, \$args = array())" 245 | [module_invoke_all]="\Drupal::moduleHandler()->invokeAll(\$hook, \$args = array())" 246 | [module_hook]="\Drupal::moduleHandler()->implementsHook(\$module, \$hook)" 247 | [module_implements]="\Drupal::moduleHandler()->getImplementations(\$hook)" 248 | [module_list]="\$module_handler->setModuleList(array \$module_list = array())" 249 | [module_load_all]="\Drupal::moduleHandler()->loadAll(); / module_load_all(\$bootstrap = NULL)] => \$this->moduleHandler->loadAllIncludes();" 250 | [module_load_all_includes]="\Drupal::moduleHandler()->loadAllIncludes(\$type, \$name = NULL)" 251 | [node_load]="\Drupal\node\Entity\Node::load()" 252 | [node_type_get_type]="See https://www.drupal.org/node/1574670" 253 | [node_type_get_types]="\Drupal\node\Entity\NodeType::loadMultiple()" 254 | [node_type_load]="TODO" 255 | [request_path]="\Drupal\Core\Url::fromRoute('');" 256 | [request_uri]="$uri = \Drupal::request()->getRequestUri(); / $uri_without_query_string = \Drupal::request()->getPathInfo();" 257 | [st]="TODO" 258 | [system_get_date_format]="Drupal 8's Configuration API" 259 | [system_get_date_formats]="Drupal 8's Configuration API" 260 | [system_get_date_types]="Drupal 8's Configuration API" 261 | [system_list]="ModuleHandlerInterface::getModuleList" 262 | [system_rebuild_theme_data]="$theme_handler->rebuildThemeData()" 263 | [t]="\$this->t('some text')" 264 | [taxonomy_get_tree]="\$tree = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree(\$vid, \$parent, \$max_depth, \$load_entities);" 265 | [taxonomy_term_load_children]="\$parents = \Drupal::entityManager()->getStorage('taxonomy_term')->loadChildren(\$tid);" 266 | [taxonomy_term_load_parents]="\$parents = \Drupal::entityManager()->getStorage('taxonomy_term')->loadParents(\$tid);" 267 | [taxonomy_term_load_parents_all]="\$parents = \Drupal::entityManager()->getStorage('taxonomy_term')->loadParentsAll(\$tid);" 268 | [theme_enable]="\$theme_handler->enable(\$theme_list)" 269 | [theme_disable]="\$theme_handler->disable(\$theme_list)" 270 | [theme_link]="#type' => 'link'" 271 | [truncate_utf8]="Unicode::truncate()" 272 | [unicode_check]="Unicode::check()" 273 | [_update_create_fetch_task]="\Drupal::service('update.processor')->createFetchTask(\$project);" 274 | [_update_process_fetch_task]="\Drupal::service('update.processor')->processFetchTask(\$project);" 275 | [_update_refresh]="\Drupal::service('update.manager')->refreshUpdateData();" 276 | [update_fetch_data]="\Drupal::service('update.processor')->fetchData();" 277 | [update_fetch_data_finished]="\Drupal::service('update.manager')->fetchDataBatch(\$context);" 278 | [update_get_projects]="\$projects = \Drupal::service('update.manager')->getProjects();" 279 | [update_manual_status]="\Drupal\update\Controller\UpdateController::updateStatusManually();" 280 | [url]="use Drupal\Core\Url; / \$internal_link = \$this->l(t('Book admin'), Url::fromRoute('book.admin')); / \$external_link = \$this->l(t('External link'), Url::fromUri('http://www.example.com/'));" 281 | [url_is_external]="UrlHelper::isExternal('http://www.drupal.org')" 282 | [user_access]="User::hasPermission()" 283 | [user_load]="\Drupal::entityManager()->getStorage('user')->load(\$id);" 284 | [user_load_multiple]="\Drupal\user\Entity\User::loadMultiple()" 285 | [valid_url]="TODO" 286 | [views_get_applicable_views]="TBD" 287 | ) 288 | 289 | for API_FUNCTIONS in "${!FUNCTIONS[@]}"; do 290 | if [[ $(find "${VALID_PATH}" -type f ! -name "*.css" ! -name "*.js" | xargs grep -s -E " ${API_FUNCTIONS}[(*$]") ]]; then 291 | echo -e "\tReplace ${RED}${API_FUNCTIONS}()${COLOR_ENDING} by ${GREEN}${FUNCTIONS[${API_FUNCTIONS}]}${COLOR_ENDING}" 292 | fi 293 | done 294 | 295 | ############# 296 | # CONSTANTS # 297 | ############# 298 | echo -e "${BLUE}Auditing constants...${COLOR_ENDING}" 299 | 300 | declare -A CONSTANTS 301 | CONSTANTS=( 302 | [COMMENT_FORM_BELOW]="CommentItem::FORM_BELOW" 303 | [COMMENT_FORM_SEPARATE_PAGE]="CommentItem::FORM_SEPARATE_PAGE" 304 | [COMMENT_MODE_FLAT]="CommentManagerInterface::COMMENT_MODE_FLAT" 305 | [MENU_MAX_DEPTH]="MenuLinkTreeInterface::maxDepth() to retrieve the value or MenuTreeStorage::MAX_DEPTH for the default storage max depth" 306 | [MENU_VISIBLE_IN_BREADCRUMB]="Breadcrumbs are no longer defined as menu links - See https://www.drupal.org/node/2098323" 307 | [MENU_NORMAL_ITEM]="TODO" 308 | [MENU_SUGGESTED_ITEM]="TODO" 309 | [MENU_PREFERRED_LINK]="TODO" 310 | [MENU_LINKS_TO_PARENT]="No replacement" 311 | [MENU_VISIBLE_IN_TREE]="No replacement" 312 | [MENU_IS_ROOT]="No replacement" 313 | [PREG_CLASS_UNICODE_WORD_BOUNDARY]="Unicode::PREG_CLASS_WORD_BOUNDARY" 314 | [UNICODE_ERROR]="Unicode::STATUS_ERROR" 315 | [UNICODE_MULTIBYTE]="Unicode::STATUS_MULTIBYTE" 316 | [UNICODE_SINGLEBYTE]="Unicode::STATUS_SINGLEBYTE" 317 | ) 318 | 319 | for API_CONSTANTS in "${!CONSTANTS[@]}"; do 320 | if [[ $(find "${VALID_PATH}" -type f ! -name "*.css" ! -name "*.js" | xargs grep "${API_CONSTANTS}") ]]; then 321 | echo -e "\tReplace ${RED}${API_CONSTANTS}()${COLOR_ENDING} by ${GREEN}${CONSTANTS[${API_CONSTANTS}]}${COLOR_ENDING}" 322 | fi 323 | done 324 | 325 | ################ 326 | # GLOBALS # 327 | ################ 328 | echo -e "${BLUE}Auditing globals...${COLOR_ENDING}" 329 | 330 | declare -A GLOBALS 331 | GLOBALS=( 332 | [\$user]="\Drupal::currentUser" 333 | [\$multibyte]="Unicode::getStatus() / Unicode::setStatus($status)" 334 | [\$script_path]="$request->getBaseUrl() . '/test'; - See also https://www.drupal.org/node/2450019" 335 | ) 336 | 337 | for API_GLOBALS in "${!GLOBALS[@]}"; do 338 | if [[ $(find "${VALID_PATH}" -type f ! -name "*.css" ! -name "*.js" | xargs grep "${API_GLOBALS}") ]]; then 339 | echo -e "\tReplace ${RED}${API_GLOBALS}()${COLOR_ENDING} by ${GREEN}${GLOBALS[${API_GLOBALS}]}${COLOR_ENDING}" 340 | fi 341 | done 342 | 343 | ################ 344 | # SUPERGLOBALS # 345 | ################ 346 | echo -e "${BLUE}Auditing superglobals...${COLOR_ENDING}" 347 | 348 | declare -A SUPERGLOBALS 349 | SUPERGLOBALS=( 350 | [\$_POST]="TODO" 351 | [\$_SERVER]="TODO" 352 | ) 353 | 354 | # Searching for $GET_['q'] doesn't work well as an array key. Hardcoding it for now. 355 | if [[ $(find "${VALID_PATH}" -type f ! -name "*.css" ! -name "*.js" | xargs grep "\$_GET\['q']") ]]; then 356 | echo -e "\tReplace ${RED}\$_GET['q']${COLOR_ENDING} by ${GREEN} route - See https://www.drupal.org/node/2382211${COLOR_ENDING}" 357 | fi 358 | 359 | for API_SGLOBALS in "${!SUPERGLOBALS[@]}"; do 360 | if [[ $(find "${VALID_PATH}" -type f ! -name "*.css" ! -name "*.js" | xargs grep "${API_SGLOBALS}") ]]; then 361 | echo -e "\tReplace ${RED}${API_SGLOBALS}()${COLOR_ENDING} by ${GREEN}${SUPERGLOBALS[${API_SGLOBALS}]}${COLOR_ENDING}" 362 | fi 363 | done 364 | -------------------------------------------------------------------------------- /audit/system_audit.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Invoke the script from anywhere (e.g .bashrc alias) 4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | 6 | # Required source files 7 | source "${DIR}"/common 8 | source "${DIR}"/functions.sh 9 | 10 | is_root 11 | 12 | PHP_APACHE="/etc/php5/apache2/php.ini" 13 | PHP_CLI="/etc/php5/cli/php.ini" 14 | 15 | MYSQL_MINIMUM="$(mysql -V | awk '{print $5}' | head -c 5)" 16 | PHP_MINIMUM="$(php -v | awk '{print $2}' | head -c 5)" 17 | 18 | DISABLE_FUNCTIONS="$(php -c ${PHP_CLI} -i | grep disable_functions | awk '{print $3$4}')" 19 | DATE_TIMEZONE="$(grep "date.timezone" ${PHP_APACHE} | awk '{print $3}' | tail -1)" 20 | DATE_TIMEZONE_CLI="$(grep "date.timezone" ${PHP_CLI} | awk '{print $3}' | tail -1)" 21 | TWIG_EXTENSION="$(grep "extension=twig.so" ${PHP_APACHE})" 22 | TWIG_EXTENSION_CLI="$(grep "extension=twig.so" ${PHP_CLI})" 23 | XDEBUG_NESTING="$(grep "xdebug.max_nesting_level" ${PHP_APACHE} | awk '{print $3}')" 24 | XDEBUG_NESTING_CLI="$(grep "xdebug.max_nesting_level" ${PHP_CLI} | awk '{print $3}')" 25 | APC_UPLOAD_PROGRESS="$(php -c ${PHP_CLI} -i | grep apc.rfc1867_name | awk '{print $3}')" 26 | 27 | # Minimum required MySQL version. 28 | if [[ "${MYSQL_MINIMUM}" < "5.5.3" ]]; then 29 | echo -e "Your MySQL version is too old (${MYSQL_MINIMUM}). Minimum requirement for Drupal 8 is PHP 5.5.3 ${RED}[ERROR]${COLOR_ENDING}" 30 | else 31 | echo -e "MySQL version is ${MYSQL_MINIMUM} ${GREEN}[OK]${COLOR_ENDING}" 32 | fi 33 | 34 | # Minimum required PHP version. 35 | if [[ "${PHP_MINIMUM}" < "5.4.2" ]]; then 36 | echo -e "Your PHP version is too old (${PHP_MINIMUM}). Minimum requirement for Drupal 8 is PHP 5.4.2 ${RED}[ERROR]${COLOR_ENDING}" 37 | else 38 | echo -e "PHP version is ${PHP_MINIMUM} ${GREEN}[OK]${COLOR_ENDING}" 39 | fi 40 | 41 | # Drush requires PHP's disable_functions to be empty, except for PHP 5.5 - See https://github.com/drush-ops/drush/pull/357 42 | if [[ "${DISABLE_FUNCTIONS}" == "novalue" ]]; then 43 | echo -e "PHP CLI's disable_functions are turned off ${GREEN}[OK]${COLOR_ENDING}" 44 | else 45 | echo -e "PHP CLI's disable_functions are turned on and might cause issues with Drush. ${RED}[ERROR]${COLOR_ENDING}" 46 | fi 47 | 48 | # date.timezone needs to be set. 49 | if [[ -z "${DATE_TIMEZONE}" ]] || [[ -z "${DATE_TIMEZONE_CLI}" ]]; then 50 | echo -e "PHP's date.timezone is not set. You should check your apache2 and CLI php.ini file settings. ${RED}[ERROR]${COLOR_ENDING}" 51 | else 52 | echo -e "PHP's date.timezone is set ${GREEN}[OK]${COLOR_ENDING}" 53 | fi 54 | 55 | # The Twig C extension should ideally be enabled. 56 | if [[ -z "${TWIG_EXTENSION}" ]] || [[ -z "${TWIG_EXTENSION_CLI}" ]]; then 57 | echo -e "The Twig C extension is not set. You should check your apache2 and CLI php.ini file settings or install the extension. See http://twig.sensiolabs.org/doc/installation.html#installing-the-c-extension. ${RED}[ERROR]${COLOR_ENDING}" 58 | else 59 | echo -e "The Twig C extension is set ${GREEN}[OK]${COLOR_ENDING}" 60 | fi 61 | 62 | # If XDebug is enabled, then check max_nesting_level. 63 | if [[ "${XDEBUG_NESTING}" -lt 256 ]] || [[ "${XDEBUG_NESTING_CLI}" -lt 256 ]]; then 64 | echo -e "PHP's xdebug.max_nesting_level should be set to 256 at a minimum. ${RED}[ERROR]${COLOR_ENDING}" 65 | else 66 | echo -e "PHP's xdebug.max_nesting_level is correctly set ${GREEN}[OK]${COLOR_ENDING}" 67 | fi 68 | 69 | # APC upload progress is recommended. 70 | if [[ -z "${APC_UPLOAD_PROGRESS}" ]]; then 71 | echo -e "APC upload progress is not correctly set. Please follow http://php.net/manual/apc.configuration.php#ini.apc.rfc1867 for instructions. ${RED}[ERROR]${COLOR_ENDING}" 72 | else 73 | echo -e "APC upload progress is correctly set ${GREEN}[OK]${COLOR_ENDING}" 74 | fi 75 | -------------------------------------------------------------------------------- /misc/README.md: -------------------------------------------------------------------------------- 1 | Requirements 2 | ------------ 3 | 4 | - Git clone HEAD from drupal.org 5 | 6 |
 7 | $ git clone --branch 8.0.x http://git.drupal.org/project/drupal.git
 8 | 
9 | 10 | - Create a *HEAD* symbolic link in the *misc* directory so that the installer knows where to git pull changes from. 11 | 12 |
13 | $ cd /path/to/misc/dir ; ln -s /path/to/d8/repo HEAD
14 | 
15 | 16 | Note: The *HEAD* directory name has been added to the .gitignore file so that it won't be deleted ever. 17 | 18 | misc/core-update.sh 19 | ----------------------- 20 | 21 | - Checks if the current working directory contains a bootstrap.inc file 22 | - Preserves common files you might have modified (.htaccess, robots.txt, settings.php, services.yml) 23 | - Updates Drupal Core by leveraging advanced rsync options (e.g. --checksum) 24 | - Logs rsync output under /tmp/core-update-YYYY-MM-DD.log 25 | -------------------------------------------------------------------------------- /misc/core-update.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Invoke the script from anywhere (e.g .bashrc alias) 4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | 6 | # Colors 7 | GREEN="\033[0;32m" 8 | RED="\033[0;31m" 9 | BLUE="\033[94m" 10 | COLOR_ENDING="\033[0m" 11 | 12 | SOURCE="${DIR}/HEAD" 13 | DEST="${PWD}" 14 | FILES="composer.json composer.lock .csslintrc .editorconfig .eslintignore .eslintrc example.gitignore .gitattributes index.php README.txt web.config" 15 | SITES="development.services.yml example.settings.local.php example.sites.php README.txt" 16 | DEFAULT="default.settings.php default.services.yml" 17 | LOG="/tmp/core-update-$(date +%F).log" 18 | 19 | echo -e "${RED}###########################################################################${COLOR_ENDING}" 20 | echo -e "${RED}# WARNING! You're about to update Drupal. This might result in data loss! #${COLOR_ENDING}" 21 | echo -e "${RED}###########################################################################${COLOR_ENDING}" 22 | 23 | echo -e "Current working directory: ${PWD}\n" 24 | 25 | read -p "Are you sure? [Y/N] " 26 | if [[ ${REPLY} =~ ^[Nn]$ ]]; then 27 | echo -e "${GREEN}Back to the comfort zone. Aborting.${COLOR_ENDING}" 28 | exit 0 29 | elif [[ ${REPLY} =~ ^[Yy]$ ]]; then 30 | echo -e "${BLUE}Starting Drupal Core update...${COLOR_ENDING}" 31 | else 32 | echo "Sorry, the only accepted input characters are [Yy/Nn]. Aborting..." 33 | exit 0 34 | fi 35 | 36 | if [[ ! -f ${DEST}/core/includes/bootstrap.inc ]]; then 37 | echo "Oops! This doesn't look like a Drupal docroot. Aborting..." 38 | exit 0 39 | else 40 | echo -e "*\n**\n***\nDrupal Core update started: $(date)\n***\n**\n*" >> "${LOG}" 41 | 42 | echo "The below files will stay untouched:" 43 | echo -e "\t.htaccess" 44 | echo -e "\trobots.txt" 45 | 46 | if [[ -d ${DEST}/sites/default ]]; then 47 | for DEFAULT_FILE in ${DEFAULT}; do 48 | echo -e "\t${DEST}/sites/default/${DEFAULT_FILE}" 49 | done 50 | fi 51 | 52 | echo -e "\t/modules" 53 | echo -e "\t/profiles" 54 | echo -e "\t/themes" 55 | 56 | echo -e "\n#############################" >> "${LOG}" 2>&1 57 | echo "# Updating docroot files... #" >> "${LOG}" 2>&1 58 | echo -e "#############################\n" >> "${LOG}" 2>&1 59 | for FILE in ${FILES}; do 60 | rsync -azP --delete --checksum "${SOURCE}"/"${FILE}" "${DEST}"/"${FILE}" >> "${LOG}" 2>&1 61 | done 62 | 63 | echo -e "\n##############################" >> "${LOG}" 2>&1 64 | echo "# Updating core directory... #" >> "${LOG}" 2>&1 65 | echo -e "##############################\n" >> "${LOG}" 2>&1 66 | rsync -azP --delete --checksum "${SOURCE}"/core/ "${DEST}"/core/ >> "${LOG}" 2>&1 67 | 68 | echo -e "\n###############################" >> "${LOG}" 2>&1 69 | echo "# Updating sites directory... #" >> "${LOG}" 2>&1 70 | echo -e "###############################\n" >> "${LOG}" 2>&1 71 | for SITES_FILE in ${SITES}; do 72 | rsync -azP --delete --checksum "${SOURCE}"/sites/"${SITES_FILE}" "${DEST}"/sites/"${SITES_FILE}" >> "${LOG}" 2>&1 73 | done 74 | 75 | if [[ -d ${DEST}/sites/default ]]; then 76 | for DEFAULT_FILE in ${DEFAULT}; do 77 | rsync -azP --delete --checksum "${SOURCE}"/sites/default/"${DEFAULT_FILE}" "${DEST}"/sites/default/"${DEFAULT_FILE}" >> "${LOG}" 2>&1 78 | done 79 | fi 80 | 81 | # Ephemeral PHP dir cleanup 82 | if [[ -d ${DEST}/sites/default/files/php ]]; then 83 | rm -Rf "${DEST}"/sites/default/files/php 84 | fi 85 | 86 | echo -e "\n*\n**\n***\nDrupal Core update completed: $(date)\n***\n**\n*\n" >> "${LOG}" 87 | fi 88 | 89 | echo -e "${BLUE}Drupal Core update completed!${COLOR_ENDING}" 90 | -------------------------------------------------------------------------------- /provisioning/.my.conf: -------------------------------------------------------------------------------- 1 | [client] 2 | host=localhost 3 | user=root 4 | password='root' 5 | -------------------------------------------------------------------------------- /provisioning/.mydevdesktop.conf: -------------------------------------------------------------------------------- 1 | [client] 2 | host=localhost 3 | user=drupaluser 4 | password='root' 5 | -------------------------------------------------------------------------------- /provisioning/README.md: -------------------------------------------------------------------------------- 1 | Requirements 2 | ------------ 3 | 4 | - Git clone `8.0.x` from drupal.org 5 | 6 |
 7 | $ git clone --branch 8.0.x http://git.drupal.org/project/drupal.git
 8 | 
9 | 10 | - Create a `HEAD` symbolic link in the *provisioning* directory so that the installer knows where to git pull changes from 11 | 12 |
13 | $ cd /path/to/provisioning/dir ; ln -s /path/to/d8/repo HEAD
14 | 
15 | 16 | Note: The `HEAD` symlink has been added to the `.gitignore` file so that it won't be deleted ever. 17 | 18 | provisioning/install.sh 19 | ----------------------- 20 | 21 | - Enable Apache's mod_rewrite if it is disabled 22 | - Allow you to customize the name of the new Drupal docroot 23 | - Git pull 8.0.x (HEAD) to make sure you're working with the latest dev release 24 | - Set up a new docroot with the correct permissions and requirements (settings.php, files dir...) 25 | - Create the required Apache vhost and tweak the hosts file accordingly 26 | - Create a MySQL database 27 | - Run the Drupal installer automatically and spin up the site in seconds 28 | 29 | The script assumes that your MySQL credentials are root/root and that you're downloading the latest Drupal 8 dev release to set up a new docroot under _/var/www/html_. Feel free to modify the script according to your preferences. 30 | 31 | $ install d8 32 | 33 | The `install.sh` script supports passing arguments to load a specific Drush make file. There's a make file named `dev.make` that ships with the repo. It loads some handy dev modules (devel, coder, webprofiler...) that most Drupal 8 developers will need. You can invoke it by passing `-d` as a second argument to the script. 34 | 35 | $ install d8 -d 36 | 37 | The other make file does NOT ship with the repo and you'll have to create it manually: 38 | 39 | * Place it under the `provisioning` directory 40 | * Name it `custom.make` for the install script to find it 41 | 42 | The intent of supporting a custom make file is that you can come up with your own requirements and quickly spin up a D8 instance with just what you need. That file has been added to `.gitignore` so that it won't be wiped at any point in time. You can invoke it by passing `-c` to the script. 43 | 44 | $ install d8 -c 45 | 46 | provisioning/delete.sh 47 | ---------------------- 48 | 49 | Does the exact opposite and cleans up everything (docroot, DB, vhost, hosts entry). 50 | 51 | $ delete d8 52 | 53 | 54 | provisioning/functions.sh 55 | ------------------------- 56 | 57 | Holds shared functions and feature-specific functions to keep the main files clean. 58 | 59 | provisioning/common 60 | ------------------- 61 | 62 | Simple admin script to store common variables. 63 | -------------------------------------------------------------------------------- /provisioning/common: -------------------------------------------------------------------------------- 1 | # Apache variables 2 | WEBROOT="/var/www/html" 3 | PERMS=`stat -c %U:%G ${WEBROOT}` 4 | SITES_AVAILABLE="/etc/apache2/sites-available" 5 | SITES_ENABLED="/etc/apache2/sites-enabled" 6 | APACHE_22_DEFAULT="default" 7 | APACHE_24_DEFAULT="000-default.conf" 8 | SUFFIX="local" 9 | 10 | GIT="${DIR}/HEAD" 11 | 12 | DRUSH=`which drush` 13 | 14 | # PHP variables 15 | PHP="php5-curl" 16 | 17 | # MySQL variables 18 | MYSQL=`which mysql` 19 | DB_HOST="localhost" 20 | DB_PORT="3306" 21 | 22 | # Misc variables 23 | HOMEDIR="/home/`stat -c %G ${WEBROOT}`" 24 | CREDS="admin" 25 | 26 | # Compatibility with Acquia Dev Desktop 27 | DD_CREDS="drupaluser" 28 | 29 | # Colors 30 | GREEN="\033[0;32m" 31 | RED="\033[0;31m" 32 | BLUE="\033[94m" 33 | COLOR_ENDING="\033[0m" 34 | -------------------------------------------------------------------------------- /provisioning/delete.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Invoke the script from anywhere (e.g .bashrc alias) 4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | 6 | # Required source files 7 | source "${DIR}"/common 8 | source "${DIR}"/functions.sh 9 | 10 | SITENAME=$1 11 | 12 | is_root 13 | 14 | warning 15 | 16 | docroot_selection 17 | deletion 18 | 19 | # Rebuild Drush command file cache to purge the alias 20 | ${DRUSH} -q cc drush 21 | 22 | echo -e "${GREEN}Successfully removed http://${SITENAME}.${SUFFIX}${COLOR_ENDING}" 23 | -------------------------------------------------------------------------------- /provisioning/functions.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Shared functions 4 | is_root() { 5 | # Make sure only root can execute the script 6 | if [[ ! $(id -u) = 0 ]]; then 7 | echo -e "${RED}You are required to run this script as root or with sudo! Aborting...${COLOR_ENDING}" 8 | exit 1 9 | fi 10 | } 11 | 12 | # Deployment functions 13 | 14 | mod_rewrite() { 15 | # Enable mod_rewrite if needed 16 | if [[ ! -L /etc/apache2/mods-enabled/rewrite.load ]]; then 17 | echo "Enabling mod_rewrite..." 18 | a2enmod rewrite > /dev/null 2>&1 19 | service apache2 restart 20 | fi 21 | } 22 | 23 | curl() { 24 | # Install cURL if needed 25 | if [[ ! $(dpkg -s curl | head -n1 | awk '{print $2}') == 'curl' ]]; then 26 | echo 'Installing cURL...' 27 | apt-get install -qy curl 28 | fi 29 | } 30 | 31 | 32 | head_symlink() { 33 | # @todo: allow to install from checkout or archive. 34 | # Make sure the HEAD symbolic link exists 35 | if [[ ! -L ${DIR}/HEAD ]]; then 36 | echo "You need to create a HEAD symbolic link from your Drupal checkout in the provisioning directory..." 37 | exit 1 38 | fi 39 | } 40 | 41 | installer() { 42 | # @todo: implement --minimal parameter in the installer. 43 | if [[ ${OPTION} == "-d" ]] || [[ ${OPTION} == "-c" ]]; then 44 | SITENAME_UPPER=${OPTION} 45 | if [[ -z ${OPTION} ]]; then 46 | echo -n "What should be the name of the new Drupal docroot? " 47 | read SITENAME_UPPER 48 | fi 49 | elif [[ ${OPTION} == *-* ]]; then 50 | echo -e "${RED}Only -d (dev make file) or -c (custom make file) parameters are accepted! Aborting.${COLOR_ENDING}" 51 | exit 0 52 | else 53 | 54 | SITENAME_UPPER=${DOCROOT} 55 | if [[ -z ${DOCROOT} ]]; then 56 | echo -n "What should be the name of the new Drupal docroot? " 57 | read SITENAME_UPPER 58 | fi 59 | fi 60 | 61 | # Convert sitename to lowercase if needed. 62 | SITENAME="${SITENAME_UPPER,,}" 63 | } 64 | 65 | checkout() { 66 | # Abort if docroot exists. Else, copy from Git 67 | if [[ -d ${WEBROOT}/${SITENAME} ]]; then 68 | echo -e "${RED}The ${SITENAME} docroot already exists! Aborting.${COLOR_ENDING}" 69 | exit 0 70 | else 71 | echo "Pulling changes from upstream repo..." 72 | cd "${GIT}" && git pull -q 73 | cp -R "${GIT}"/ "${WEBROOT}"/"${SITENAME}" 74 | fi 75 | } 76 | 77 | composer_dependencies() { 78 | echo "Pulling composer dependencies..." 79 | cd "${WEBROOT}"/"${SITENAME}" 80 | composer install -q 81 | } 82 | 83 | settings_files() { 84 | echo "Creating settings.testing.php file..." # See https://www.drupal.org/node/2230005 85 | touch "${WEBROOT}"/"${SITENAME}"/sites/default/settings.testing.php 86 | 87 | echo "Creating services.yml file..." 88 | cp "${WEBROOT}"/"${SITENAME}"/sites/default/default.services.yml "${WEBROOT}"/"${SITENAME}"/sites/default/services.yml 89 | } 90 | 91 | settings_php() { 92 | echo "Creating settings.php file..." 93 | cp "${WEBROOT}"/"${SITENAME}"/sites/default/default.settings.php "${WEBROOT}"/"${SITENAME}"/sites/default/settings.php 94 | 95 | # Enable settings.local.php 96 | # @todo This is very fragile. Improve the detection even if lines change. 97 | sed -i '706,708 s/# //' "${WEBROOT}"/"${SITENAME}"/sites/default/settings.php 98 | 99 | echo "Adding configuration for trusted hostnames..." 100 | cat <> ${WEBROOT}/${SITENAME}/sites/default/settings.php 101 | 102 | \$settings['trusted_host_patterns'] = array( 103 | '^${SITENAME}\\.${SUFFIX}$', 104 | ); 105 | 106 | EOT 107 | 108 | # Enable on-screen error reporting 109 | echo "\$config['system.logging']['error_level'] = 'verbose';" >> "${WEBROOT}"/"${SITENAME}"/sites/default/settings.php 110 | } 111 | 112 | twig_debugging() { 113 | echo "Turning on Twig debugging mode..." 114 | sed -i "s/debug: false/debug: true/g" "${WEBROOT}"/"${SITENAME}"/sites/default/services.yml 115 | sed -i "s/auto_reload: null/auto_reload: true/g" "${WEBROOT}"/"${SITENAME}"/sites/default/services.yml 116 | sed -i "s/cache: true/cache: false/g" "${WEBROOT}"/"${SITENAME}"/sites/default/services.yml 117 | } 118 | 119 | apache() { 120 | # Apache setup 121 | echo "Provisionning Apache vhost..." 122 | 123 | # First, determine if we're running Apache 2.2 or 2.4 124 | if [[ -f ${SITES_AVAILABLE}/${APACHE_22_DEFAULT} ]]; then 125 | cp "${SITES_AVAILABLE}"/"${APACHE_22_DEFAULT}" "${SITES_AVAILABLE}"/"${SITENAME}" 126 | # ServerName directive 127 | sed -i "3i\\\tServerName ${SITENAME}.${SUFFIX}" "${SITES_AVAILABLE}"/"${SITENAME}" 128 | # Modifying directives 129 | sed -i "s:/var/www:/${WEBROOT}/${SITENAME}:g" "${SITES_AVAILABLE}"/"${SITENAME}" 130 | # Make sure that Drupal's .htaccess clean URLs will work fine 131 | sed -i "s/AllowOverride None/AllowOverride All/g" "${SITES_AVAILABLE}"/"${SITENAME}" 132 | 133 | echo "Enabling site..." 134 | a2ensite "${SITENAME}" > /dev/null 2>&1 135 | else 136 | cp "${SITES_AVAILABLE}"/"${APACHE_24_DEFAULT}" "${SITES_AVAILABLE}"/"${SITENAME}".conf 137 | # ServerName directive 138 | sed -i "11i\\\tServerName ${SITENAME}.${SUFFIX}" "${SITES_AVAILABLE}"/"${SITENAME}".conf 139 | # ServerAlias directive 140 | sed -i "12i\\\tServerAlias ${SITENAME}.${SUFFIX}" "${SITES_AVAILABLE}"/"${SITENAME}".conf 141 | # vHost overrides 142 | sed -i "16i\\\t" "${SITES_AVAILABLE}"/"${SITENAME}".conf 143 | sed -i "17i\\\t\tOptions Indexes FollowSymLinks" "${SITES_AVAILABLE}"/"${SITENAME}".conf 144 | sed -i "18i\\\t\tAllowOverride All" "${SITES_AVAILABLE}"/"${SITENAME}".conf 145 | sed -i "19i\\\t\tRequire all granted" "${SITES_AVAILABLE}"/"${SITENAME}".conf 146 | sed -i "20i\\\t" "${SITES_AVAILABLE}"/"${SITENAME}".conf 147 | 148 | # Modifying directives 149 | sed -i "s:DocumentRoot /var/www/html:DocumentRoot ${WEBROOT}/${SITENAME}:g" "${SITES_AVAILABLE}"/"${SITENAME}".conf 150 | sed -i "s:Directory /var/www/:Directory ${WEBROOT}/${SITENAME}/:g" "${SITES_AVAILABLE}"/"${SITENAME}".conf 151 | 152 | # Custom logging 153 | sed -i "s:error.log:${SITENAME}-error.log:g" "${SITES_AVAILABLE}"/"${SITENAME}".conf 154 | sed -i "s:access.log:${SITENAME}-access.log:g" "${SITES_AVAILABLE}"/"${SITENAME}".conf 155 | 156 | echo "Enabling site..." 157 | a2ensite "${SITENAME}".conf > /dev/null 2>&1 158 | fi 159 | 160 | # Restart Apache to apply the new configuration 161 | service apache2 reload > /dev/null 2>&1 162 | } 163 | 164 | hosts_file() { 165 | echo "Adding hosts file entry..." 166 | sed -i "1i127.0.0.1\t${SITENAME}.${SUFFIX}" /etc/hosts 167 | } 168 | 169 | mysql() { 170 | # MySQL queries - See https://www.drupal.org/node/1314214 171 | DB_CREATE="CREATE DATABASE IF NOT EXISTS \`${SITENAME}\` DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci" 172 | 173 | # Custom DB queries if we're using Linux 174 | if [[ $(uname -s) == 'Linux' ]]; then 175 | DB_PERMS="GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON \`${SITENAME}\`.* TO '${CREDS}'@'${DB_HOST}' IDENTIFIED BY '${CREDS}'" 176 | SQL="${DB_CREATE};${DB_PERMS}" 177 | 178 | echo "Creating MySQL database..." 179 | $MYSQL --defaults-file="${DIR}"/.my.conf -e "${SQL}" 180 | 181 | # Custom DB queries if we're using a Mac 182 | elif [[ $(uname -s) == 'Darwin' ]]; then 183 | DB_PERMS="GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON \`${SITENAME}\`.* TO '${DD_CREDS}'@'${DB_HOST}' IDENTIFIED BY '${DD_CREDS}'" 184 | SQL="${DB_CREATE};${DB_PERMS}" 185 | 186 | echo "Creating MySQL database..." 187 | $MYSQL --defaults-file="${DIR}"/.mydevdesktop.conf -e "${SQL}" 188 | fi 189 | } 190 | 191 | drush_alias() { 192 | echo "Creating Drush alias..." 193 | 194 | cat <> ${HOMEDIR}/.drush/${SITENAME}.aliases.drushrc.php 195 | '${SITENAME}', 199 | 'env' => '${SUFFIX}', 200 | 'root' => '${WEBROOT}/${SITENAME}', 201 | 'uri' => '${SITENAME}.${SUFFIX}', 202 | ); 203 | 204 | EOT 205 | 206 | echo "Setting Drush permissions..." 207 | # Drush 208 | chown "${PERMS}" "${HOMEDIR}"/.drush/"${SITENAME}".aliases.drushrc.php 209 | chmod 600 "${HOMEDIR}"/.drush/"${SITENAME}".aliases.drushrc.php 210 | chmod -R 777 "${HOMEDIR}"/.drush/cache/ 211 | } 212 | 213 | drupal_install() { 214 | echo "Running Drupal installation..." 215 | 216 | cd "${WEBROOT}"/"${SITENAME}"/sites/default/ 217 | 218 | # Custom installation if we're using Linux 219 | if [[ $(uname -s) == 'Linux' ]]; then 220 | ${DRUSH} site-install standard install_configure_form.update_status_module='array(FALSE,FALSE)' -qy --db-url=mysql://"${CREDS}":"${CREDS}"@"${DB_HOST}":"${DB_PORT}"/"${SITENAME}" --site-name="${SITENAME}" --site-mail="${CREDS}"@"${SITENAME}"."${SUFFIX}" --account-name="${CREDS}" --account-pass="${CREDS}" --account-mail="${CREDS}"@"${SITENAME}"."${SUFFIX}" 221 | 222 | # Custom installation if we're using a Mac 223 | elif [[ $(uname -s) == 'Darwin' ]]; then 224 | ${DRUSH} site-install standard install_configure_form.update_status_module='array(FALSE,FALSE)' -qy --db-url=mysql://"${DD_CREDS}"@"${DB_HOST}":"${DB_PORT}"/"${SITENAME}" --site-name="${SITENAME}" --site-mail="${CREDS}"@"${SITENAME}"."${SUFFIX}" --account-name="${CREDS}" --account-pass="${CREDS}" --account-mail="${CREDS}"@"${SITENAME}"."${SUFFIX}" 225 | fi 226 | 227 | # Now that Drupal is installed, rebuild Drush commandfile cache to load the alias. 228 | ${DRUSH} -q cc drush 229 | } 230 | 231 | dev_mode() { 232 | echo "Setting up development mode..." 233 | # Enable Simpletest 234 | cd ../ ; mkdir simpletest ; chmod -R 777 simpletest 235 | ${DRUSH} --root="${WEBROOT}"/"${SITENAME}" en -qy simpletest 236 | } 237 | 238 | make_file() { 239 | # Load the make file, if any. (-d = dev.make / -c = custom.make) 240 | while getopts ":dc" opt; do 241 | case $opt in 242 | d) 243 | echo "Loading the dev make file..." >&2 244 | # Drush doesn't place the modules at the right location so we're changing directory manually. 245 | cd "${WEBROOT}"/"${SITENAME}" 246 | ${DRUSH} make --no-core -qy "${DIR}"/dev.make --contrib-destination=. 247 | ;; 248 | c) 249 | echo "Loading custom make file..." >&2 250 | cd "${WEBROOT}"/"${SITENAME}" 251 | ${DRUSH} make --no-core -qy "${DIR}"/custom.make --contrib-destination=. 252 | ;; 253 | esac 254 | done 255 | } 256 | 257 | set_permissions() { 258 | echo "Setting correct permissions..." 259 | # Drupal 260 | chmod go-w "${WEBROOT}"/"${SITENAME}"/sites/default 261 | chmod go-w "${WEBROOT}"/"${SITENAME}"/sites/default/settings.php 262 | chmod go-w "${WEBROOT}"/"${SITENAME}"/sites/default/services.yml 263 | chmod 777 "${WEBROOT}"/"${SITENAME}"/sites/default/files/ 264 | chmod -R 777 "${WEBROOT}"/"${SITENAME}"/sites/default/files/config_*/sync 265 | # Supposedly, the below perms are too open, but it's the only way I found to fix broken image styles. 266 | chmod 777 "${WEBROOT}"/"${SITENAME}"/sites/default/files/styles 267 | chown -R "${PERMS}" "${WEBROOT}"/"${SITENAME}" 268 | } 269 | 270 | site_check() { 271 | # Rebuilding Drupal caches 272 | ${DRUSH} --root="${WEBROOT}"/"${SITENAME}" cache-rebuild -q 273 | 274 | if [[ $(curl -sL -w "%{http_code} %{url_effective}\\n" "http://${SITENAME}.${SUFFIX}" -o /dev/null) ]]; then 275 | echo -e "${GREEN}Site is available at http://${SITENAME}.${SUFFIX}${COLOR_ENDING}" 276 | else 277 | echo -e "${RED}There has been a problem when accessing the site. Is Apache running?${COLOR_ENDING}" 278 | fi 279 | } 280 | 281 | # Deletion functions 282 | 283 | warning() { 284 | echo -e "${RED}############################################################${COLOR_ENDING}" 285 | echo -e "${RED}# WARNING! You're about to delete a site and all its data! #${COLOR_ENDING}" 286 | echo -e "${RED}############################################################${COLOR_ENDING}" 287 | } 288 | 289 | docroot_selection() { 290 | if [[ -z ${SITENAME} ]]; then 291 | echo -n "Which Drupal docroot should we delete? " 292 | read SITENAME 293 | fi 294 | 295 | read -p "Are you sure? [Y/N] " 296 | if [[ ${REPLY} =~ ^[Nn]$ ]]; then 297 | echo -e "${GREEN}Back to the comfort zone. Aborting.${COLOR_ENDING}" 298 | exit 0 299 | elif [[ ! ${REPLY} =~ ^[Yy]$ ]]; then 300 | echo "Sorry, the only accepted input characters are [Yy/Nn]. Aborting..." 301 | exit 0 302 | fi 303 | } 304 | 305 | deletion() { 306 | # Docroot exists 307 | if [[ ! -d ${WEBROOT}/${SITENAME} ]]; then 308 | echo -e "${GREEN}The ${SITENAME} docroot doesn't exist! Aborting.${COLOR_ENDING}" 309 | exit 0 310 | fi 311 | 312 | echo "Deleting Drupal docroot..." 313 | rm -Rf "${WEBROOT:?}"/"${SITENAME}" 314 | 315 | echo "Deleting Apache vHost..." 316 | a2dissite "${SITENAME}" > /dev/null 2>&1 317 | service apache2 reload > /dev/null 2>&1 318 | 319 | # First, determine if we're running Apache 2.2 or 2.4 320 | if [[ -f ${SITES_AVAILABLE}/${SITENAME} ]]; then 321 | rm -f "${SITES_AVAILABLE}"/"${SITENAME}" 322 | else 323 | rm -f "${SITES_AVAILABLE}"/"${SITENAME}".conf 324 | rm /var/log/apache2/"${SITENAME}"-access.log && rm /var/log/apache2/"${SITENAME}"-error.log 325 | fi 326 | 327 | echo "Deleting hosts file entry..." 328 | sed -i "/${SITENAME}.${SUFFIX}/d" /etc/hosts 329 | 330 | echo "Deleting database..." 331 | ${MYSQL} --defaults-file="${DIR}"/.my.conf -e "DROP DATABASE IF EXISTS \`$SITENAME\`" 332 | 333 | echo "Deleting Drush alias..." 334 | rm "${HOMEDIR}"/.drush/"${SITENAME}".aliases.drushrc.php 335 | } 336 | -------------------------------------------------------------------------------- /provisioning/install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Invoke the script from anywhere (e.g .bashrc alias) 4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | 6 | # Required source files 7 | source "${DIR}"/common 8 | source "${DIR}"/functions.sh 9 | 10 | is_root 11 | 12 | DOCROOT=$1 13 | OPTION=$2 14 | 15 | # Requirements 16 | mod_rewrite 17 | curl 18 | head_symlink 19 | 20 | # Prepare deployment 21 | installer 22 | checkout 23 | composer_dependencies 24 | 25 | # Prepare Drupal files 26 | settings_files 27 | settings_php 28 | twig_debugging 29 | 30 | # Stack configuration 31 | apache 32 | hosts_file 33 | mysql 34 | 35 | # Drupal install 36 | drush_alias 37 | drupal_install 38 | 39 | # Local setup 40 | dev_mode 41 | make_file 42 | set_permissions 43 | 44 | site_check 45 | -------------------------------------------------------------------------------- /scaffolding/README.md: -------------------------------------------------------------------------------- 1 | scaffolding/module.sh 2 | --------------------- 3 | 4 | - Create a directory structure with Dependency Injection support (Controller, Form, Plugin, Tests) 5 | - Create required default module files and CMI config directory 6 | - Fill in *.info.yml with basic details 7 | 8 | scaffolding/common 9 | ------------------ 10 | 11 | Simple admin script to store common variables. 12 | -------------------------------------------------------------------------------- /scaffolding/common: -------------------------------------------------------------------------------- 1 | # Colors 2 | GREEN="\033[0;32m" 3 | RED="\033[0;31m" 4 | BLUE="\033[94m" 5 | COLOR_ENDING="\033[0m" -------------------------------------------------------------------------------- /scaffolding/functions.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Shared functions 4 | is_root() { 5 | # Make sure only root can execute the script 6 | if [[ ! $(id -u) = 0 ]]; then 7 | echo -e "${RED}You are required to run this script as root or with sudo! Aborting...${COLOR_ENDING}" 8 | exit 1 9 | fi 10 | } 11 | -------------------------------------------------------------------------------- /scaffolding/module.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # @todo: https://drupal.org/node/2122201 (Route subscriber + service.yml file) 4 | # @todo: https://drupal.org/node/2122195 (Access check service.yml file) 5 | 6 | # Invoke the script from anywhere (e.g .bashrc alias) 7 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 8 | 9 | # Required source files 10 | source "${DIR}"/common 11 | source "${DIR}"/functions.sh 12 | 13 | is_root 14 | 15 | # Fill-in module details. 16 | NAME=$1 17 | DESCRIPTION=$2 18 | PACKAGE=$3 19 | 20 | if [[ -z $1 ]] && [[ -z $2 ]] && [[ -z $3 ]]; then 21 | echo -n "Module name (required): " 22 | read NAME 23 | 24 | echo -n "Description (required): " 25 | read DESCRIPTION 26 | 27 | echo -n "Package (optional): " 28 | read PACKAGE 29 | fi 30 | 31 | # Confirming path. 32 | while true; do 33 | read -p "Module scaffolding will be generated under $(pwd). Should we proceed? [Y/N] " ANSWER 34 | case ${ANSWER} in 35 | [Yy] ) 36 | break;; 37 | [Nn] ) 38 | read -p "Enter the new path: " NEW_PATH 39 | break;; 40 | * ) 41 | echo -e "${RED}Sorry, you need to answer by Y/y (yes) or N/n (no).${COLOR_ENDING}" 42 | esac 43 | done 44 | 45 | # Change directory if needed. 46 | if [[ ! -z ${NEW_PATH} ]]; then 47 | cd "${NEW_PATH}" 48 | echo -e "${GREEN}New scaffolding path is ${NEW_PATH}${COLOR_ENDING}" 49 | else 50 | echo -e "${GREEN}Generating scaffolding under $(pwd)${COLOR_ENDING}" 51 | fi 52 | 53 | # Convert module name to lowercase. 54 | NAME_LOWER="${NAME,,}" 55 | 56 | # Create module directory. 57 | if [[ -d ${NAME_LOWER} ]]; then 58 | echo -e "${RED}${NAME_LOWER} directory already exists! Aborting...${COLOR_ENDING}" 59 | exit 1 60 | else 61 | echo -e "\tCreating ${NAME_LOWER} directory..." 62 | mkdir "${NAME_LOWER}" 63 | fi 64 | 65 | ############################ 66 | # Configuration Management # 67 | ############################ 68 | 69 | # Create the config directory 70 | if [[ -d ${NAME_LOWER}/config ]]; then 71 | echo -e "\t${BLUE}${NAME_LOWER}/config directory already exists! Skipping...${COLOR_ENDING}" 72 | else 73 | echo -e "\tCreating ${NAME_LOWER}/config directory..." 74 | mkdir "${NAME_LOWER}"/config 75 | mkdir "${NAME_LOWER}"/config/install 76 | fi 77 | 78 | # Offer to create a schema for the configuration files. 79 | while true; do 80 | read -p "Create Schema scaffolding for configuration files? [Y/N] " ANSWER 81 | case ${ANSWER} in 82 | [Nn] ) 83 | break;; 84 | [Yy] ) 85 | 86 | if [[ -d ${NAME_LOWER}/config/schema ]]; then 87 | echo -e "\t${BLUE}${NAME_LOWER}/config/schema directory already exists! Skipping...${COLOR_ENDING}" 88 | else 89 | echo -e "\tCreating ${NAME_LOWER}/config/schema directory..." 90 | mkdir "${NAME_LOWER}"/config/schema 91 | echo -e "${GREEN}Successfully created Schema scaffolding!${COLOR_ENDING}" 92 | fi 93 | break;; 94 | * ) 95 | echo -e "${RED}Sorry, you need to answer by Y/y (yes) or N/n (no).${COLOR_ENDING}" 96 | esac 97 | done 98 | 99 | ######################## 100 | # Dependency Injection # 101 | ######################## 102 | 103 | # Offer to create a Controller. 104 | while true; do 105 | read -p "Create Controller scaffolding? [Y/N] " ANSWER 106 | case ${ANSWER} in 107 | [Nn] ) 108 | break;; 109 | [Yy] ) 110 | if [[ -d ${NAME_LOWER}/src ]]; then 111 | echo -e "\t${BLUE}${NAME_LOWER}/src directory already exists! Skipping...${COLOR_ENDING}" 112 | else 113 | echo -e "\tCreating ${NAME_LOWER}/src directory..." 114 | mkdir "${NAME_LOWER}"/src 115 | fi 116 | 117 | if [[ -d ${NAME_LOWER}/src/Controller ]]; then 118 | echo -e "\t${BLUE}${NAME_LOWER}/src/Controller directory already exists! Skipping...${COLOR_ENDING}" 119 | else 120 | echo -e "\tCreating ${NAME_LOWER}/src/Controller directory..." 121 | mkdir "${NAME_LOWER}"/src/Controller 122 | fi 123 | 124 | # Ensure module's first letter is uppercase. 125 | NAME_1ST_UP=$(sed 's/\(.\)/\U\1/' <<< "${NAME_LOWER}") 126 | touch "${NAME_LOWER}"/src/Controller/"${NAME_1ST_UP}"Controller.php 127 | 128 | # Generating ModuleController.php default values 129 | cat <> ${NAME_LOWER}/src/Controller/${NAME_1ST_UP}Controller.php 130 | > ${NAME_LOWER}/src/Access/${NAME_1ST_UP}AccessCheck.php 174 | > ${NAME_LOWER}/${NAME_LOWER}.info.yml 306 | name: ${NAME} 307 | type: module 308 | description: '${DESCRIPTION}.' 309 | core: 8.x 310 | EOT 311 | 312 | # Only add package if any was entered. 313 | if [[ ! -z ${PACKAGE} ]]; then 314 | sed -i "4ipackage: ${PACKAGE}" "${NAME_LOWER}"/"${NAME_LOWER}".info.yml 315 | fi 316 | fi 317 | 318 | if [[ ! -f ${NAME_LOWER}/${NAME_LOWER}.module ]]; then 319 | echo -e "\tCreating ${NAME_LOWER}.module..." 320 | touch "${NAME_LOWER}"/"${NAME_LOWER}".module 321 | echo "> "${NAME_LOWER}"/"${NAME_LOWER}".module 322 | fi 323 | 324 | if [[ ! -f ${NAME_LOWER}/${NAME_LOWER}.routing.yml ]]; then 325 | echo -e "\tCreating ${NAME_LOWER}.routing.yml..." 326 | touch "${NAME_LOWER}"/"${NAME_LOWER}".routing.yml 327 | fi 328 | 329 | if [[ ! -f ${NAME_LOWER}/${NAME_LOWER}.links.menu.yml ]]; then 330 | echo -e "\tCreating ${NAME_LOWER}.links.menu.yml..." 331 | touch "${NAME_LOWER}"/"${NAME_LOWER}".links.menu.yml 332 | fi 333 | if [[ ! -f ${NAME_LOWER}/${NAME_LOWER}.links.task.yml ]]; then 334 | echo -e "\tCreating ${NAME_LOWER}.links.task.yml..." 335 | touch "${NAME_LOWER}"/"${NAME_LOWER}".links.task.yml 336 | fi 337 | 338 | if [[ ! -f ${NAME_LOWER}/${NAME_LOWER}.links.action.yml ]]; then 339 | echo -e "\tCreating ${NAME_LOWER}.links.action.yml..." 340 | touch "${NAME_LOWER}"/"${NAME_LOWER}".links.action.yml 341 | fi 342 | 343 | if [[ ! -f ${NAME_LOWER}/${NAME_LOWER}.services.yml ]]; then 344 | echo -e "\tCreating ${NAME_LOWER}.services.yml..." 345 | touch "${NAME_LOWER}"/"${NAME_LOWER}".services.yml 346 | fi 347 | 348 | echo -e "${GREEN}Successfully generated module scaffolding!${COLOR_ENDING}" 349 | --------------------------------------------------------------------------------