Added patient education module:
[openemr.git] / contrib / util / installScripts / InstallerAuto.php
blob95a40471daee55685e9828f6bfdfd71f74d1b3af
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 // development_translations -> If set to anything, will then download and use the development set (updated daily)
46 // of translations from the github repository.
48 // Examples of use:
49 // 1) Install using default configuration settings
50 // php -f InstallerAuto.php
51 // 2) Provide root sql user password for installation
52 // (otherwise use default configuration settings)
53 // php -f InstallerAuto.php rootpass=howdy
54 // 3) Provide root sql user password and openemr sql user password
55 // (otherwise use default configuration settings)
56 // php -f InstallerAuto.php rootpass=howdy pass=hey
57 // 4) Provide sql user settings and openemr user settings
58 // (otherwise use default configuration settings)
59 // php -f InstallerAuto.php rootpass=howdy login=openemr2 pass=hey dbname=openemr2 iuser=tom iuname=Miller iuserpass=heynow
60 // 5) Create mutli-site (note this is very advanced usage)
61 // a. First create first installation
62 // php -f InstallerAuto.php
63 // b. Can create an installation that duplicates 'default' site but not the database
64 // php -f InstallerAuto.php login=openemr2 pass=openemr2 dbname=openemr2 site=default2 source_site_id=default
65 // c. Or can create an installation that duplicates 'default' site and database
66 // php -f InstallerAuto.php login=openemr2 pass=openemr2 dbname=openemr2 site=default2 source_site_id=default clone_database=yes
67 // d. Can continue installing new instances as needed ...
68 // php -f InstallerAuto.php login=openemr3 pass=openemr3 dbname=openemr3 site=default3 source_site_id=default clone_database=yes
71 // This exit is to avoid malicious use of this script.
72 exit;
74 require_once(dirname(__FILE__).'/../../../library/classes/Installer.class.php');
76 // Set up default configuration settings
77 $installSettings = array();
78 $installSettings['iuser'] = 'admin';
79 $installSettings['iuname'] = 'Administrator';
80 $installSettings['iuserpass'] = 'pass';
81 $installSettings['igroup'] = 'Default';
82 $installSettings['server'] = 'localhost'; // mysql server
83 $installSettings['loginhost'] = 'localhost'; // php/apache server
84 $installSettings['port'] = '3306';
85 $installSettings['root'] = 'root';
86 $installSettings['rootpass'] = 'BLANK';
87 $installSettings['login'] = 'openemr';
88 $installSettings['pass'] = 'openemr';
89 $installSettings['dbname'] = 'openemr';
90 $installSettings['collate'] = 'utf8_general_ci';
91 $installSettings['site'] = 'default';
92 $installSettings['source_site_id'] = 'BLANK';
93 $installSettings['clone_database'] = 'BLANK';
94 $installSettings['development_translations'] = 'BLANK';
96 // Collect parameters(if exist) for installation configuration settings
97 for ($i=1;$i < count($argv); $i++) {
98 $indexandvalue = explode("=",$argv[$i]);
99 $index = $indexandvalue[0];
100 $value = $indexandvalue[1];
101 $installSettings[$index] = $value;
104 // Convert BLANK settings to empty
105 $tempInstallSettings = array();
106 foreach ($installSettings as $setting => $value) {
107 if ($value == "BLANK") {
108 $value = '';
110 $tempInstallSettings[$setting] = $value;
112 $installSettings = $tempInstallSettings;
115 // Install and configure OpenEMR using the Installer class
116 $installer = new Installer( $installSettings );
117 if ( ! $installer->quick_install() ) {
118 // Failed, report error
119 echo "ERROR: " . $installer->error_message . "\n";
121 else {
122 // Successful
123 echo $installer->debug_message . "\n";