├── LICENSE ├── README.md └── image ├── Dockerfile ├── cypht_setup_database.php ├── docker-entrypoint.sh ├── nginx.conf └── supervisord.conf /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Cypht 2 | 3 | This was the official Docker image builder of [Cypht](https://cypht.org/). It is being replaced: 4 | - [Docker-related code will be part of the main Cypht repository](https://github.com/cypht-org/cypht/pull/1001) so https://github.com/cypht-org/cypht-docker/ will be deprecated. 5 | - https://hub.docker.com/u/cypht will replace https://hub.docker.com/r/sailfrog/cypht-docker as per https://github.com/cypht-org/cypht/issues/1016 6 | - Here is background info: https://github.com/cypht-org/cypht-docker/issues/31 7 | 8 | 9 | ### Features of this image 10 | 11 | * Alpine linux based image that is less than 50MB 12 | * Bundled nginx and PHP 7.1 provides everything in one image 13 | * Performs same install steps as found on [Cypht install page](https://cypht.org/install.html) 14 | * All Cypht mods and configuration options can be set via environment variables 15 | * Automatic database setup (if configured to use database) 16 | 17 | ### Example docker-compose 18 | 19 | * Starts a database container to be for user authentication 20 | * Starts the Cypht container available on port 80 of the host with ... 21 | * A local volume declared for persisting user settings across container reboots. 22 | * An initial user account for authentication 23 | * Environment variables for accessing the database container 24 | 25 | *NOTE: Please change usernames and passwords before using this docker-compose in your environment* 26 | 27 | ``` 28 | version: '3' 29 | services: 30 | db: 31 | image: mariadb:10 32 | volumes: 33 | - ./db:/var/lib/mysql 34 | environment: 35 | - MYSQL_ROOT_PASSWORD=root_password 36 | - MYSQL_DATABASE=cypht 37 | - MYSQL_USER=cypht 38 | - MYSQL_PASSWORD=cypht_password 39 | cypht: 40 | image: sailfrog/cypht-docker:latest 41 | volumes: 42 | - ./cypht/users:/var/lib/hm3/users 43 | ports: 44 | - "80:80" 45 | environment: 46 | - CYPHT_AUTH_USERNAME=admin 47 | - CYPHT_AUTH_PASSWORD=admin_password 48 | - CYPHT_DB_CONNECTION_TYPE=host 49 | - CYPHT_DB_HOST=db 50 | - CYPHT_DB_NAME=cypht 51 | - CYPHT_DB_USER=cypht 52 | - CYPHT_DB_PASS=cypht_password 53 | - CYPHT_SESSION_TYPE=DB 54 | ``` 55 | 56 | ### Environment variables 57 | 58 | See [hm3.sample.ini](https://github.com/cypht-org/cypht/blob/master/hm3.sample.ini) file for more information about each setting. 59 | 60 | * **CYPHT_SESSION_TYPE** : How logged in state is maintained (default : PHP - Not sure why yet but PHP sessions are not working in this image right now, but DB sessions do so I added it to the example docker compose above) 61 | * **CYPHT_AUTH_TYPE** : Type of user authentication *(default : DB)* 62 | * **CYPHT_AUTH_USERNAME** : User account to be created in database for authentication *(default : blank)* 63 | * **CYPHT_AUTH_PASSWORD** : Password for the user *(default : blank)* 64 | * **CYPHT_LDAP_AUTH_SERVER** : LDAP server (only used if auth_type is LDAP) *(default : localhost)* 65 | * **CYPHT_LDAP_AUTH_PORT** : LDAP server port (only used if auth_type is LDAP) *(default : 389)* 66 | * **CYPHT_LDAP_AUTH_TLS** : LDAP server encryption (only used if auth_type is LDAP) *(default : blank)* 67 | * **CYPHT_LDAP_AUTH_BASE_DN** : LDAP server base dn (only used if auth_type is LDAP) *(default : "example,dc:com")* 68 | * **CYPHT_IMAP_AUTH_NAME** : IMAP server name/label in UI (only used if auth_type is IMAP) *(default : localhost)* 69 | * **CYPHT_IMAP_AUTH_SERVER** : IMAP server (only used if auth_type is IMAP) *(default : localhost)* 70 | * **CYPHT_IMAP_AUTH_PORT** : IMAP server port (only used if auth_type is IMAP) *(default : 143)* 71 | * **CYPHT_IMAP_AUTH_TLS** : IMAP server encryption (only used if auth_type is IMAP) *(default : blank)* 72 | * **CYPHT_DEFAULT_SMTP_NAME** : Default SMTP server name/label in UI for all users (only makes sense if auth_type is IMAP ) *(default : blank)* 73 | * **CYPHT_DEFAULT_SMTP_SERVER** : Default SMTP server for all users (only makes sense if auth_type is IMAP ) *(default : blank)* 74 | * **CYPHT_DEFAULT_SMTP_PORT** : Default SMTP server port for all users (only makes sense if auth_type is IMAP ) *(default : blank)* 75 | * **CYPHT_DEFAULT_SMTP_TLS** : Default SMTP server encryption for all users (only makes sense if auth_type is IMAP ) *(default : blank)* 76 | * **CYPHT_DEFAULT_SMTP_NO_AUTH** : Whether or not default SMTP server for all users requires authentication (only makes sense if auth_type is IMAP ) *(default : blank)* 77 | * **CYPHT_USER_CONFIG_TYPE** : Where user settings are stored *(default : file)* 78 | * **CYPHT_USER_SETTINGS_DIR** : Directory for storing user settings (only used if user_config_type is file) *(default : /var/lib/hm3/users)* 79 | * **CYPHT_ATTACHMENT_DIR** : Directory for temporarily storing attachments of outgoing messages *(default : /var/lib/hm3/attachments)* 80 | * **CYPHT_APP_DATA_DIR** : Directory for storing module configuration files *(default : /var/lib/hm3/app_data)* 81 | * **CYPHT_DISABLE_ORIGIN_CHECK** : Disable origin header check *(default : false)* 82 | * **CYPHT_ADMIN_USERS** : Comma-delimited list of admin users receiving special rights *(default : blank)* 83 | * **CYPHT_COOKIE_DOMAIN** : Domain to be set in cookie domain property *(default : blank)* 84 | * **CYPHT_DEFAULT_EMAIL_DOMAIN** : Default email domain for users that do not login with full IMAP email address *(default : blank)* 85 | * **CYPHT_REDIRECT_AFTER_LOGIN** : Force redirect to specific page after login *(default : blank)* 86 | * **CYPHT_APP_NAME** : Label that appears to UI *(default : Cypht)* 87 | * **CYPHT_DEFAULT_LANGUAGE** : Default language for users that have not set a language *(default : en)* 88 | * **CYPHT_JS_COMPRESS** : Optionally compress JS resources *(default : false)* 89 | * **CYPHT_CSS_COMPRESS** : Optionally compress CSS resources *(default : false)* 90 | * **CYPHT_ENABLE_MEMCACHED** : Enable memcached to cache data *(default : true)* 91 | * **CYPHT_MEMCACHED_SERVER** : Memcached server *(default : 127.0.0.1)* 92 | * **CYPHT_MEMCACHED_PORT** : Memcached server port *(default : 11211)* 93 | * **CYPHT_MEMCACHED_AUTH** : Enable SASL authentication for memcached *(default : false)* 94 | * **CYPHT_MEMCACHED_USER** : Memcached server SASL authentication username *(default : blank)* 95 | * **CYPHT_MEMCACHED_PASS** : Memcached server SASL authentication password *(default : blank)* 96 | * **CYPHT_ALLOW_LONG_SESSION** : Keep user logged in across multiple browser sessions *(default : false)* 97 | * **CYPHT_LONG_SESSION_LIFETIME** : Number of days users will remain logged in (only used if allow_long_session is true) *(default : 30)* 98 | * **CYPHT_ENCRYPT_AJAX_REQUESTS** : Encrypt AJAX responses (adds 70KB to page load size) *(default : blank)* 99 | * **CYPHT_ENCRYPT_LOCAL_STORAGE** : Encrypt browser local storage (adds 70KB to page load size) *(default : blank)* 100 | * **CYPHT_DISABLE_IP_CHECK** : Disable automatic logout if IP address changes *(default : false)* 101 | * **CYPHT_ALLOW_EXTERNAL_IMAGE_SOURCES** : Allow external images to be loaded when viewing an HTML formatted E-mail message *(default : false)* 102 | * **CYPHT_SINGLE_SERVER_MODE** : Restrict Cypht to single email source and default SMTP server *(default : false)* 103 | * **CYPHT_DISABLE_EMPTY_SUPERGLOBALS** : Do not empty PHP super globals for easier 3rd party integration *(default : false)* 104 | * **CYPHT_DISABLE_OPEN_BASEDIR** : Do not apply open basedir restrictions for easier 3rd party integration *(default : false)* 105 | * **CYPHT_DISABLE_INI_SETTINGS** : Do not tweak ini settings for easier 3rd party integration *(default : false)* 106 | * **CYPHT_DISABLE_FINGERPRINT** : Do not user browser fingerprint for easier 3rd party integration *(default : false)* 107 | * **CYPHT_DB_CONNECTION_TYPE** : Database connection type if database is used for authentication, sessions, or user settings *(default : host)* 108 | * **CYPHT_DB_HOST** : Database host or IP address (only used if db_connection_type is "host") *(default : 127.0.0.1)* 109 | * **CYPHT_DB_SOCKET** : Database socket (only used if db_connection_type is "socket") *(default : /var/lib/mysqld/mysqld.sock)* 110 | * **CYPHT_DB_NAME** : Name of the database *(default : test)* 111 | * **CYPHT_DB_USER** : User for connecting to database *(default : test)* 112 | * **CYPHT_DB_PASS** : Password for user connecting to database *(default : 123456)* 113 | * **CYPHT_DB_DRIVER** : Type of database driver *(default : mysql)* 114 | * **CYPHT_MODULE_CORE** : Enable/disable Cypht core (must always be enabled) *(default : enable)* 115 | * **CYPHT_MODULE_CONTACTS** : Enable/disable support for contacts (requires ldap_contacts, gmail_contacts, or local_contacts to be enabled as well) *(default : enable)* 116 | * **CYPHT_MODULE_LOCAL_CONTACTS** : Enable/disable support for local storage for contacts *(default : enable)* 117 | * **CYPHT_MODULE_LDAP_CONTACTS** : Enable/disable support for LDAP server contacts *(default : disable)* 118 | * **CYPHT_MODULE_GMAIL_CONTACTS** : Enable/disable support for read-only Gmail contacts *(default : disable)* 119 | * **CYPHT_MODULE_FEEDS** : Enable/disable support for RSS/ATOM feed *(default : enable)* 120 | * **CYPHT_MODULE_IMAP** : Enable/disable support for IMAP email accounts *(default : enable)* 121 | * **CYPHT_MODULE_2FA** : Enable/disable support for two-factor authentication using TOTP *(default : disable)* 122 | * **CYPHT_MODULE_SMTP** : Enable/disable support for outbound email via SMTP *(default : enable)* 123 | * **CYPHT_MODULE_ACCOUNT** : Enable/disable support for creating accounts and user password updates (only used if auth_type is DB) *(default : enable)* 124 | * **CYPHT_MODULE_IDLE_TIMER** : Enable/disable support for automatic logout when idle *(default : enable)* 125 | * **CYPHT_MODULE_CALENDAR** : Enable/disable support for basic calendar *(default : enable)* 126 | * **CYPHT_MODULE_THEMES** : Enable/disable support for updating UI via css *(default : enable)* 127 | * **CYPHT_MODULE_NUX** : Enable/disable support for new user experience (common email services and development updates) *(default : enable)* 128 | * **CYPHT_MODULE_DEVELOPER** : Enable/disable support for resources and install details for debugging *(default : enable)* 129 | * **CYPHT_MODULE_GITHUB** : Enable/disable support for Github repository tracking *(default : disable)* 130 | * **CYPHT_MODULE_RECAPTCHA** : Enable/disable support for Recaptcha on login *(default : disable)* 131 | * **CYPHT_MODULE_WORDPRESS** : Enable/disable support for WordPress.com notifications *(default : disable)* 132 | * **CYPHT_MODULE_HISTORY** : Enable/disable support for list of message read since login *(default : enable)* 133 | * **CYPHT_MODULE_SAVED_SEARCHES** : Enable/disable support for saving and re-running searches easily *(default : enable)* 134 | * **CYPHT_MODULE_NASA** : Enable/disable support for NASA Astronomy Picture of the Day *(default : disable)* 135 | * **CYPHT_MODULE_PROFILES** : Enable/disable support for profiles setting reply-to, name, and signatures *(default : enable)* 136 | * **CYPHT_MODULE_INLINE_MESSAGE** : Enable/disable support for viewing messages in an inline reading-pane rather than new page *(default : enable)* 137 | * **CYPHT_MODULE_IMAP_FOLDERS** : Enable/disable support for adding/renaming/deleting folders in IMAP accounts *(default : enable)* 138 | * **CYPHT_MODULE_KEYBOARD_SHORTCUTS** : Enable/disable support for keyboard shortcuts for navigations and actions *(default : enable)* 139 | * **CYPHT_MODULE_SIEVEFILTERS** : Enable/disable support for configurable Sieve based IMAP filters *(default : disable)* 140 | * **CYPHT_MODULE_SITE** : Enable/disable support for site-specific overrides (without hacking core code) *(default : disable)* 141 | * **CYPHT_MODULE_DYNAMIC_LOGIN** : Enable/disable support for authenticating against populate mail services (only used if auth_type is dynamic) *(default : disable)* 142 | * **CYPHT_MODULE_API_LOGIN** : Enable/disable support for API based login that returns JSON response *(default : disable)* 143 | * **CYPHT_API_LOGIN_KEY** : API key for api login *(default : blank)* 144 | * **CYPHT_MODULE_RECOVER_SETTINGS** : Enable/disable support for recovering encrypted user settings after IMAP password change *(default : disable)* 145 | * **CYPHT_MODULE_HELLO_WORLD** : Enable/disable support for the example module set with lots of comments *(default : disable)* 146 | * **CYPHT_MODULE_DESKTOP_NOTIFICATIONS** : Enable/disable support for desktop notifications *(default : disable)* 147 | * **CYPHT_DEFAULT_SETTING_NO_PASSWORD_SAVE** : Default for saving passwords between logins *(default : false)* 148 | * **CYPHT_DEFAULT_SETTING_IMAP_PER_PAGE** : Default for number of messages per page for IMAP folders *(default : 20)* 149 | * **CYPHT_DEFAULT_SETTING_SIMPLE_MSG_PARTS** : Default for IMAP message structure detail on message view page *(default : false)* 150 | * **CYPHT_DEFAULT_SETTING_MSG_PART_ICONS** : Default for showing icons for each IMAP message part type *(default : true)* 151 | * **CYPHT_DEFAULT_SETTING_TEXT_ONLY** : Default for preferring text part when viewing a message *(default : false)* 152 | * **CYPHT_DEFAULT_SETTING_SENT_PER_SOURCE** : Default for per-source max for combined sent view *(default : 20)* 153 | * **CYPHT_DEFAULT_SETTING_SENT_SINCE** : Default for per-source time limit for combined sent view *(default : '-1 week')* 154 | * **CYPHT_DEFAULT_SETTING_SHOW_LIST_ICONS** : Default for displaying source icons in message lists *(default : true)* 155 | * **CYPHT_DEFAULT_SETTING_START_PAGE** : Default for redirect page after login *(default : none)* 156 | * **CYPHT_DEFAULT_SETTING_DISABLE_DELETE_PROMPT** : Default for prompting when deleting something *(default : false)* 157 | * **CYPHT_DEFAULT_SETTING_NO_FOLDER_ICONS** : Default for hiding icons in the folder list *(default : false)* 158 | * **CYPHT_DEFAULT_SETTING_ALL_EMAIL_PER_SOURCE** : Default for per-source max for all email combined view *(default : 20)* 159 | * **CYPHT_DEFAULT_SETTING_ALL_EMAIL_SINCE** : Default for per-source time limit for all email combined view *(default : '-1 week')* 160 | * **CYPHT_DEFAULT_SETTING_ALL_SINCE** : Default for per-source time limit for everything combined view *(default : '-1 week')* 161 | * **CYPHT_DEFAULT_SETTING_ALL_PER_SOURCE** : Default for per-source max for everything combined view *(default : 20)* 162 | * **CYPHT_DEFAULT_SETTING_UNREAD_PER_SOURCE** : Default for per-source max for unread combined view *(default : 20)* 163 | * **CYPHT_DEFAULT_SETTING_FLAGGED_PER_SOURCE** : Default for per-source max for flagged combined view *(default : 20)* 164 | * **CYPHT_DEFAULT_SETTING_FLAGGED_SINCE** : Default for per-source time limit for flagged combined view *(default : '-1 week')* 165 | * **CYPHT_DEFAULT_SETTING_UNREAD_SINCE** : Default for per-source time limit for unread combined view *(default : '-1 week')* 166 | * **CYPHT_DEFAULT_SETTING_TIMEZONE** : Default for timezone used to display dates *(default : 'UTC')* 167 | * **CYPHT_DEFAULT_SETTING_LIST_STYLE** : Default for message list format *(default : 'email_style')* 168 | * **CYPHT_DEFAULT_SETTING_LANGUAGE** : Default for interface language *(default : 'en')* 169 | * **CYPHT_DEFAULT_SETTING_UNREAD_EXCLUDE_FEEDS** : Default for hiding news feed items from unread combined view *(default : false)* 170 | * **CYPHT_DEFAULT_SETTING_FEED_LIMIT** : Default for per-source max for news feeds *(default : 20)* 171 | * **CYPHT_DEFAULT_SETTING_FEED_SINCE** : Default for per-source time limit for news feeds *(default : '-1 week')* 172 | * **CYPHT_DEFAULT_SETTING_SMTP_COMPOSE_TYPE** : Default for plain text or HTML formatted email on compose page *(default : 0)* 173 | * **CYPHT_DEFAULT_SETTING_SMTP_AUTO_BCC** : Default for automatically BCCing sender on outbound email *(default : false)* 174 | * **CYPHT_DEFAULT_SETTING_THEME** : Default for UI theme *(default : 'default')* 175 | * **CYPHT_DEFAULT_SETTING_UNREAD_EXCLUDE_WORDPRESS** : Default for hiding WordPress notifications from the unread combined view *(default : false)* 176 | * **CYPHT_DEFAULT_SETTING_WORDPRESS_SINCE** : Default for time limit for WordPress notifications *(default : '-1 week')* 177 | * **CYPHT_DEFAULT_SETTING_UNREAD_EXCLUDE_GITHUB** : Default for hiding GitHub notifications from the unread combined view *(default : false)* 178 | * **CYPHT_DEFAULT_SETTING_GITHUB_LIMIT** : Default for per-source max for GitHub notifications *(default : 20)* 179 | * **CYPHT_DEFAULT_SETTING_GITHUB_SINCE** : Default for time limit for GitHub notifications *(default : '-1 weeks')* 180 | * **CYPHT_DEFAULT_SETTING_INLINE_MESSAGE** : Default for displaying message details inline from message list *(default : false)* 181 | * **CYPHT_DEFAULT_SETTING_ENABLE_KEYBOARD_SHORTCUTS** : Default for enabling keyboard shortcuts *(default : 1)* 182 | * **CYPHT_DEFAULT_SETTING_ENABLE_SIEVE_FILTER** : Default for enabling configurable Sieve based IMAP filters *(default : false)* 183 | 184 | -------------------------------------------------------------------------------- /image/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.4.33-fpm-alpine 2 | 3 | ENV CYPHT_DEST "/usr/local/share/cypht" 4 | 5 | WORKDIR "/var/www" 6 | 7 | RUN set -e \ 8 | && apk add --no-cache \ 9 | supervisor \ 10 | nginx \ 11 | composer \ 12 | # GD 13 | freetype libpng libjpeg-turbo \ 14 | php-session php-fileinfo php-dom php-xml libxml2-dev php-xmlwriter php-tokenizer \ 15 | && apk add --no-cache --virtual .build-deps \ 16 | ca-certificates \ 17 | wget \ 18 | unzip \ 19 | # For GD (2fa module) 20 | libpng-dev libjpeg-turbo-dev freetype-dev \ 21 | && docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \ 22 | && docker-php-ext-install gd pdo pdo_mysql \ 23 | && mkdir ${CYPHT_DEST} \ 24 | && cd ${CYPHT_DEST} \ 25 | && mkdir /tmp/cypht-temp \ 26 | && cd /tmp/cypht-temp \ 27 | && wget https://github.com/cypht-org/cypht/archive/master.zip \ 28 | && unzip master.zip \ 29 | && cp cypht-master/hm3.sample.ini cypht-master/hm3.ini \ 30 | && find cypht-master -type d -print | xargs chmod 755 \ 31 | && find cypht-master -type f -print | xargs chmod 644 \ 32 | && chown -R root:root cypht-master \ 33 | && mv cypht-master/* ${CYPHT_DEST} \ 34 | && cd /tmp \ 35 | && rm -rf cypht-temp \ 36 | && apk del .build-deps \ 37 | && cd ${CYPHT_DEST} \ 38 | && composer self-update --2 \ 39 | && composer install \ 40 | && echo "post_max_size = 60M" >> /usr/local/etc/php/php.ini \ 41 | && echo "upload_max_filesize = 50M" >> /usr/local/etc/php/php.ini 42 | 43 | COPY nginx.conf /etc/nginx/nginx.conf 44 | COPY supervisord.conf /etc/supervisord.conf 45 | COPY docker-entrypoint.sh /usr/local/bin/ 46 | COPY cypht_setup_database.php /tmp/cypht_setup_database.php 47 | 48 | RUN set -ex \ 49 | && ln -sf /dev/stdout /var/log/nginx/access.log \ 50 | && ln -sf /dev/stderr /var/log/nginx/error.log \ 51 | && chmod 700 /tmp/cypht_setup_database.php \ 52 | && chmod +x /usr/local/bin/docker-entrypoint.sh 53 | 54 | EXPOSE 80 443 55 | 56 | ENTRYPOINT ["docker-entrypoint.sh"] 57 | -------------------------------------------------------------------------------- /image/cypht_setup_database.php: -------------------------------------------------------------------------------- 1 | setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 11 | printf("Database connection successful ...\n"); 12 | $connected = true; 13 | } catch(PDOException $e){ 14 | error_log('Waiting for database connection ... (' . $e->getMessage() . ')'); 15 | sleep(1); 16 | } 17 | } 18 | if ($session_type == 'DB') { 19 | if ($db_driver == 'mysql') { 20 | $stmt = "CREATE TABLE IF NOT EXISTS hm_user_session (hm_id varchar(250), data longblob, date timestamp, primary key (hm_id));"; 21 | } elseif ($db_driver == 'pgsql') { 22 | $stmt = "CREATE TABLE IF NOT EXISTS hm_user_session (hm_id varchar(250) primary key not null, data text, date timestamp);"; 23 | } 24 | printf("Creating database table hm_user_session ...\n"); 25 | $conn->exec($stmt); 26 | } 27 | if ($auth_type == 'DB') { 28 | if ($db_driver == 'mysql') { 29 | $stmt = "CREATE TABLE IF NOT EXISTS hm_user (username varchar(250), hash varchar(250), primary key (username));"; 30 | } elseif ($db_driver == 'pgsql') { 31 | $stmt = "CREATE TABLE IF NOT EXISTS hm_user (username varchar(255) primary key not null, hash varchar(255));"; 32 | } 33 | printf("Creating database table hm_user ...\n"); 34 | $conn->exec($stmt); 35 | } 36 | if ($user_config_type == 'DB') { 37 | if ($db_driver == 'mysql') { 38 | $stmt = "CREATE TABLE IF NOT EXISTS hm_user_settings(username varchar(250), settings longblob, primary key (username));"; 39 | } elseif ($db_driver == 'pgsql') { 40 | $stmt = "CREATE TABLE IF NOT EXISTS hm_user_settings (username varchar(250) primary key not null, settings text);"; 41 | } 42 | printf("Creating database table hm_user_settings ...\n"); 43 | $conn->exec($stmt); 44 | } 45 | -------------------------------------------------------------------------------- /image/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | CYPHT_CONFIG_FILE=/usr/local/share/cypht/hm3.ini 4 | 5 | # 6 | # Update ini file based on environment variables (only if the specific environment variable is set) 7 | # 8 | 9 | # General Settings 10 | if [ ! -z ${CYPHT_SESSION_TYPE+x} ]; then sed -i "s/session_type=.*/session_type=${CYPHT_SESSION_TYPE}/" ${CYPHT_CONFIG_FILE}; fi 11 | if [ ! -z ${CYPHT_AUTH_TYPE+x} ]; then sed -i "s/auth_type=.*/auth_type=${CYPHT_AUTH_TYPE}/" ${CYPHT_CONFIG_FILE}; fi 12 | if [ ! -z ${CYPHT_LDAP_AUTH_SERVER+x} ]; then sed -i "s/ldap_auth_server=.*/ldap_auth_server=${CYPHT_LDAP_AUTH_SERVER}/" ${CYPHT_CONFIG_FILE}; fi 13 | if [ ! -z ${CYPHT_LDAP_AUTH_PORT+x} ]; then sed -i "s/ldap_auth_port=.*/ldap_auth_port=${CYPHT_LDAP_AUTH_PORT}/" ${CYPHT_CONFIG_FILE}; fi 14 | if [ ! -z ${CYPHT_LDAP_AUTH_TLS+x} ]; then sed -i "s/ldap_auth_tls=.*/ldap_auth_tls=${CYPHT_LDAP_AUTH_TLS}/" ${CYPHT_CONFIG_FILE}; fi 15 | if [ ! -z ${CYPHT_LDAP_AUTH_BASE_DN+x} ]; then sed -i "s/ldap_auth_base_dn=.*/ldap_auth_base_dn=${CYPHT_LDAP_AUTH_BASE_DN}/" ${CYPHT_CONFIG_FILE}; fi 16 | if [ ! -z ${CYPHT_IMAP_AUTH_NAME+x} ]; then sed -i "s/imap_auth_name=.*/imap_auth_name=${CYPHT_IMAP_AUTH_NAME}/" ${CYPHT_CONFIG_FILE}; fi 17 | if [ ! -z ${CYPHT_IMAP_AUTH_SERVER+x} ]; then sed -i "s/imap_auth_server=.*/imap_auth_server=${CYPHT_IMAP_AUTH_SERVER}/" ${CYPHT_CONFIG_FILE}; fi 18 | if [ ! -z ${CYPHT_IMAP_AUTH_PORT+x} ]; then sed -i "s/imap_auth_port=.*/imap_auth_port=${CYPHT_IMAP_AUTH_PORT}/" ${CYPHT_CONFIG_FILE}; fi 19 | if [ ! -z ${CYPHT_IMAP_AUTH_TLS+x} ]; then sed -i "s/imap_auth_tls=.*/imap_auth_tls=${CYPHT_IMAP_AUTH_TLS}/" ${CYPHT_CONFIG_FILE}; fi 20 | if [ ! -z ${CYPHT_DEFAULT_SMTP_NAME+x} ]; then sed -i "s/default_smtp_name=.*/default_smtp_name=${CYPHT_DEFAULT_SMTP_NAME}/" ${CYPHT_CONFIG_FILE}; fi 21 | if [ ! -z ${CYPHT_DEFAULT_SMTP_SERVER+x} ]; then sed -i "s/default_smtp_server=.*/default_smtp_server=${CYPHT_DEFAULT_SMTP_SERVER}/" ${CYPHT_CONFIG_FILE}; fi 22 | if [ ! -z ${CYPHT_DEFAULT_SMTP_PORT+x} ]; then sed -i "s/default_smtp_port=.*/default_smtp_port=${CYPHT_DEFAULT_SMTP_PORT}/" ${CYPHT_CONFIG_FILE}; fi 23 | if [ ! -z ${CYPHT_DEFAULT_SMTP_TLS+x} ]; then sed -i "s/default_smtp_tls=.*/default_smtp_tls=${CYPHT_DEFAULT_SMTP_TLS}/" ${CYPHT_CONFIG_FILE}; fi 24 | if [ ! -z ${CYPHT_DEFAULT_SMTP_NO_AUTH+x} ]; then sed -i "s/default_smtp_no_auth=.*/default_smtp_no_auth=${CYPHT_DEFAULT_SMTP_NO_AUTH}/" ${CYPHT_CONFIG_FILE}; fi 25 | if [ ! -z ${CYPHT_USER_CONFIG_TYPE+x} ]; then sed -i "s/user_config_type=.*/user_config_type=${CYPHT_USER_CONFIG_TYPE}/" ${CYPHT_CONFIG_FILE}; fi 26 | if [ ! -z ${CYPHT_USER_SETTINGS_DIR+x} ]; then sed -i "s!user_settings_dir=.*!user_settings_dir=${CYPHT_USER_SETTINGS_DIR}!" ${CYPHT_CONFIG_FILE}; fi 27 | if [ ! -z ${CYPHT_ATTACHMENT_DIR+x} ]; then sed -i "s/attachment_dir=.*/attachment_dir=${CYPHT_ATTACHMENT_DIR}/" ${CYPHT_CONFIG_FILE}; fi 28 | if [ ! -z ${CYPHT_APP_DATA_DIR+x} ]; then sed -i "s/app_data_dir=.*/app_data_dir=${CYPHT_APP_DATA_DIR}/" ${CYPHT_CONFIG_FILE}; fi 29 | if [ ! -z ${CYPHT_DISABLE_ORIGIN_CHECK+x} ]; then sed -i "s/disable_origin_check=.*/disable_origin_check=${CYPHT_DISABLE_ORIGIN_CHECK}/" ${CYPHT_CONFIG_FILE}; fi 30 | if [ ! -z ${CYPHT_ADMIN_USERS+x} ]; then sed -i "s/admin_users=.*/admin_users=${CYPHT_ADMIN_USERS}/" ${CYPHT_CONFIG_FILE}; fi 31 | if [ ! -z ${CYPHT_COOKIE_DOMAIN+x} ]; then sed -i "s/cookie_domain=.*/cookie_domain=${CYPHT_COOKIE_DOMAIN}/" ${CYPHT_CONFIG_FILE}; fi 32 | if [ ! -z ${CYPHT_DEFAULT_EMAIL_DOMAIN+x} ]; then sed -i "s/default_email_domain=.*/default_email_domain=${CYPHT_DEFAULT_EMAIL_DOMAIN}/" ${CYPHT_CONFIG_FILE}; fi 33 | if [ ! -z ${CYPHT_REDIRECT_AFTER_LOGIN+x} ]; then sed -i "s/redirect_after_login=.*/redirect_after_login=${CYPHT_REDIRECT_AFTER_LOGIN}/" ${CYPHT_CONFIG_FILE}; fi 34 | if [ ! -z ${CYPHT_APP_NAME+x} ]; then sed -i "s/app_name=.*/app_name=${CYPHT_APP_NAME}/" ${CYPHT_CONFIG_FILE}; fi 35 | if [ ! -z ${CYPHT_DEFAULT_LANGUAGE+x} ]; then sed -i "s/default_language=.*/default_language=${CYPHT_DEFAULT_LANGUAGE}/" ${CYPHT_CONFIG_FILE}; fi 36 | if [ ! -z ${CYPHT_JS_COMPRESS+x} ]; then sed -i "s/js_compress=.*/js_compress=${CYPHT_JS_COMPRESS}/" ${CYPHT_CONFIG_FILE}; fi 37 | if [ ! -z ${CYPHT_CSS_COMPRESS+x} ]; then sed -i "s/css_compress=.*/css_compress=${CYPHT_CSS_COMPRESS}/" ${CYPHT_CONFIG_FILE}; fi 38 | if [ ! -z ${CYPHT_ENABLE_MEMCACHED+x} ]; then sed -i "s/enable_memcached=.*/enable_memcached=${CYPHT_ENABLE_MEMCACHED}/" ${CYPHT_CONFIG_FILE}; fi 39 | if [ ! -z ${CYPHT_MEMCACHED_SERVER+x} ]; then sed -i "s/memcached_server=.*/memcached_server=${CYPHT_MEMCACHED_SERVER}/" ${CYPHT_CONFIG_FILE}; fi 40 | if [ ! -z ${CYPHT_MEMCACHED_PORT+x} ]; then sed -i "s/memcached_port=.*/memcached_port=${CYPHT_MEMCACHED_PORT}/" ${CYPHT_CONFIG_FILE}; fi 41 | if [ ! -z ${CYPHT_MEMCACHED_AUTH+x} ]; then sed -i "s/memcached_auth=.*/memcached_auth=${CYPHT_MEMCACHED_AUTH}/" ${CYPHT_CONFIG_FILE}; fi 42 | if [ ! -z ${CYPHT_MEMCACHED_USER+x} ]; then sed -i "s/memcached_user=.*/memcached_user=${CYPHT_MEMCACHED_USER}/" ${CYPHT_CONFIG_FILE}; fi 43 | if [ ! -z ${CYPHT_MEMCACHED_PASS+x} ]; then sed -i "s/memcached_pass=.*/memcached_pass=${CYPHT_MEMCACHED_PASS}/" ${CYPHT_CONFIG_FILE}; fi 44 | if [ ! -z ${CYPHT_ALLOW_LONG_SESSION+x} ]; then sed -i "s/allow_long_session=.*/allow_long_session=${CYPHT_ALLOW_LONG_SESSION}/" ${CYPHT_CONFIG_FILE}; fi 45 | if [ ! -z ${CYPHT_LONG_SESSION_LIFETIME+x} ]; then sed -i "s/long_session_lifetime=.*/long_session_lifetime=${CYPHT_LONG_SESSION_LIFETIME}/" ${CYPHT_CONFIG_FILE}; fi 46 | if [ ! -z ${CYPHT_ENCRYPT_AJAX_REQUESTS+x} ]; then sed -i "s/encrypt_ajax_requests=.*/encrypt_ajax_requests=${CYPHT_ENCRYPT_AJAX_REQUESTS}/" ${CYPHT_CONFIG_FILE}; fi 47 | if [ ! -z ${CYPHT_ENCRYPT_LOCAL_STORAGE+x} ]; then sed -i "s/encrypt_local_storage=.*/encrypt_local_storage=${CYPHT_ENCRYPT_LOCAL_STORAGE}/" ${CYPHT_CONFIG_FILE}; fi 48 | if [ ! -z ${CYPHT_DISABLE_IP_CHECK+x} ]; then sed -i "s/disable_ip_check=.*/disable_ip_check=${CYPHT_DISABLE_IP_CHECK}/" ${CYPHT_CONFIG_FILE}; fi 49 | if [ ! -z ${CYPHT_ALLOW_EXTERNAL_IMAGE_SOURCES+x} ]; then sed -i "s/allow_external_image_sources=.*/allow_external_image_sources=${CYPHT_ALLOW_EXTERNAL_IMAGE_SOURCES}/" ${CYPHT_CONFIG_FILE}; fi 50 | if [ ! -z ${CYPHT_SINGLE_SERVER_MODE+x} ]; then sed -i "s/single_server_mode=.*/single_server_mode=${CYPHT_SINGLE_SERVER_MODE}/" ${CYPHT_CONFIG_FILE}; fi 51 | if [ ! -z ${CYPHT_DISABLE_EMPTY_SUPERGLOBALS+x} ]; then sed -i "s/disable_empty_superglobals=.*/disable_empty_superglobals=${CYPHT_DISABLE_EMPTY_SUPERGLOBALS}/" ${CYPHT_CONFIG_FILE}; fi 52 | if [ ! -z ${CYPHT_DISABLE_OPEN_BASEDIR+x} ]; then sed -i "s/disable_open_basedir=.*/disable_open_basedir=${CYPHT_DISABLE_OPEN_BASEDIR}/" ${CYPHT_CONFIG_FILE}; fi 53 | if [ ! -z ${CYPHT_DISABLE_INI_SETTINGS+x} ]; then sed -i "s/disable_ini_settings=.*/disable_ini_settings=${CYPHT_DISABLE_INI_SETTINGS}/" ${CYPHT_CONFIG_FILE}; fi 54 | if [ ! -z ${CYPHT_DISABLE_FINGERPRINT+x} ]; then sed -i "s/disable_fingerprint=.*/disable_fingerprint=${CYPHT_DISABLE_FINGERPRINT}/" ${CYPHT_CONFIG_FILE}; fi 55 | if [ ! -z ${CYPHT_DB_CONNECTION_TYPE+x} ]; then sed -i "s/db_connection_type=.*/db_connection_type=${CYPHT_DB_CONNECTION_TYPE}/" ${CYPHT_CONFIG_FILE}; fi 56 | if [ ! -z ${CYPHT_DB_HOST+x} ]; then sed -i "s/db_host=.*/db_host=${CYPHT_DB_HOST}/" ${CYPHT_CONFIG_FILE}; fi 57 | if [ ! -z ${CYPHT_DB_SOCKET+x} ]; then sed -i "s/db_socket=.*/db_socket=${CYPHT_DB_SOCKET}/" ${CYPHT_CONFIG_FILE}; fi 58 | if [ ! -z ${CYPHT_DB_NAME+x} ]; then sed -i "s/db_name=.*/db_name=${CYPHT_DB_NAME}/" ${CYPHT_CONFIG_FILE}; fi 59 | if [ ! -z ${CYPHT_DB_USER+x} ]; then sed -i "s/db_user=.*/db_user=${CYPHT_DB_USER}/" ${CYPHT_CONFIG_FILE}; fi 60 | if [ ! -z ${CYPHT_DB_PASS+x} ]; then sed -i "s/db_pass=.*/db_pass=${CYPHT_DB_PASS}/" ${CYPHT_CONFIG_FILE}; fi 61 | if [ ! -z ${CYPHT_DB_DRIVER+x} ]; then sed -i "s/db_driver=.*/db_driver=${CYPHT_DB_DRIVER}/" ${CYPHT_CONFIG_FILE}; fi 62 | if [ ! -z ${CYPHT_API_LOGIN_KEY+x} ]; then sed -i "s/api_login_key=.*/api_login_key=${CYPHT_API_LOGIN_KEY}/" ${CYPHT_CONFIG_FILE}; fi 63 | 64 | # Modules 65 | 66 | enable_disable_module() { 67 | local module=${1} 68 | local setting=${2} 69 | # For some reason, "(; )?" isn't working but ";\{0,1\} \{0,1\}" does the same thing 70 | if [ ${setting} = enable ] 71 | then 72 | sed -i "s/^;\{0,1\} \{0,1\}modules\[\]=${module}/modules[]=${module}/" ${CYPHT_CONFIG_FILE} 73 | if [ ${module} = api_login ]; then sed -i "s/;\{0,1\} \{0,1\}api_login_key=/api_login_key=/" ${CYPHT_CONFIG_FILE}; fi 74 | else 75 | sed -i "s/^;\{0,1\} \{0,1\}modules\[\]=${module}/; modules[]=${module}/" ${CYPHT_CONFIG_FILE} 76 | if [ ${module} = api_login ]; then sed -i "s/;\{0,1\} \{0,1\}api_login_key=/; api_login_key=/" ${CYPHT_CONFIG_FILE}; fi 77 | fi 78 | } 79 | 80 | if [ ! -z ${CYPHT_MODULE_CORE+x} ]; then enable_disable_module core ${CYPHT_MODULE_CORE}; fi 81 | if [ ! -z ${CYPHT_MODULE_CONTACTS+x} ]; then enable_disable_module contacts ${CYPHT_MODULE_CONTACTS}; fi 82 | if [ ! -z ${CYPHT_MODULE_LOCAL_CONTACTS+x} ]; then enable_disable_module local_contacts ${CYPHT_MODULE_LOCAL_CONTACTS}; fi 83 | if [ ! -z ${CYPHT_MODULE_LDAP_CONTACTS+x} ]; then enable_disable_module ldap_contacts ${CYPHT_MODULE_LDAP_CONTACTS}; fi 84 | if [ ! -z ${CYPHT_MODULE_GMAIL_CONTACTS+x} ]; then enable_disable_module gmail_contacts ${CYPHT_MODULE_GMAIL_CONTACTS}; fi 85 | if [ ! -z ${CYPHT_MODULE_FEEDS+x} ]; then enable_disable_module feeds ${CYPHT_MODULE_FEEDS}; fi 86 | if [ ! -z ${CYPHT_MODULE_IMAP+x} ]; then enable_disable_module imap ${CYPHT_MODULE_IMAP}; fi 87 | if [ ! -z ${CYPHT_MODULE_2FA+x} ]; then enable_disable_module 2fa ${CYPHT_MODULE_2FA}; fi 88 | if [ ! -z ${CYPHT_MODULE_SMTP+x} ]; then enable_disable_module smtp ${CYPHT_MODULE_SMTP}; fi 89 | if [ ! -z ${CYPHT_MODULE_ACCOUNT+x} ]; then enable_disable_module account ${CYPHT_MODULE_ACCOUNT}; fi 90 | if [ ! -z ${CYPHT_MODULE_IDLE_TIMER+x} ]; then enable_disable_module idle_timer ${CYPHT_MODULE_IDLE_TIMER}; fi 91 | if [ ! -z ${CYPHT_MODULE_CALENDAR+x} ]; then enable_disable_module calendar ${CYPHT_MODULE_CALENDAR}; fi 92 | if [ ! -z ${CYPHT_MODULE_THEMES+x} ]; then enable_disable_module themes ${CYPHT_MODULE_THEMES}; fi 93 | if [ ! -z ${CYPHT_MODULE_NUX+x} ]; then enable_disable_module nux ${CYPHT_MODULE_NUX}; fi 94 | if [ ! -z ${CYPHT_MODULE_DEVELOPER+x} ]; then enable_disable_module developer ${CYPHT_MODULE_DEVELOPER}; fi 95 | if [ ! -z ${CYPHT_MODULE_GITHUB+x} ]; then enable_disable_module github ${CYPHT_MODULE_GITHUB}; fi 96 | if [ ! -z ${CYPHT_MODULE_RECAPTCHA+x} ]; then enable_disable_module recaptcha ${CYPHT_MODULE_RECAPTCHA}; fi 97 | if [ ! -z ${CYPHT_MODULE_WORDPRESS+x} ]; then enable_disable_module wordpress ${CYPHT_MODULE_WORDPRESS}; fi 98 | if [ ! -z ${CYPHT_MODULE_HISTORY+x} ]; then enable_disable_module history ${CYPHT_MODULE_HISTORY}; fi 99 | if [ ! -z ${CYPHT_MODULE_SAVED_SEARCHES+x} ]; then enable_disable_module saved_searches ${CYPHT_MODULE_SAVED_SEARCHES}; fi 100 | if [ ! -z ${CYPHT_MODULE_NASA+x} ]; then enable_disable_module nasa ${CYPHT_MODULE_NASA}; fi 101 | if [ ! -z ${CYPHT_MODULE_PROFILES+x} ]; then enable_disable_module profiles ${CYPHT_MODULE_PROFILES}; fi 102 | if [ ! -z ${CYPHT_MODULE_INLINE_MESSAGE+x} ]; then enable_disable_module inline_message ${CYPHT_MODULE_INLINE_MESSAGE}; fi 103 | if [ ! -z ${CYPHT_MODULE_IMAP_FOLDERS+x} ]; then enable_disable_module imap_folders ${CYPHT_MODULE_IMAP_FOLDERS}; fi 104 | if [ ! -z ${CYPHT_MODULE_KEYBOARD_SHORTCUTS+x} ]; then enable_disable_module keyboard_shortcuts ${CYPHT_MODULE_KEYBOARD_SHORTCUTS}; fi 105 | if [ ! -z ${CYPHT_MODULE_SIEVEFILTERS+x} ]; then enable_disable_module sievefilters ${CYPHT_MODULE_SIEVEFILTERS}; fi 106 | if [ ! -z ${CYPHT_MODULE_SITE+x} ]; then enable_disable_module site ${CYPHT_MODULE_SITE}; fi 107 | if [ ! -z ${CYPHT_MODULE_DYNAMIC_LOGIN+x} ]; then enable_disable_module dynamic_login ${CYPHT_MODULE_DYNAMIC_LOGIN}; fi 108 | if [ ! -z ${CYPHT_MODULE_API_LOGIN+x} ]; then enable_disable_module api_login ${CYPHT_MODULE_API_LOGIN}; fi 109 | if [ ! -z ${CYPHT_MODULE_RECOVER_SETTINGS+x} ]; then enable_disable_module recover_settings ${CYPHT_MODULE_RECOVER_SETTINGS}; fi 110 | if [ ! -z ${CYPHT_MODULE_HELLO_WORLD+x} ]; then enable_disable_module hello_world ${CYPHT_MODULE_HELLO_WORLD}; fi 111 | if [ ! -z ${CYPHT_MODULE_DESKTOP_NOTIFICATIONS+x} ]; then enable_disable_module desktop_notifications ${CYPHT_MODULE_DESKTOP_NOTIFICATIONS}; fi 112 | 113 | # Defaults 114 | if [ ! -z ${CYPHT_DEFAULT_SETTING_NO_PASSWORD_SAVE+x} ]; then sed -i "s/; default_setting_no_password_save=.*/default_setting_no_password_save=${CYPHT_DEFAULT_SETTING_NO_PASSWORD_SAVE}/" config.ini; fi 115 | if [ ! -z ${CYPHT_DEFAULT_SETTING_IMAP_PER_PAGE+x} ]; then sed -i "s/; default_setting_imap_per_page=.*/default_setting_imap_per_page=${CYPHT_DEFAULT_SETTING_IMAP_PER_PAGE}/" config.ini; fi 116 | if [ ! -z ${CYPHT_DEFAULT_SETTING_SIMPLE_MSG_PARTS+x} ]; then sed -i "s/; default_setting_simple_msg_parts=.*/default_setting_simple_msg_parts=${CYPHT_DEFAULT_SETTING_SIMPLE_MSG_PARTS}/" config.ini; fi 117 | if [ ! -z ${CYPHT_DEFAULT_SETTING_MSG_PART_ICONS+x} ]; then sed -i "s/; default_setting_msg_part_icons=.*/default_setting_msg_part_icons=${CYPHT_DEFAULT_SETTING_MSG_PART_ICONS}/" config.ini; fi 118 | if [ ! -z ${CYPHT_DEFAULT_SETTING_TEXT_ONLY+x} ]; then sed -i "s/; default_setting_text_only=.*/default_setting_text_only=${CYPHT_DEFAULT_SETTING_TEXT_ONLY}/" config.ini; fi 119 | if [ ! -z ${CYPHT_DEFAULT_SETTING_SENT_PER_SOURCE+x} ]; then sed -i "s/; default_setting_sent_per_source=.*/default_setting_sent_per_source=${CYPHT_DEFAULT_SETTING_SENT_PER_SOURCE}/" config.ini; fi 120 | if [ ! -z ${CYPHT_DEFAULT_SETTING_SENT_SINCE+x} ]; then sed -i "s/; default_setting_sent_since=.*/default_setting_sent_since=${CYPHT_DEFAULT_SETTING_SENT_SINCE}/" config.ini; fi 121 | if [ ! -z ${CYPHT_DEFAULT_SETTING_SHOW_LIST_ICONS+x} ]; then sed -i "s/; default_setting_show_list_icons=.*/default_setting_show_list_icons=${CYPHT_DEFAULT_SETTING_SHOW_LIST_ICONS}/" config.ini; fi 122 | if [ ! -z ${CYPHT_DEFAULT_SETTING_START_PAGE+x} ]; then sed -i "s/; default_setting_start_page=.*/default_setting_start_page=${CYPHT_DEFAULT_SETTING_START_PAGE}/" config.ini; fi 123 | if [ ! -z ${CYPHT_DEFAULT_SETTING_DISABLE_DELETE_PROMPT+x} ]; then sed -i "s/; default_setting_disable_delete_prompt=.*/default_setting_disable_delete_prompt=${CYPHT_DEFAULT_SETTING_DISABLE_DELETE_PROMPT}/" config.ini; fi 124 | if [ ! -z ${CYPHT_DEFAULT_SETTING_NO_FOLDER_ICONS+x} ]; then sed -i "s/; default_setting_no_folder_icons=.*/default_setting_no_folder_icons=${CYPHT_DEFAULT_SETTING_NO_FOLDER_ICONS}/" config.ini; fi 125 | if [ ! -z ${CYPHT_DEFAULT_SETTING_ALL_EMAIL_PER_SOURCE+x} ]; then sed -i "s/; default_setting_all_email_per_source=.*/default_setting_all_email_per_source=${CYPHT_DEFAULT_SETTING_ALL_EMAIL_PER_SOURCE}/" config.ini; fi 126 | if [ ! -z ${CYPHT_DEFAULT_SETTING_ALL_EMAIL_SINCE+x} ]; then sed -i "s/; default_setting_all_email_since=.*/default_setting_all_email_since=${CYPHT_DEFAULT_SETTING_ALL_EMAIL_SINCE}/" config.ini; fi 127 | if [ ! -z ${CYPHT_DEFAULT_SETTING_ALL_SINCE+x} ]; then sed -i "s/; default_setting_all_since=.*/default_setting_all_since=${CYPHT_DEFAULT_SETTING_ALL_SINCE}/" config.ini; fi 128 | if [ ! -z ${CYPHT_DEFAULT_SETTING_ALL_PER_SOURCE+x} ]; then sed -i "s/; default_setting_all_per_source=.*/default_setting_all_per_source=${CYPHT_DEFAULT_SETTING_ALL_PER_SOURCE}/" config.ini; fi 129 | if [ ! -z ${CYPHT_DEFAULT_SETTING_UNREAD_PER_SOURCE+x} ]; then sed -i "s/; default_setting_unread_per_source=.*/default_setting_unread_per_source=${CYPHT_DEFAULT_SETTING_UNREAD_PER_SOURCE}/" config.ini; fi 130 | if [ ! -z ${CYPHT_DEFAULT_SETTING_FLAGGED_PER_SOURCE+x} ]; then sed -i "s/; default_setting_flagged_per_source=.*/default_setting_flagged_per_source=${CYPHT_DEFAULT_SETTING_FLAGGED_PER_SOURCE}/" config.ini; fi 131 | if [ ! -z ${CYPHT_DEFAULT_SETTING_FLAGGED_SINCE+x} ]; then sed -i "s/; default_setting_flagged_since=.*/default_setting_flagged_since=${CYPHT_DEFAULT_SETTING_FLAGGED_SINCE}/" config.ini; fi 132 | if [ ! -z ${CYPHT_DEFAULT_SETTING_UNREAD_SINCE+x} ]; then sed -i "s/; default_setting_unread_since=.*/default_setting_unread_since=${CYPHT_DEFAULT_SETTING_UNREAD_SINCE}/" config.ini; fi 133 | if [ ! -z ${CYPHT_DEFAULT_SETTING_TIMEZONE+x} ]; then sed -i "s/; default_setting_timezone=.*/default_setting_timezone=${CYPHT_DEFAULT_SETTING_TIMEZONE}/" config.ini; fi 134 | if [ ! -z ${CYPHT_DEFAULT_SETTING_LIST_STYLE+x} ]; then sed -i "s/; default_setting_list_style=.*/default_setting_list_style=${CYPHT_DEFAULT_SETTING_LIST_STYLE}/" config.ini; fi 135 | if [ ! -z ${CYPHT_DEFAULT_SETTING_LANGUAGE+x} ]; then sed -i "s/; default_setting_language=.*/default_setting_language=${CYPHT_DEFAULT_SETTING_LANGUAGE}/" config.ini; fi 136 | if [ ! -z ${CYPHT_DEFAULT_SETTING_UNREAD_EXCLUDE_FEEDS+x} ]; then sed -i "s/; default_setting_unread_exclude_feeds=.*/default_setting_unread_exclude_feeds=${CYPHT_DEFAULT_SETTING_UNREAD_EXCLUDE_FEEDS}/" config.ini; fi 137 | if [ ! -z ${CYPHT_DEFAULT_SETTING_FEED_LIMIT+x} ]; then sed -i "s/; default_setting_feed_limit=.*/default_setting_feed_limit=${CYPHT_DEFAULT_SETTING_FEED_LIMIT}/" config.ini; fi 138 | if [ ! -z ${CYPHT_DEFAULT_SETTING_FEED_SINCE+x} ]; then sed -i "s/; default_setting_feed_since=.*/default_setting_feed_since=${CYPHT_DEFAULT_SETTING_FEED_SINCE}/" config.ini; fi 139 | if [ ! -z ${CYPHT_DEFAULT_SETTING_SMTP_COMPOSE_TYPE+x} ]; then sed -i "s/; default_setting_smtp_compose_type=.*/default_setting_smtp_compose_type=${CYPHT_DEFAULT_SETTING_SMTP_COMPOSE_TYPE}/" config.ini; fi 140 | if [ ! -z ${CYPHT_DEFAULT_SETTING_SMTP_AUTO_BCC+x} ]; then sed -i "s/; default_setting_smtp_auto_bcc=.*/default_setting_smtp_auto_bcc=${CYPHT_DEFAULT_SETTING_SMTP_AUTO_BCC}/" config.ini; fi 141 | if [ ! -z ${CYPHT_DEFAULT_SETTING_THEME+x} ]; then sed -i "s/; default_setting_theme=.*/default_setting_theme=${CYPHT_DEFAULT_SETTING_THEME}/" config.ini; fi 142 | if [ ! -z ${CYPHT_DEFAULT_SETTING_UNREAD_EXCLUDE_WORDPRESS+x} ]; then sed -i "s/; default_setting_unread_exclude_wordpress=.*/default_setting_unread_exclude_wordpress=${CYPHT_DEFAULT_SETTING_UNREAD_EXCLUDE_WORDPRESS}/" config.ini; fi 143 | if [ ! -z ${CYPHT_DEFAULT_SETTING_WORDPRESS_SINCE+x} ]; then sed -i "s/; default_setting_wordpress_since=.*/default_setting_wordpress_since=${CYPHT_DEFAULT_SETTING_WORDPRESS_SINCE}/" config.ini; fi 144 | if [ ! -z ${CYPHT_DEFAULT_SETTING_UNREAD_EXCLUDE_GITHUB+x} ]; then sed -i "s/; default_setting_unread_exclude_github=.*/default_setting_unread_exclude_github=${CYPHT_DEFAULT_SETTING_UNREAD_EXCLUDE_GITHUB}/" config.ini; fi 145 | if [ ! -z ${CYPHT_DEFAULT_SETTING_GITHUB_LIMIT+x} ]; then sed -i "s/; default_setting_github_limit=.*/default_setting_github_limit=${CYPHT_DEFAULT_SETTING_GITHUB_LIMIT}/" config.ini; fi 146 | if [ ! -z ${CYPHT_DEFAULT_SETTING_GITHUB_SINCE+x} ]; then sed -i "s/; default_setting_github_since=.*/default_setting_github_since=${CYPHT_DEFAULT_SETTING_GITHUB_SINCE}/" config.ini; fi 147 | if [ ! -z ${CYPHT_DEFAULT_SETTING_INLINE_MESSAGE+x} ]; then sed -i "s/; default_setting_inline_message=.*/default_setting_inline_message=${CYPHT_DEFAULT_SETTING_INLINE_MESSAGE}/" config.ini; fi 148 | if [ ! -z ${CYPHT_DEFAULT_SETTING_ENABLE_KEYBOARD_SHORTCUTS+x} ]; then sed -i "s/; default_setting_enable_keyboard_shortcuts=.*/default_setting_enable_keyboard_shortcuts=${CYPHT_DEFAULT_SETTING_ENABLE_KEYBOARD_SHORTCUTS}/" config.ini; fi 149 | if [ ! -z ${CYPHT_DEFAULT_SETTING_ENABLE_SIEVE_FILTER+x} ]; then sed -i "s/; default_setting_enable_sieve_filter=.*/default_setting_enable_sieve_filter=${CYPHT_DEFAULT_SETTING_ENABLE_SIEVE_FILTER}/" config.ini; fi 150 | 151 | 152 | # 153 | # Wait for database to be ready then setup tables for sessions, authentication, and settings as needed 154 | # 155 | session_type=$(sed -n 's/session_type=//p' ${CYPHT_CONFIG_FILE}) 156 | auth_type=$(sed -n 's/auth_type=//p' ${CYPHT_CONFIG_FILE}) 157 | user_config_type=$(sed -n 's/user_config_type=//p' ${CYPHT_CONFIG_FILE}) 158 | db_host=$(sed -n 's/db_host=//p' ${CYPHT_CONFIG_FILE}) 159 | db_name=$(sed -n 's/db_name=//p' ${CYPHT_CONFIG_FILE}) 160 | db_user=$(sed -n 's/db_user=//p' ${CYPHT_CONFIG_FILE}) 161 | db_pass=$(sed -n 's/db_pass=//p' ${CYPHT_CONFIG_FILE}) 162 | db_driver=$(sed -n 's/db_driver=//p' ${CYPHT_CONFIG_FILE}) 163 | if [ "${session_type}" = "DB" ] || [ "${auth_type}" = "DB" ] || [ "${user_config_type}" = "DB" ] 164 | then 165 | sed -i "s/CYPHT_SESSION_TYPE/${session_type}/" /tmp/cypht_setup_database.php 166 | sed -i "s/CYPHT_AUTH_TYPE/${auth_type}/" /tmp/cypht_setup_database.php 167 | sed -i "s/CYPHT_USER_CONFIG_TYPE/${user_config_type}/" /tmp/cypht_setup_database.php 168 | sed -i "s/CYPHT_DB_HOST/${db_host}/" /tmp/cypht_setup_database.php 169 | sed -i "s/CYPHT_DB_NAME/${db_name}/" /tmp/cypht_setup_database.php 170 | sed -i "s/CYPHT_DB_USER/${db_user}/" /tmp/cypht_setup_database.php 171 | sed -i "s/CYPHT_DB_PASS/${db_pass}/" /tmp/cypht_setup_database.php 172 | sed -i "s/CYPHT_DB_DRIVER/${db_driver}/" /tmp/cypht_setup_database.php 173 | php /tmp/cypht_setup_database.php 174 | fi 175 | 176 | # 177 | # Additional tasks based on the newly-configured settings 178 | # 179 | 180 | # Settings Location - create directory if config type is "file" 181 | user_config_type=$(sed -n 's/user_config_type=//p' ${CYPHT_CONFIG_FILE}) 182 | user_settings_dir=$(sed -n 's/user_settings_dir=//p' ${CYPHT_CONFIG_FILE}) 183 | if [ "${user_config_type}" = "file" ] 184 | then 185 | mkdir -p ${user_settings_dir} 186 | chown www-data:www-data ${user_settings_dir} 187 | fi 188 | 189 | # Attachment Location - create directory 190 | attachment_dir=$(sed -n 's/attachment_dir=//p' ${CYPHT_CONFIG_FILE}) 191 | mkdir -p ${attachment_dir} 192 | chown www-data:www-data ${attachment_dir} 193 | 194 | # Change /var/lib/nginx owner from root to www-data to avoid "permission denied" error. 195 | chown -R www-data:www-data /var/lib/nginx 196 | 197 | # Application Data Location - create directory 198 | app_data_dir=$(sed -n 's/app_data_dir=//p' ${CYPHT_CONFIG_FILE}) 199 | mkdir -p ${app_data_dir} 200 | chown www-data:www-data ${app_data_dir} 201 | 202 | # 203 | # Generate the run-time configuration 204 | # 205 | cd /usr/local/share/cypht 206 | php ./scripts/config_gen.php 207 | 208 | # 209 | # Enable the program in the web-server 210 | # 211 | rm -r /var/www 212 | ln -s /usr/local/share/cypht/site /var/www 213 | 214 | # 215 | # Create user account in database (or change password if user already exists) 216 | # 217 | php ./scripts/create_account.php ${CYPHT_AUTH_USERNAME} ${CYPHT_AUTH_PASSWORD} 218 | #OR maybe run the following if the user already exists... 219 | #php ./scripts/update_password.php ${CYPHT_AUTH_USERNAME} ${CYPHT_AUTH_PASSWORD} 220 | 221 | # 222 | # Close out tasks 223 | # 224 | 225 | # now that we're definitely done writing configuration, let's clear out the relevant environment variables (so that stray "phpinfo()" calls don't leak secrets from our code) 226 | #for e in "${envs[@]}"; do 227 | # unset "$e" 228 | #done 229 | 230 | # Start supervisord and services 231 | /usr/bin/supervisord -c /etc/supervisord.conf 232 | 233 | exec "$@" 234 | -------------------------------------------------------------------------------- /image/nginx.conf: -------------------------------------------------------------------------------- 1 | user www-data; 2 | worker_processes 4; 3 | pid /run/nginx.pid; 4 | events { 5 | worker_connections 768; 6 | } 7 | http { 8 | sendfile off; 9 | tcp_nopush on; 10 | tcp_nodelay on; 11 | keepalive_timeout 65; 12 | types_hash_max_size 2048; 13 | include /etc/nginx/mime.types; 14 | default_type application/octet-stream; 15 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE 16 | ssl_prefer_server_ciphers on; 17 | access_log /var/log/nginx/access.log; 18 | error_log /var/log/nginx/error.log; 19 | gzip on; 20 | gzip_disable "msie6"; 21 | server { 22 | listen 80; 23 | server_name localhost; 24 | index index.php; 25 | root /var/www; 26 | client_max_body_size 60M; 27 | location / { 28 | try_files $uri /index.php$is_args$args; 29 | } 30 | location ~ \.php { 31 | try_files $uri =404; 32 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 33 | include fastcgi_params; 34 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 35 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 36 | fastcgi_index index.php; 37 | fastcgi_pass 127.0.0.1:9000; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /image/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | logfile=/var/log/supervisord.log 4 | pidfile=/var/run/supervisord.pid 5 | 6 | [program:nginx] 7 | command=/usr/sbin/nginx -g "daemon off;" 8 | autostart=true 9 | autorestart=true 10 | stdout_logfile=/dev/stdout 11 | stdout_logfile_maxbytes=0 12 | stderr_logfile=/dev/stderr 13 | stderr_logfile_maxbytes=0 14 | 15 | [program:php-fpm] 16 | command=php-fpm 17 | autostart=true 18 | autorestart=true 19 | stdout_logfile=/dev/stdout 20 | stdout_logfile_maxbytes=0 21 | stderr_logfile=/dev/stderr 22 | stderr_logfile_maxbytes=0 23 | --------------------------------------------------------------------------------