Quick Install Script Improvements
[openemr.git] / contrib / util / installScripts / InstallerAuto.php
blobdfc06098fb500ea539c95e3169e3c72e7bab4447
1 <?php
2 // Copyright (C) 2010 Brady Miller <brady@sparmy.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This script is for automatic installation and ocnfiguration
10 // of OpenEMR.
11 //
12 // This script is meant to be run as php command line (php-cli),
13 // and needs to be first activated by removing the 'exit' line
14 // at top (via sed command).
16 // To activate script, need to comment out the exit command at top
17 // of script.
19 // Command ( Note that the ordering and number of custom settings
20 // that can be sent is flexible ):
21 // php -f iuser=[iuser] iuname=[iuname] iuserpass=[iuserpass] igroup=[igroup]
22 // server=[server] loginhost=[loginhost] port=[port] root=[root] rootpass=[rootpass]
23 // login=[login] pass=[pass] dbname=[dbname] collate=[collate] site=[site]
24 // source_site_id=[source_site_id] clone_database=[clone_database]
26 // Description of settings (default value in parenthesis):
27 // iuser -> initial user login name (admin)
28 // iuname -> initial user last name (Administrator)
29 // iuserpass -> initial user password (pass)
30 // igroup -> practice group name (Default)
31 // server -> mysql server (localhost)
32 // loginhost -> php/apache server (localhost)
33 // port -> MySQL port (3306)
34 // root -> MySQL server root username (root)
35 // rootpass -> MySQL server root password ()
36 // login -> username to MySQL openemr database (openemr)
37 // pass -> password to MySQL openemr database (openemr)
38 // dbname -> MySQL openemr database name (openemr)
39 // collate -> collation for mysql (utf8_general_ci)
40 // site -> location of this instance in sites/ (default)
41 // source_site_id -> location of instance to clone and mirror ()
42 // Advanced option of multi site module to allow cloning/mirroring of another local site.
43 // clone_database -> if set to anything, then will clone database from source_site_id ()
44 // Advanced option of multi site module to allow cloning/mirroring of another local database.
45 // no_root_db_access -> if set to anything, will use pre-created and pre-configured login/pass/dbname and
46 // will disable cloning / migration since that generally requires root access to the db
47 // development_translations -> If set to anything, will then download and use the development set (updated daily)
48 // of translations from the github repository.
50 // Examples of use:
51 // 1) Install using default configuration settings
52 // php -f InstallerAuto.php
53 // 2) Provide root sql user password for installation
54 // (otherwise use default configuration settings)
55 // php -f InstallerAuto.php rootpass=howdy
56 // 3) Provide root sql user password and openemr sql user password
57 // (otherwise use default configuration settings)
58 // php -f InstallerAuto.php rootpass=howdy pass=hey
59 // 4) Provide sql user settings and openemr user settings
60 // (otherwise use default configuration settings)
61 // php -f InstallerAuto.php rootpass=howdy login=openemr2 pass=hey dbname=openemr2 iuser=tom iuname=Miller iuserpass=heynow
62 // 5) Create mutli-site (note this is very advanced usage)
63 // a. First create first installation
64 // php -f InstallerAuto.php
65 // b. Can create an installation that duplicates 'default' site but not the database
66 // php -f InstallerAuto.php login=openemr2 pass=openemr2 dbname=openemr2 site=default2 source_site_id=default
67 // c. Or can create an installation that duplicates 'default' site and database
68 // php -f InstallerAuto.php login=openemr2 pass=openemr2 dbname=openemr2 site=default2 source_site_id=default clone_database=yes
69 // d. Can continue installing new instances as needed ...
70 // php -f InstallerAuto.php login=openemr3 pass=openemr3 dbname=openemr3 site=default3 source_site_id=default clone_database=yes
71 // 6) Provide pre-created database and restricted privilege user access credentials - example from Planettel.com.sg Proxmox OpenVZ Template
72 // (otherwise use default configuration settings - do not use for cloning / migration)
73 // 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
76 // This exit is to avoid malicious use of this script.
77 exit;
79 require_once(dirname(__FILE__).'/../../../library/classes/Installer.class.php');
81 // Set up default configuration settings
82 $installSettings = array();
83 $installSettings['iuser'] = 'admin';
84 $installSettings['iuname'] = 'Administrator';
85 $installSettings['iuserpass'] = 'pass';
86 $installSettings['igroup'] = 'Default';
87 $installSettings['server'] = 'localhost'; // mysql server
88 $installSettings['loginhost'] = 'localhost'; // php/apache server
89 $installSettings['port'] = '3306';
90 $installSettings['root'] = 'root';
91 $installSettings['rootpass'] = 'BLANK';
92 $installSettings['login'] = 'openemr';
93 $installSettings['pass'] = 'openemr';
94 $installSettings['dbname'] = 'openemr';
95 $installSettings['collate'] = 'utf8_general_ci';
96 $installSettings['site'] = 'default';
97 $installSettings['source_site_id'] = 'BLANK';
98 $installSettings['clone_database'] = 'BLANK';
99 $installSettings['no_root_db_access'] = 'BLANK';
100 $installSettings['development_translations'] = 'BLANK';
102 // Collect parameters(if exist) for installation configuration settings
103 for ($i=1;$i < count($argv); $i++) {
104 $indexandvalue = explode("=",$argv[$i]);
105 $index = $indexandvalue[0];
106 $value = $indexandvalue[1];
107 $installSettings[$index] = $value;
110 // Convert BLANK settings to empty
111 $tempInstallSettings = array();
112 foreach ($installSettings as $setting => $value) {
113 if ($value == "BLANK") {
114 $value = '';
116 $tempInstallSettings[$setting] = $value;
118 $installSettings = $tempInstallSettings;
121 // Install and configure OpenEMR using the Installer class
122 $installer = new Installer( $installSettings );
123 if ( ! $installer->quick_install() ) {
124 // Failed, report error
125 echo "ERROR: " . $installer->error_message . "\n";
127 else {
128 // Successful
129 echo $installer->debug_message . "\n";