preparing for future 4.0.0 version
[openemr.git] / contrib / util / ubuntu_package_scripts / production / postinst
blob864ba76dc609a508c2a194578bf4b9b09630270b
1 #!/bin/bash
3 #This program is free software; you can redistribute it and/or modify
4 #it under the terms of the GNU General Public License as published by
5 #the Free Software Foundation; either version 2 of the License, or
6 #(at your option) any later version.
8 # authors: Amalu Obinna <amaluobinna@aol.com>
9 # Brady Miller <brady@sparmy.com>
11 # date: 05/15/09
13 # Debian package post installation script steps:
14 # 1) Collect setting from package configuration file
15 # 2) Install or Upgrade
16 # -Install
17 # a) Ensure OpenEMR MySQL database and user do not exist.
18 # b) If MySQL is already installed:
19 # -Collect the MySQL root password
20 # -ensure openemr mysql database/user does not exist
21 # c) Configure OpenEMR
22 # d) Configure Apache
23 # e) Configure PHP
24 # -Upgrade
25 # a) Modify new OpenEMR version configuration files
26 # b) Upgrade MySQL database
27 # c) Upgrade Access Controls
28 # d) Copy over old configuration files
29 # (Copy to files with .OLD extension to allow manual comparisons by user)
30 # e) Update PHP settings with new recommendations (not needed yet)
31 # f) Modify permissions for writable directories
32 # g) Secure the php installation/upgrading scripts
33 # 3) Modify the package configuration file
34 # 4) Echo instructions on starting openemr
36 # summary of how this script can be called:
37 # * <postinst> `configure' <most-recently-configured-version>
38 # * <old-postinst> `abort-upgrade' <new version>
39 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
40 # <new-version>
41 # * <postinst> `abort-remove'
42 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
43 # <failed-install-package> <version> `removing'
44 # <conflicting-package> <version>
45 # for details, see http://www.debian.org/doc/debian-policy/ or
46 # the debian-policy package
48 case "$1" in
49 configure)
51 #constants and paths
52 LOGDIR=/var/log/openemr
53 LOG=$LOGDIR/install
54 CONFIGDIR=/etc/openemr
55 CONFIG=$CONFIGDIR/openemr.conf
56 TMPDIR=/tmp/openemr-tmp
57 WEB=/var/www
58 OPENEMR=$WEB/openemr
59 #hardcoded mysql user and database for install (not pertinent for upgrading)
60 # upgrading can use whatever is found in openemr/library/sqlconf.php
61 INSTALL_USER=openemr
62 INSTALL_DATABASE=openemr
63 INSTALL_SITE=localhost
64 INSTALL_WEBPATH=/openemr
65 #php and apache files
66 PHP=/etc/php5/apache2/php.ini
67 APACHE=/etc/apache2/httpd.conf
68 #web user and group
69 WEB_GROUP=www-data
70 WEB_USER=www-data
72 #Standardized echo function to send to both echo and to log file
73 # requires one parameter (string)
74 output_both () {
75 echo $1
76 echo "`date`: $1" >> $LOG
79 #Standardized echo function to send to only log file
80 # requires one parameter (string)
81 log_only () {
82 echo "`date`: $1" >> $LOG
85 #Standardized exit functions to be used
86 # requires one parameter (string with reason for exiting)
87 unable_exit () {
88 echo $1
89 echo "`date`: $1" >> $LOG
90 echo "EXITING.........."
91 echo "`date`: EXITING.........." >> $LOG
92 sleep 5
93 exit 1
96 #function to check mysql for selected databases
97 # 1st param is password, 2nd param database, 3rd param is host (optional), 4th param is user (optional)
98 check_mysql () {
99 if [ -n "$3" ]; then
100 HOST=$3
101 else
102 HOST=localhost
104 if [ -n "$4" ]; then
105 USE=$4
106 else
107 USE=root
109 echo `mysql -u "$USE" -h "$HOST" --password="$1" -e 'show databases' 2>/dev/null | awk '{ print $1}' | grep "^$2$"`
112 #function to collect variables from config files
113 # 1st param is variable name, 2nd param is filename
114 collect_var () {
115 echo `grep -i "^[[:space:]]*$1[[:space:]=]" $2 | cut -d \= -f 2 | cut -d \; -f 1 | sed "s/[ '\"]//gi"`
118 #function to insert variables into config files
119 # 1st param is variable name, 2nd param is variable, 3rd param is filename
120 insert_var () {
121 sed -i 's@^[ ]*'"$1"'[ =].*$@'"$1"' = '"$2"'@' "$3"
124 #collect scripting information from config file
125 PROCESS=$(collect_var process $CONFIG)
126 PLAN=$(collect_var plan $CONFIG)
127 MPASS=$(collect_var pass $CONFIG)
129 #Don't allow re-configuration
130 if [ "$PROCESS" == "complete" ] ; then
131 unable_exit "OpenEMR has already been configured."
132 elif [ "$PROCESS" == "pending" ] ; then
133 #continue with configuration
134 log_only "Configuring package..."
135 else
136 unable_exit "Error reading process variable in configuration file."
139 if [ "$PLAN" == "upgrade" ] ; then
140 #continue with upgrade
142 #collect more information from config file
143 OLD_VERSION=$(collect_var previous_version $CONFIG)
144 SQLLOCATION=$(collect_var sqllocation $CONFIG)
145 SQLUSER=$(collect_var sqluser $CONFIG)
146 SQLPASSWORD=$(collect_var sqlpassword $CONFIG)
147 SQLDATABASE=$(collect_var sqldatabase $CONFIG)
148 SQLUTFFLAG=$(collect_var sqlutfflag $CONFIG)
150 #configure openemr/library/sqlconf.php
151 insert_var "\$host" "\'$SQLLOCATION\';" $OPENEMR/library/sqlconf.php
152 insert_var "\$login" "\'$SQLUSER\';" $OPENEMR/library/sqlconf.php
153 insert_var "\$pass" "\'$SQLPASSWORD\';" $OPENEMR/library/sqlconf.php
154 insert_var "\$dbase" "\'$SQLDATABASE\';" $OPENEMR/library/sqlconf.php
155 insert_var "\$disable_utf8_flag" "$SQLUTFFLAG;" $OPENEMR/library/sqlconf.php
156 sed -i "s/^[ ]*\$config[ =].*0/\$config = 1/" $OPENEMR/library/sqlconf.php
158 #before run scripts, go to openemr directory
159 cd $OPENEMR
161 #upgrade the sql database
162 CONC_VERSION=$(echo $OLD_VERSION | cut -d \- -f 1)
163 cp -f $OPENEMR/sql_upgrade.php $OPENEMR/TEMPsql_upgrade.php
164 sed -i "/input type='submit'/d" $OPENEMR/TEMPsql_upgrade.php
165 sed -i "s/!empty(\$_POST\['form_submit'\])/empty(\$_POST\['form_submit'\])/" $OPENEMR/TEMPsql_upgrade.php
166 sed -i "s/^[ ]*\$form_old_version[ =].*$/\$form_old_version = \"$CONC_VERSION\";/" $OPENEMR/TEMPsql_upgrade.php
167 php -f $OPENEMR/TEMPsql_upgrade.php >> $LOG
168 rm $OPENEMR/TEMPsql_upgrade.php
170 #upgrade the gacl controls
171 php -f $OPENEMR/acl_upgrade.php >> $LOG
173 #copy the old config files into new with the OLD at end to allow manual configuration of old
174 # optional settings. Two files, openemr/interface/globals.php and openemr/includes/config.php
175 cp -f $TMPDIR/openemr_web_$OLD_VERSION/interface/globals.php $OPENEMR/interface/globals.php.OLD
176 cp -f $TMPDIR/openemr_web_$OLD_VERSION/includes/config.php $OPENEMR/includes/config.php.OLD
178 #upgrade php settings if change or have new recs in future (none yet)
180 #secure openemr
181 chown -Rf root:root $OPENEMR
182 chmod 600 $OPENEMR/acl_setup.php
183 chmod 600 $OPENEMR/acl_upgrade.php
184 chmod 600 $OPENEMR/sl_convert.php
185 chmod 600 $OPENEMR/setup.php
186 chmod 600 $OPENEMR/sql_upgrade.php
187 chmod 600 $OPENEMR/ippf_upgrade.php
188 chmod 600 $OPENEMR/gacl/setup.php
190 #set writable directories
191 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/documents
192 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/edi
193 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/era
194 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/library/freeb
195 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/custom/letter_templates
196 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/interface/main/calendar/modules/PostCalendar/pntemplates/cache
197 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/interface/main/calendar/modules/PostCalendar/pntemplates/compiled
198 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/gacl/admin/templates_c
200 #update config file, change process to complete and remove others
201 sed -i "s/^[ ]*process[ =].*$/process=complete/" $CONFIG
202 sed -i "/^[ ]*plan[ =].*$/d" $CONFIG
203 sed -i "/^[ ]*pass[ =].*$/d" $CONFIG
204 sed -i "/^[ ]*previous_version[ =].*$/d" $CONFIG
205 sed -i "/^[ ]*sqllocation[ =].*$/d" $CONFIG
206 sed -i "/^[ ]*sqluser[ =].*$/d" $CONFIG
207 sed -i "/^[ ]*sqlpassword[ =].*$/d" $CONFIG
208 sed -i "/^[ ]*sqldatabase[ =].*$/d" $CONFIG
209 sed -i "/^[ ]*sqlutfflag[ =].*$/d" $CONFIG
211 #done upgrading
212 echo ""
213 echo "-----------------------------------------------------"
214 echo ""
215 output_both "OpenEMR upgrade is complete."
216 echo ""
217 output_both "Recommend setting optional configuration settings in:"
218 output_both "$OPENEMR/interface/globals.php"
219 output_both "$OPENEMR/includes/config.php"
220 output_both "(We have renamed your old configuration files to *.OLD)"
221 output_both "(We recommend you delete the *.OLD files when done)"
222 echo ""
223 output_both "We have placed backup of your old OpenEMR in $TMPDIR"
224 output_both "(We recommend you copy this somewhere protected since it"
225 output_both "contains confidential patient information)"
226 echo ""
227 echo "-----------------------------------------------------"
229 sleep 5
230 exit 0
232 elif [ "$PLAN" == "install" ] ; then
233 #continue with installation
234 log_only "Installing OpenEMR"
235 else
236 unable_exit "Error reading plan variable in configuration file."
239 ## BEGIN MYSQL ROOT PASSWORD GRAB
240 if [ "`check_mysql "$MPASS" "mysql"`" != "mysql" ]; then
241 #the initial mysql password didn't work, so ask for password
242 COUNTDOWN=1
243 while true; do
244 echo ""
245 echo -n "Please enter your MySQL root password:"
246 read MPASS
247 echo ""
248 if [ "`check_mysql "$MPASS" "mysql"`" == "mysql" ]; then
249 #the mysql root password works, so can exit loop
250 break
251 else
252 #the mysql root password did not work
253 if [ "$COUNTDOWN" -ge "5" ]; then
254 output_both "5 attempts to enter your mysql root password have failed"
255 output_both "Recommend repeating OpenEMR installation when you know your mysql root password"
256 unable_exit "Giving up on OpenEMR package installation."
258 echo "The entered MySQL root password did not work."
259 echo "$COUNTDOWN of 5 total attempts."
260 echo "PLEASE TRY AGAIN..."
262 let "COUNTDOWN += 1"
263 done
265 ## END MYSQL ROOT PASSWORD GRAB
267 #now ensure the openemr user and database do not exist, if so then exit
268 # Check for openemr database in mysql, if exist then exit
269 if [ "`check_mysql "$MPASS" "$INSTALL_DATABASE"`" == "$INSTALL_DATABASE" ]; then
270 unable_exit "MySQL '$INSTALL_DATABASE' database already exists"
272 # Check for OpenEMR user in mysql.user, if exist then exit
273 USER=$(mysql -s -u root -h localhost --password="$MPASS" -e "SELECT User from mysql.user where User='$INSTALL_USER'")
274 if [ "$USER" == "$INSTALL_USER" ]; then
275 unable_exit "MySQl user '$INSTALL_USER' already exists"
278 # Create a random password for the openemr mysql user
279 password=$(makepasswd --char=12)
281 # openemr installation VARIABLES
282 setHost="$INSTALL_SITE" #mysql server (if not different from php, then localhost)
283 setLoginhost="$INSTALL_SITE" #php/apache server (if not different from mysql, then localhost)
284 setPort="3306" #MySQL port
285 setDbname="$INSTALL_DATABASE" #MySQL openemr database name
286 setLogin="$INSTALL_USER" #username to MySQL openemr database
287 setPass="$password" #password to MySQL openemr database
288 setRoot="root" #MySQL server root username
289 setRootpass="$MPASS" #MySQL server root password
290 setColl="utf8_general_ci" #collation for mysql
291 setIuser="admin" #initial user login name
292 setIuname="Administrator" #initial user full name
293 setIgroup="Default" #practice group name
294 setInst="1" #CONSTANT, don't set
296 #go to openemr directory
297 cd $OPENEMR
299 #secure openemr
300 chown -Rf root:root $OPENEMR
302 #INSTALL AND CONFIGURE OPENEMR
303 output_both "Configuring OpenEMR"
304 # Set file and directory permissions
305 chmod 666 $OPENEMR/library/sqlconf.php
306 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/documents
307 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/edi
308 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/era
309 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/library/freeb
310 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/custom/letter_templates
311 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/interface/main/calendar/modules/PostCalendar/pntemplates/cache
312 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/interface/main/calendar/modules/PostCalendar/pntemplates/compiled
313 chown -R $WEB_GROUP.$WEB_USER $OPENEMR/gacl/admin/templates_c
315 # CONVERT setup.php file to script, then run it
317 cp -f $OPENEMR/setup.php $OPENEMR/TEMPsetup.php
318 # Set the path variable in setup.php
319 sed -e 's@\$manualPath = \"\"\;@\$manualPath = \"'$OPENEMR'\/\"\;@' <$OPENEMR/TEMPsetup.php >$OPENEMR/TEMP2setup.php
320 mv -f $OPENEMR/TEMP2setup.php $OPENEMR/TEMPsetup.php
321 # Set the variables in setup.php
322 sed -e 's@\/\/END POST VARIABLES@\
323 $host = '\'''$setHost''\'';\
324 $server = '\'''$setHost''\'';\
325 $port = '$setPort';\
326 $dbname = '\'''$setDbname''\'';\
327 $root = '\'''$setRoot''\'';\
328 $login = '\'''$setLogin''\'';\
329 $pass = '\'''$setPass''\'';\
330 $loginhost = '\'''$setLoginhost''\'';\
331 $rootpass = '\'''$setRootpass''\'';\
332 $iuser = '\'''$setIuser''\'';\
333 $iuname = '\'''$setIuname''\'';\
334 $igroup = '\'''$setIgroup''\'';\
335 $collate = '\'''$setColl''\'';\
336 $inst = 1;@' <$OPENEMR/TEMPsetup.php >$OPENEMR/TEMP2setup.php
337 mv -f $OPENEMR/TEMP2setup.php $OPENEMR/TEMPsetup.php
338 # Remove form functionality
339 sed -e 's@<INPUT TYPE='\''SUBMIT'\'' VALUE='\''Continue'\''>@ @' <$OPENEMR/TEMPsetup.php >$OPENEMR/TEMP2setup.php
340 mv -f $OPENEMR/TEMP2setup.php $OPENEMR/TEMPsetup.php
341 #prepare gacl/setup.php script
342 cp $OPENEMR/gacl/setup.php $OPENEMR/gacl/TEMP2setup.php
343 sed -e 's@.\/gacl\/gacl.ini.php@'$OPENEMR'\/gacl\/gacl.ini.php@' <$OPENEMR/gacl/setup.php >$OPENEMR/gacl/TEMPsetup.php
344 mv -f $OPENEMR/gacl/TEMPsetup.php $OPENEMR/gacl/setup.php
345 sed -e 's@.\/gacl\/admin\/gacl_admin.inc.php@'$OPENEMR'\/gacl\/admin\/gacl_admin.inc.php@' <$OPENEMR/gacl/setup.php >$OPENEMR/gacl/TEMPsetup.php
346 mv -f $OPENEMR/gacl/TEMPsetup.php $OPENEMR/gacl/setup.php
347 sed -e 's@.\/gacl\/schema.xml@'$OPENEMR'\/gacl\/schema.xml@' <$OPENEMR/gacl/setup.php >$OPENEMR/gacl/TEMPsetup.php
348 mv -f $OPENEMR/gacl/TEMPsetup.php $OPENEMR/gacl/setup.php
349 #prepare library/acl.inc script
350 cp $OPENEMR/library/acl.inc $OPENEMR/library/TEMP2acl.inc
351 sed -e 's@\$phpgacl_location = \"gacl\";@\$phpgacl_location = \"'$OPENEMR'\/gacl\";@' <$OPENEMR/library/acl.inc >$OPENEMR/library/TEMPacl.inc
352 mv -f $OPENEMR/library/TEMPacl.inc $OPENEMR/library/acl.inc
353 # (step 3) Set up OpenEMR and MySQL
354 sed -e 's@$state = $_POST\["state"\];@$state = 3;@' <$OPENEMR/TEMPsetup.php >$OPENEMR/TEMP2setup.php
355 mv -f $OPENEMR/TEMP2setup.php $OPENEMR/TEMPsetup.php
356 php -f $OPENEMR/TEMPsetup.php >> $LOG
357 # (step 4) Configure sqlconf.php file
358 sed -e 's@$state = 3;@$state = 4;@' <$OPENEMR/TEMPsetup.php >$OPENEMR/TEMP2setup.php
359 mv -f $OPENEMR/TEMP2setup.php $OPENEMR/TEMPsetup.php
360 php -f $OPENEMR/TEMPsetup.php >> $LOG
361 rm -f $OPENEMR/TEMPsetup.php
362 #replace original acl.inc and gacl/setup.php script
363 mv $OPENEMR/library/TEMP2acl.inc $OPENEMR/library/acl.inc
364 mv $OPENEMR/gacl/TEMP2setup.php $OPENEMR/gacl/setup.php
365 #remove global permission to all setup scripts
366 chmod 600 $OPENEMR/acl_setup.php
367 chmod 600 $OPENEMR/acl_upgrade.php
368 chmod 600 $OPENEMR/sl_convert.php
369 chmod 600 $OPENEMR/setup.php
370 chmod 600 $OPENEMR/sql_upgrade.php
371 chmod 600 $OPENEMR/ippf_upgrade.php
372 chmod 600 $OPENEMR/gacl/setup.php
374 log_only "Done configuring OpenEMR"
376 #This section configures Apache for OpenEMR
377 output_both "Configuring Apache for OpenEMR"
379 #Check to ensure the apache configuration files exists
380 if [ -f $APACHE ]; then
382 # First, backup the httpd.conf file before modifying
383 cp -f $APACHE $APACHE.BAK
385 # Second, append information to secure selected directories in OpenEMR
386 echo "#This is the start of the Apache configuration for OpenEMR." >> $APACHE
387 echo "#Below will secure directories with patient information." >> $APACHE
388 echo "<Directory \"/var/www/openemr/documents\">" >> $APACHE
389 echo " order deny,allow" >> $APACHE
390 echo " Deny from all" >> $APACHE
391 echo "</Directory>" >> $APACHE
392 echo "<Directory \"/var/www/openemr/edi\">" >> $APACHE
393 echo " order deny,allow" >> $APACHE
394 echo " Deny from all" >> $APACHE
395 echo "</Directory>" >> $APACHE
396 echo "<Directory \"/var/www/openemr/era\">" >> $APACHE
397 echo " order deny,allow" >> $APACHE
398 echo " Deny from all" >> $APACHE
399 echo "</Directory>" >> $APACHE
400 echo "#This is the end of the Apache configuration for OpenEMR." >> $APACHE
402 #let user know the plan
403 output_both "Added entries to apache configuration to secure directories with patient information."
404 output_both "Placed backup of your original apache configuration file to $APACHE.BAK"
406 else
407 #can't find apache config file, so just echo instructions
408 echo ""
409 output_both "We recommend placing below lines into your apache configuration file:"
410 output_both "#This is the start of the Apache configuration for OpenEMR."
411 output_both "#Below will secure directories with patient information."
412 output_both "<Directory \"/var/www/openemr/documents\">"
413 output_both " order deny,allow"
414 output_both " Deny from all"
415 output_both "</Directory>"
416 output_both "<Directory \"/var/www/openemr/edi\">"
417 output_both " order deny,allow"
418 output_both " Deny from all"
419 output_both "</Directory>"
420 output_both "<Directory \"/var/www/openemr/era\">"
421 output_both " order deny,allow"
422 output_both " Deny from all"
423 output_both "</Directory>"
424 output_both "#This is the end of the Apache configuration for OpenEMR."
425 echo ""
428 log_only "Done configuring Apache"
430 #This Section edits the php.ini file to accomodate the proper functioning of OpenEMR using php
431 output_both "Configuring PHP for OpenEMR"
433 #check to ensure the php configuration file exists
434 if [ -f $PHP ]; then
435 # First, collect php variables
436 collect_php () {
437 echo `grep -i "^[[:space:]]*$1[[:space:]=]" $PHP | cut -d \= -f 2 | cut -d \; -f 1 | sed 's/[ M]//gi'`
439 TAG_TEXT="short_open_tag"
440 TAG=$(collect_php "$TAG_TEXT")
441 EXEC_TEXT="max_execution_time"
442 EXEC=$(collect_php "$EXEC_TEXT")
443 INPUT_TEXT="max_input_time"
444 INPUT=$(collect_php "$INPUT_TEXT")
445 MEM_TEXT="memory_limit"
446 MEM=$(collect_php "$MEM_TEXT")
447 DISP_TEXT="display_errors"
448 DISP=$(collect_php "$DISP_TEXT")
449 LOGG_TEXT="log_errors"
450 LOGG=$(collect_php "$LOGG_TEXT")
451 GLOB_TEXT="register_globals"
452 GLOB=$(collect_php "$GLOB_TEXT")
453 POST_TEXT="post_max_size"
454 POST=$(collect_php "$POST_TEXT")
455 MAGIC_TEXT="magic_quotes_gpc"
456 MAGIC=$(collect_php "$MAGIC_TEXT")
457 UPLOAD_TEXT="file_uploads"
458 UPLOAD=$(collect_php "$UPLOAD_TEXT")
459 FILESIZE_TEXT="upload_max_filesize"
460 FILESIZE=$(collect_php "$FILESIZE_TEXT")
462 # Second, backup the php.ini file before modifying
463 cp $PHP $PHP.BAK
465 # Third, edit the required entries
466 # Do this in a for loop.
467 # First iteration will discover the recommended changes
468 # Second iteration will make the changes (if user request this)
469 FLAG_ON=0
470 process_php () {
471 if [ "$3" -eq "1" ]; then
472 # make rec to php.ini
473 if [ "$FLAG_ON" -eq "0" ]; then
474 output_both "We changed the following setting(s) in your php configuration file at $PHP :"
476 FLAG_ON=1
477 else
478 # modify php.ini
479 sed -i "s/^[ ]*$1[ =].*$/$1 = $2/" $PHP
480 output_both "Successfully set $1 = $2"
483 for i in `seq 1 2`; do
484 if [ "$TAG" != "On" ]; then
485 process_php "$TAG_TEXT" "On" $i
487 if [ "$EXEC" -lt "60" ]; then
488 process_php "$EXEC_TEXT" "60" $i
490 if [ "$INPUT" -lt "90" ]; then
491 process_php "$INPUT_TEXT" "90" $i
493 if [ "$MEM" -lt "128" ]; then
494 process_php "$MEM_TEXT" "128M" $i
496 if [ "$DISP" != "Off" ]; then
497 process_php "$DISP_TEXT" "Off" $i
499 if [ "$LOGG" != "On" ]; then
500 process_php "$LOGG_TEXT" "On" $i
502 if [ "$GLOB" != "Off" ]; then
503 process_php "$GLOB_TEXT" "Off" $i
505 if [ "$POST" -lt "30" ]; then
506 process_php "$POST_TEXT" "30M" $i
508 if [ "$MAGIC" != "On" ]; then
509 process_php "$MAGIC_TEXT" "On" $i
511 if [ "$UPLOAD" != "On" ]; then
512 process_php "$UPLOAD_TEXT" "On" $i
514 if [ "$FILESIZE" -lt "30" ]; then
515 process_php "$FILESIZE_TEXT" "30M" $i
517 if [ "$FLAG_ON" -eq "0" ]; then
518 output_both "Your PHP configuration is perfect for OpenEMR."
519 break
521 if [ "$i" -eq "1" ]; then
522 output_both "(We have placed a backup of your php configuration at $PHP.BAK)"
524 done
525 else
526 #can't find php config file, so just echo instructions
527 echo ""
528 output_both "We recommend ensuring you have below settings in your php configuration file:"
529 output_both "short_open_tag = On"
530 output_both "max_execution_time = 60"
531 output_both "max_input_time = 90"
532 output_both "memory_limit = 128M"
533 output_both "display_errors = Off"
534 output_both "log_errors = On"
535 output_both "register_globals = Off"
536 output_both "post_max_size = 30M"
537 output_both "magic_quotes_gpc = On"
538 output_both "file_uploads = On"
539 output_both "upload_max_filesize = 30M"
540 echo ""
543 log_only "Done configuring PHP"
545 output_both "Restarting Apache service"
546 invoke-rc.d apache2 restart >> $LOG
548 echo "--------------------------------------------------"
549 echo ""
550 output_both "You can now use OpenEMR by browsing to:"
551 output_both "http://localhost/openemr"
552 output_both "user is 'admin' and password is 'pass'"
553 echo ""
554 output_both "See the openemr man page for further instructions:"
555 output_both "type 'man openemr' at command line"
556 echo ""
557 echo "--------------------------------------------------"
559 #update config file, change process to complete and remove plan and pass
560 sed -i "s/^[ ]*process[ =].*$/process=complete/" $CONFIG
561 sed -i "/^[ ]*plan[ =].*$/d" $CONFIG
562 sed -i "/^[ ]*pass[ =].*$/d" $CONFIG
564 sleep 5
565 exit 0
567 abort-upgrade|abort-remove|abort-deconfigure)
569 echo "postinst asked to do $1"
570 exit 0
573 echo "postinst called with unknown argument \`$1'" >&2
574 exit 1
576 esac
578 sleep 5
579 exit 0