Permalink
Browse files

Leveraged Andy's Installer class to automate installation of

cvs demo, Developer Appliance, and ubuntu packages.
Can also be utilized to install from command line
or scripts.
Instructions and details can be found in:
contrib/util/installScripts/InstallerAuto.php.
  • Loading branch information...
1 parent 229b49e commit 7094eff0977eda68d4daf86ac928c71e9f3dc910 bradymiller committed Oct 4, 2010
@@ -18,16 +18,15 @@ public static function get_installer()
'igroup' => 'test_igroup',
'pass' => 'test_pass',
'server' => 'localhost',
- 'port' => '',
+ 'loginhost' => 'localhost',
+ 'port' => '3306',
'root' => 'root',
'rootpass' => getenv('EMR_ROOT_DATABASE_PASSWORD'),
'dbname' => 'openemr_test_suite',
'collate' => 'utf8_general_ci',
- 'openemrBasePath' => '',
- 'openemrWebPath' => '',
'site' => 'default',
);
- return new Installer( $fixture_cgi, '' );
+ return new Installer( $fixture_cgi );
}
View
@@ -19,17 +19,15 @@ protected function setUp()
'igroup' => 'initialgroup',
'pass' => 'validpassword',
'server' => 'localhost',
+ 'loginhost' => 'localhost',
'port' => '3306',
'root' => 'root',
'rootpass' => 'notapass',
'dbname' => 'openemr_test_suite',
'collate' => '',
- 'openemrBasePath' => '',
- 'openemrWebPath' => '',
'site' => 'default',
);
- $this->manualPath = '';
- $this->installer = new Installer( $this->post_variables, $this->manualPath );
+ $this->installer = new Installer( $this->post_variables );
}
public function testAttributes()
@@ -53,7 +51,7 @@ public function testLoginValidator( $login, $expected_return )
{
$post_variables = $this->post_variables;
$post_variables['login'] = $login;
- $installer = new Installer( $post_variables, $this->manualPath );
+ $installer = new Installer( $post_variables );
$this->assertEquals($expected_return, $installer->login_is_valid(), "testing login: '$login'" );
}
@@ -73,7 +71,7 @@ public function testIuserIsInvalid()
{
$post_variables = $this->post_variables;
$post_variables['iuser'] = 'initial user';
- $installer = new Installer( $post_variables, $this->manualPath );
+ $installer = new Installer( $post_variables );
$this->assertEquals(FALSE, $installer->iuser_is_valid());
}
@@ -87,7 +85,7 @@ public function testPasswordIsInvalid()
{
$post_variables = $this->post_variables;
$post_variables['pass'] = '';
- $installer = new Installer( $post_variables, $this->manualPath );
+ $installer = new Installer( $post_variables );
$this->assertEquals(FALSE, $installer->password_is_valid());
}
@@ -161,4 +159,4 @@ public function tearDown()
You should have received a copy of the GNU General Public Licence along with
this file. If not see <http://www.gnu.org/licenses/>.
*/
-?>
+?>
View
@@ -30,11 +30,11 @@
// On 06/2009, added pertinent comments below each entry to allow capture
// of these terms by the translation engine.
- include_once('library/acl.inc');
+ require_once(dirname(__FILE__).'/library/acl.inc');
if (! $phpgacl_location) die("You must first set up library/acl.inc to use phpGACL!");
- include_once("$phpgacl_location/gacl_api.class.php");
+ require_once("$phpgacl_location/gacl_api.class.php");
$gacl = new gacl_api();
@@ -0,0 +1,99 @@
+<?php
+// Copyright (C) 2010 Brady Miller <brady@sparmy.com>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This script is for automatic installation and ocnfiguration
+// of OpenEMR.
+//
+// This script is meant to be run as php command line (php-cli),
+// and needs to be first activated by removing the 'exit' line
+// at top (via sed command).
+//
+// Two modes include:
+//
+// 1) Generic (no parameters); uses default configuration settings.
+// php -f InstallerAuto.php
+//
+// 2) Custom; can send configuration setting(s) via command line. Note
+// that the ordering and number of custom settings that can be sent
+// is flexible.
+// php -f iuser=[iuser] iuname=[iuname] igroup=[igroup] server=[server]
+// port=[port] root=[root] rootpass=[rootpass] login=[login] pass=[pass]
+// dbname=[dbname] collate=[collate] site=[site]
+//
+// Examples:
+// php -f InstallerAuto.php
+// php -f InstallerAuto.php rootpass=howdy pass=hey
+//
+
+// This exit is to avoid malicious use of this script.
+exit;
+
+require_once(dirname(__FILE__).'/../../../library/classes/Installer.class.php');
+
+// Set up default configuration settings
+$installSettings = array();
+$installSettings['iuser'] = 'admin';
+$installSettings['iuname'] = 'Administrator';
+$installSettings['igroup'] = 'Default';
+$installSettings['server'] = 'localhost'; // mysql server
+$installSettings['loginhost'] = 'localhost'; // php/apache server
+$installSettings['port'] = '3306';
+$installSettings['root'] = 'root';
+$installSettings['rootpass'] = 'BLANK';
+$installSettings['login'] = 'openemr';
+$installSettings['pass'] = 'openemr';
+$installSettings['dbname'] = 'openemr';
+$installSettings['collate'] = 'utf8_general_ci';
+$installSettings['site'] = 'default';
+
+// Collect parameters(if exist) for installation configuration settings
+for ($i=1;$i < count($argv); $i++) {
+ $indexandvalue = explode("=",$argv[$i]);
+ $index = $indexandvalue[0];
+ $value = $indexandvalue[1];
+ $installSettings[$index] = $value;
+}
+
+// Process rootpass and collate setting (convert BLANK to empty)
+if ($installSettings['rootpass'] == "BLANK") $installSettings['rootpass'] = '';
+if ($installSettings['collate'] == "BLANK") $installSettings['collate'] = '';
+
+class InstallerAuto
+{
+ protected $installer;
+ protected $post_variables;
+
+ function __construct()
+ {
+ global $installSettings;
+ $this->post_variables = array( 'iuser' => $installSettings['iuser'],
+ 'iuname' => $installSettings['iuname'],
+ 'igroup' => $installSettings['igroup'],
+ 'server' => $installSettings['server'],
+ 'loginhost' => $installSettings['loginhost'],
+ 'port' => $installSettings['port'],
+ 'root' => $installSettings['root'],
+ 'rootpass' => $installSettings['rootpass'],
+ 'login' => $installSettings['login'],
+ 'pass' => $installSettings['pass'],
+ 'dbname' => $installSettings['dbname'],
+ 'collate' => $installSettings['collate'],
+ 'site' => $installSettings['site']
+ );
+ $this->installer = new Installer( $this->post_variables );
+ if ( ! $this->installer->quick_install() ) {
+ echo "ERROR: " . $this->installer->error_message . "\n";
+ }
+ echo $this->installer->debug_message . "\n";
+ }
+}
+
+// Run Installer
+new InstallerAuto();
+
+?>
@@ -23,28 +23,16 @@ LOG=$WEB/log/logSetup.txt
CVS=/home/openemr/cvs
TMPDIR=/tmp/openemr-tmp
-# OTHER VARIABLES
-setHost="localhost" #mysql server (if not different from php, then localhost)
-setLoginhost="localhost" #php/apache server (if not different from mysql, then localhost)
-setPort="3306" #MySQL port
-setDbname="openemr" #MySQL openemr database name
-setLogin="openemr" #username to MySQL openemr database
-setPass="openemr" #password to MySQL openemr database
-setRoot="root" #MySQL server root username
-setRootpass="" #MySQL server root password
-setColl="utf8_general_ci" #collation for mysql
-setIuser="admin" #initial user login name
-setIuname="Administrator" #initial user full name
-setIgroup="Default" #practice group name
-setInst="1" #CONSTANT, don't set
+# PATH OF INSTALL SCRIPT
+INST=$OPENEMR/contrib/util/installScripts/InstallerAuto.php
+INSTTEMP=$OPENEMR/contrib/util/installScripts/InstallerAutoTemp.php
#INSTALL AND CONFIGURE OPENEMR
echo "Configuring OpenEMR"
echo "Configuring OpenEMR" >> $LOG
+#
# Set file and directory permissions
chmod 666 $OPENEMR/sites/default/sqlconf.php
-chmod 666 $OPENEMR/gacl/gacl.ini.php
-chmod 666 $OPENEMR/gacl/gacl.class.php
chown -R apache:apache $OPENEMR/sites/default/documents
chown -R apache:apache $OPENEMR/sites/default/edi
chown -R apache:apache $OPENEMR/sites/default/era
@@ -54,74 +42,33 @@ chown -R apache:apache $OPENEMR/interface/main/calendar/modules/PostCalendar/pnt
chown -R apache:apache $OPENEMR/interface/main/calendar/modules/PostCalendar/pntemplates/compiled
chown -R apache:apache $OPENEMR/gacl/admin/templates_c
#
-# CONVERT setup.php file to script, then run it
-#
-cp $OPENEMR/setup.php $OPENEMR/TEMPsetup.php
-# Set the path variable in setup.php
-sed -e 's@\$manualPath = \"\"\;@\$manualPath = \"'$OPENEMR'\/\"\;@' <$OPENEMR/TEMPsetup.php >$OPENEMR/TEMP2setup.php
-mv -f $OPENEMR/TEMP2setup.php $OPENEMR/TEMPsetup.php
-# Set the variables in setup.php
-sed -e 's@\/\/END POST VARIABLES@\
- $host = '\'''$setHost''\'';\
- $server = '\'''$setHost''\'';\
- $port = '$setPort';\
- $dbname = '\'''$setDbname''\'';\
- $root = '\'''$setRoot''\'';\
- $login = '\'''$setLogin''\'';\
- $pass = '\'''$setPass''\'';\
- $loginhost = '\'''$setLoginhost''\'';\
- $rootpass = '\'''$setRootpass''\'';\
- $iuser = '\'''$setIuser''\'';\
- $iuname = '\'''$setIuname''\'';\
- $igroup = '\'''$setIgroup''\'';\
- $collate = '\'''$setColl''\'';\
- $inst = 1;@' <$OPENEMR/TEMPsetup.php >$OPENEMR/TEMP2setup.php
-mv -f $OPENEMR/TEMP2setup.php $OPENEMR/TEMPsetup.php
-# Remove form functionality
-sed -e 's@<INPUT TYPE='\''SUBMIT'\'' VALUE='\''Continue'\''>@ @' <$OPENEMR/TEMPsetup.php >$OPENEMR/TEMP2setup.php
-mv -f $OPENEMR/TEMP2setup.php $OPENEMR/TEMPsetup.php
-#prepare gacl/setup.php script
-cp $OPENEMR/gacl/setup.php $OPENEMR/gacl/TEMP2setup.php
-sed -e 's@.\/gacl\/gacl.ini.php@'$OPENEMR'\/gacl\/gacl.ini.php@' <$OPENEMR/gacl/setup.php >$OPENEMR/gacl/TEMPsetup.php
-mv -f $OPENEMR/gacl/TEMPsetup.php $OPENEMR/gacl/setup.php
-sed -e 's@.\/gacl\/admin\/gacl_admin.inc.php@'$OPENEMR'\/gacl\/admin\/gacl_admin.inc.php@' <$OPENEMR/gacl/setup.php >$OPENEMR/gacl/TEMPsetup.php
-mv -f $OPENEMR/gacl/TEMPsetup.php $OPENEMR/gacl/setup.php
-sed -e 's@.\/gacl\/schema.xml@'$OPENEMR'\/gacl\/schema.xml@' <$OPENEMR/gacl/setup.php >$OPENEMR/gacl/TEMPsetup.php
-mv -f $OPENEMR/gacl/TEMPsetup.php $OPENEMR/gacl/setup.php
-#prepare library/acl.inc script
-cp $OPENEMR/library/acl.inc $OPENEMR/library/TEMP2acl.inc
-sed -e 's@\$phpgacl_location = \"gacl\";@\$phpgacl_location = \"'$OPENEMR'\/gacl\";@' <$OPENEMR/library/acl.inc >$OPENEMR/library/TEMPacl.inc
-mv -f $OPENEMR/library/TEMPacl.inc $OPENEMR/library/acl.inc
-# (step 3) Set up OpenEMR and MySQL
-sed -e 's@$state = $_POST\["state"\];@$state = 3;@' <$OPENEMR/TEMPsetup.php >$OPENEMR/TEMP2setup.php
-mv -f $OPENEMR/TEMP2setup.php $OPENEMR/TEMPsetup.php
-php -f $OPENEMR/TEMPsetup.php >> $LOG
-# (step 4) Configure sqlconf.php file
-sed -e 's@$state = 3;@$state = 4;@' <$OPENEMR/TEMPsetup.php >$OPENEMR/TEMP2setup.php
-mv -f $OPENEMR/TEMP2setup.php $OPENEMR/TEMPsetup.php
-php -f $OPENEMR/TEMPsetup.php >> $LOG
-rm -f $OPENEMR/TEMPsetup.php
+# Run installer class for the demo (note to avoid malicious use, script is activated by removing an exit command,
+# and the active script is then removed after completion.
+sed -e 's@^exit;@ @' <$INST >$INSTTEMP
+php -f $INSTTEMP >> $LOG
+rm -f $INSTTEMP
+#
#reinstitute file permissions
chmod 644 $OPENEMR/sites/default/sqlconf.php
-#replace original acl.inc and gacl/setup.php script
-mv $OPENEMR/library/TEMP2acl.inc $OPENEMR/library/acl.inc
-mv $OPENEMR/gacl/TEMP2setup.php $OPENEMR/gacl/setup.php
echo "Done configuring OpenEMR"
echo "Done configuring OpenEMR" >> $LOG
#NOW DEAL WITH STUFF SPECIFIC TO THE CVS DEMO AND DEVELOPER APPLIANCE
+#
#Connect to a new mandriva package repository (official repository no longer supports mandriva 2008)
echo "Updating new Mandriva Package repository. This is a 100MB download, so may take several minutes."
echo "Updating new Mandriva Package repository. This is a 100MB download, so may take several minutes." >> $LOG
urpmi.addmedia main http://ftp.ussg.iu.edu/linux/mandrake/official/2008.0/i586/media/main/release with media_info/hdlist.cz
urpmi.addmedia --update main_updates http://ftp.ussg.iu.edu/linux/mandrake/official/2008.0/i586/media/main/updates with media_info/hdlist.cz
urpmi.addmedia contrib http://ftp.ussg.iu.edu/linux/mandrake/official/2008.0/i586/media/contrib/release with media_info/hdlist.cz
urpmi.addmedia --update contrib_updates http://ftp.ussg.iu.edu/linux/mandrake/official/2008.0/i586/media/contrib/updates with media_info/hdlist.cz
+#
#Install php-gd (graphics), php-mbstring (multibyte character support), php-zip, php-xsl and perl-CGI packages
# and restart apache (done after below suhosin patch).
echo "Installing gd(graphics) and mbstring(multibyte support) and zip php packages and xsl php package and perl-CGI package..."
echo "Installing gd(graphics) and mbstring(multibyte support) and zip php packages and xsl php package and perl-CGI package..." >> $LOG
urpmi --auto php-gd php-mbstring php-zip php-xsl perl-CGI >> $LOG
+#
#Patch the suhosin bug
SUHOSINCONF=/etc/php.d/Z98_suhosin.ini
echo "Disabling suhosin patch which is not compatible with OpenEMR"
@@ -136,6 +83,7 @@ echo ""
sed -i 's/^extension = suhosin.so/; extension = suhosin.so/' $SUHOSINCONF
service httpd restart
echo ""
+#
#Replace manual with newest version from cvs
echo "Configuring appliance"
echo "Configuring appliance" >> $LOG
@@ -144,11 +92,13 @@ chown openemr:openemr /home/openemr/docs/manual.txt
cp -f $OPENEMR/contrib/util/installScripts/cvsDemoMisc/developerApplianceManual.txt $WEB/manual.txt
echo "Done configuring appliance"
echo "Done configuring appliance" >> $LOG
+#
#Package the cvs version into a tarball and zip file to be available thru web browser
# This is basically to allow download of most recent cvs version from the cvs Demo appliance
# It will also ease transfer/testing openemr on windows systems when using the Developer appliance
echo "Creating OpenEMR CVS packages"
echo "Creating OpenEMR CVS packages" >> $LOG
+#
# Prepare the cvs package
mkdir -p $TMPDIR
cp -rf $CVS/openemr $TMPDIR/
@@ -162,20 +112,25 @@ chmod -R a+w $TMPDIR/openemr/sites/default/letter_templates
chmod -R a+w $TMPDIR/openemr/interface/main/calendar/modules/PostCalendar/pntemplates/cache
chmod -R a+w $TMPDIR/openemr/interface/main/calendar/modules/PostCalendar/pntemplates/compiled
chmod -R a+w $TMPDIR/openemr/gacl/admin/templates_c
+#
# Create the web file directory
mkdir $WEB/files
+#
# Save the tar.gz cvs package
cd $TMPDIR
tar -czf $WEB/files/openemr-cvs.tar.gz openemr
cd $WEB/files
md5sum openemr-cvs.tar.gz > openemr-linux-md5.txt
+#
# Save the .zip cvs package
cd $TMPDIR
zip -rq $WEB/files/openemr-cvs.zip openemr
cd $WEB/files
md5sum openemr-cvs.zip > openemr-windows-md5.txt
+#
# Create the time stamp
date > date-cvs.txt
+#
# Clean up
rm -fr $TMPDIR
echo "Done creating OpenEMR CVS packages"
@@ -48,5 +48,5 @@ just installed it is very helpful.
Authors of debianized OpenEMR:
------------------------------
--- Brady Miller <brady@sparmy.com> Wed, 22 Sep 2010 22:16:23 -0700
--- Amalu Obinna <amaluobinna@aol.com> Wed, 22 Sep 2010 22:16:23 -0700
+-- Brady Miller <brady@sparmy.com> Mon, 04 Oct 2010 02:38:33 -0700
+-- Amalu Obinna <amaluobinna@aol.com> Mon, 04 Oct 2010 02:38:33 -0700
@@ -1,3 +1,9 @@
+cvs-openemr (1.0.0-6) stable; urgency=low
+
+ * start utilizing the InstallerAuto class
+
+ -- Brady Miller <brady@sparmy.com> Mon, 04 Oct 2010 02:38:33 -0700
+
cvs-openemr (1.0.0-5) stable; urgency=low
* change in directory architecture
@@ -1,5 +1,5 @@
Package: cvs-openemr
-Version: 1.0.0-4
+Version: 1.0.0-6
Maintainer: Brady Miller <brady@sparmy.com>
Installed-Size: 46000
Priority: optional
@@ -1,5 +1,5 @@
This package was debianized by Brady Miller <brady@sparmy.com> on
-Wed, 22 Sep 2010 22:16:23 -0700.
+Mon, 04 Oct 2010 02:38:33 -0700.
Upstream Author:
http://www.oemr.org
Oops, something went wrong.

0 comments on commit 7094eff

Please sign in to comment.