fix: ccda zip import and php warnings and deprecations (#7416)
[openemr.git] / contrib / util / installScripts / InstallerAuto.php
bloba30f128320cc8e6930067f0e7094a1be46cc7a89
1 <?php
3 /**
4 * This script is for automatic installation and configuration
5 * of OpenEMR.
7 * This script is meant to be run as php command line (php-cli),
8 * and needs to be first activated by removing the 'exit' line
9 * at top (via sed command).
11 * To activate script, need to comment out the exit command at top
12 * of script.
14 * Command ( Note that the ordering and number of custom settings
15 * that can be sent is flexible ):
16 * php -f iuser=[iuser] iuname=[iuname] iuserpass=[iuserpass] igroup=[igroup]
17 * server=[server] loginhost=[loginhost] port=[port] root=[root] rootpass=[rootpass]
18 * login=[login] pass=[pass] dbname=[dbname] collate=[collate] site=[site]
19 * source_site_id=[source_site_id] clone_database=[clone_database]
21 * Description of settings (default value in parenthesis):
22 * iuser -> initial user login name (admin)
23 * iuname -> initial user last name (Administrator)
24 * iuserpass -> initial user password (pass)
25 * igroup -> practice group name (Default)
26 * server -> mysql server (localhost)
27 * loginhost -> php/apache server (localhost)
28 * port -> MySQL port (3306)
29 * root -> MySQL server root username (root)
30 * rootpass -> MySQL server root password ()
31 * login -> username to MySQL openemr database (openemr)
32 * pass -> password to MySQL openemr database (openemr)
33 * dbname -> MySQL openemr database name (openemr)
34 * collate -> collation for mysql (utf8_general_ci)
35 * site -> location of this instance in sites/ (default)
36 * source_site_id -> location of instance to clone and mirror ()
37 * Advanced option of multi site module to allow cloning/mirroring of another local site.
38 * clone_database -> if set to anything, then will clone database from source_site_id ()
39 * Advanced option of multi site module to allow cloning/mirroring of another local database.
40 * no_root_db_access -> if set to anything, will use pre-created and pre-configured login/pass/dbname and
41 * will disable cloning / migration since that generally requires root access to the db
42 * development_translations -> If set to anything, will then download and use the development set (updated daily)
43 * of translations (indirectly) from the github repository.
45 * Examples of use:
46 * 1) Install using default configuration settings
47 * php -f InstallerAuto.php
48 * 2) Provide root sql user password for installation
49 * (otherwise use default configuration settings)
50 * php -f InstallerAuto.php rootpass=howdy
51 * 3) Provide root sql user password and openemr sql user password
52 * (otherwise use default configuration settings)
53 * php -f InstallerAuto.php rootpass=howdy pass=hey
54 * 4) Provide sql user settings and openemr user settings
55 * (otherwise use default configuration settings)
56 * php -f InstallerAuto.php rootpass=howdy login=openemr2 pass=hey dbname=openemr2 iuser=tom iuname=Miller iuserpass=heynow
57 * 5) Create mutli-site (note this is very advanced usage)
58 * a. First create first installation
59 * php -f InstallerAuto.php
60 * b. Can create an installation that duplicates 'default' site but not the database
61 * php -f InstallerAuto.php login=openemr2 pass=openemr2 dbname=openemr2 site=default2 source_site_id=default
62 * c. Or can create an installation that duplicates 'default' site and database
63 * php -f InstallerAuto.php login=openemr2 pass=openemr2 dbname=openemr2 site=default2 source_site_id=default clone_database=yes
64 * d. Can continue installing new instances as needed ...
65 * php -f InstallerAuto.php login=openemr3 pass=openemr3 dbname=openemr3 site=default3 source_site_id=default clone_database=yes
66 * 6) Provide pre-created database and restricted privilege user access credentials - example from Planettel.com.sg Proxmox OpenVZ Template
67 * (otherwise use default configuration settings - do not use for cloning / migration)
68 * php -f /var/www/openemr/contrib/util/installScripts/InstallerAuto.php no_root_db_access=1 iuserpass=oemr123 login=oemrusr pass=${UPASSWD} > /dev/null 2>&1
70 * @package OpenEMR
71 * @link http://www.open-emr.org
72 * @author Brady Miller <brady.g.miller@gmail.com>
73 * @copyright Copyright (C) 2010-2019 Brady Miller <brady.g.miller@gmail.com>
74 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
77 // This exit is to avoid malicious use of this script.
78 exit;
80 // Include standard libraries/classes
81 require_once dirname(__FILE__) . '/../../../vendor/autoload.php';
83 // Set up default configuration settings
84 $installSettings = array();
85 $installSettings['iuser'] = 'admin';
86 $installSettings['iuname'] = 'Administrator';
87 $installSettings['iuserpass'] = 'pass';
88 $installSettings['igroup'] = 'Default';
89 $installSettings['server'] = 'localhost'; // mysql server
90 $installSettings['loginhost'] = 'localhost'; // php/apache server
91 $installSettings['port'] = '3306';
92 $installSettings['root'] = 'root';
93 $installSettings['rootpass'] = 'BLANK';
94 $installSettings['login'] = 'openemr';
95 $installSettings['pass'] = 'openemr';
96 $installSettings['dbname'] = 'openemr';
97 $installSettings['collate'] = 'utf8mb4_general_ci';
98 $installSettings['site'] = 'default';
99 $installSettings['source_site_id'] = 'BLANK';
100 $installSettings['clone_database'] = 'BLANK';
101 $installSettings['no_root_db_access'] = 'BLANK';
102 $installSettings['development_translations'] = 'BLANK';
104 // Collect parameters(if exist) for installation configuration settings
105 for ($i = 1; $i < count($argv); $i++) {
106 $indexandvalue = explode("=", $argv[$i]);
107 $index = $indexandvalue[0];
108 $value = $indexandvalue[1];
109 $installSettings[$index] = $value;
112 // Convert BLANK settings to empty
113 $tempInstallSettings = array();
114 foreach ($installSettings as $setting => $value) {
115 if ($value == "BLANK") {
116 $value = '';
119 $tempInstallSettings[$setting] = $value;
122 $installSettings = $tempInstallSettings;
125 // Install and configure OpenEMR using the Installer class
126 $installer = new Installer($installSettings);
127 if (! $installer->quick_install()) {
128 // Failed, report error
129 echo "ERROR: " . $installer->error_message . "\n";
130 } else {
131 // Successful
132 echo $installer->debug_message . "\n";