Mangled path fax send (#7515)
[openemr.git] / contrib / util / ubuntu_package_scripts / production / postinst
blobe7fee2dcec9cce2df1f96043cab8dd6f4cd91c68
1 #!/bin/bash -e
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 # Copyright 2011-2019
9 # authors: Amalu Obinna <amaluobinna@aol.com>
10 # Brady Miller <brady.g.miller@gmail.com>
12 # Debian package post installation script steps:
13 # 1) Collect setting from package configuration file
14 # 2) Install or Upgrade
15 # -Install
16 # a) Collect the MySQL root password (if possible)
17 # b) Ensure OpenEMR MySQL database and user do not exist. (if applicable)
18 # c) Configure OpenEMR (if applicable)
19 # d) Configure Apache
20 # e) Configure PHP
21 # -Upgrade
22 # a) Modify new OpenEMR version configuration files
23 # b) Upgrade MySQL database(s)
24 # c) Upgrade Access Controls
25 # d) Copy over old configuration files
26 # (Copy to files with .OLD extension to allow manual comparisons by user)
27 # 3) Modify permissions for writable directories
28 # 4) Secure the php installation/upgrading scripts (if applicable)
29 # 5) Modify the package configuration file
30 # 6) Display instructions on starting openemr
32 # summary of how this script can be called:
33 # * <postinst> `configure' <most-recently-configured-version>
34 # * <old-postinst> `abort-upgrade' <new version>
35 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
36 # <new-version>
37 # * <postinst> `abort-remove'
38 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
39 # <failed-install-package> <version> `removing'
40 # <conflicting-package> <version>
41 # for details, see http://www.debian.org/doc/debian-policy/ or
42 # the debian-policy package
44 # Source debconf library.
45 . /usr/share/debconf/confmodule
47 case "$1" in
48 configure)
50 #constants and paths
51 LOGDIR=/var/log/openemr
52 LOG=$LOGDIR/install
53 CONFIGDIR=/etc/openemr
54 CONFIG=$CONFIGDIR/openemr.conf
55 TMPDIR=/tmp/openemr-tmp
56 WEB=/var/www
57 OPENEMR=$WEB/openemr
58 SITEDIR=$OPENEMR/sites
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 #auto install scripts
64 INST=$OPENEMR/contrib/util/installScripts/InstallerAuto.php
65 INSTTEMP=$OPENEMR/contrib/util/installScripts/InstallerAutoTemp.php
66 #php and apache files
67 PHP=/etc/php5/apache2/php.ini
68 PHP_ALTERNATE=/etc/php/7.0/apache2/php.ini
69 #web user and group
70 WEB_GROUP=www-data
71 WEB_USER=www-data
73 #Standardized echo function to send to only log file
74 # requires one parameter (string)
75 log_only () {
76 echo "`date`: $1" >> $LOG
79 #Standardized exit functions to be used
80 # requires one parameter (string with reason for exiting)
81 unable_exit () {
82 echo "`date`: $1" >> $LOG
83 echo "`date`: EXITING.........." >> $LOG
84 exit 1
87 #function to check mysql for selected databases
88 # 1st param is password, 2nd param database, 3rd param is host (optional), 4th param is user (optional)
89 check_mysql () {
90 if [ -n "$3" ]; then
91 HOST=$3
92 else
93 HOST=localhost
95 if [ -n "$4" ]; then
96 USE=$4
97 else
98 USE=root
101 if [ "`mysql -u "$USE" -h "$HOST" --password="$1" -e 'show databases' 2>/dev/null | awk '{ print $1}' | grep "^$2$"`" == "$2" ]; then
102 return 0
103 else
104 return 1
108 #function to collect variables from config files
109 # 1st param is variable name, 2nd param is filename
110 collect_var () {
111 echo `grep -i "^[[:space:]]*$1[[:space:]=]" $2 | cut -d \= -f 2 | cut -d \; -f 1 | sed "s/[ '\"]//gi"`
114 #function to insert variables into config files
115 # 1st param is variable name, 2nd param is variable, 3rd param is filename
116 insert_var () {
117 sed -i 's@^[ ]*'"$1"'[ =].*$@'"$1"' = '"$2"'@' "$3"
120 #function to prompt for input
121 # 1st param is name, 2nd param is priority, 3rd param is where result gets sent back in
122 # return the input
123 prompt_input () {
124 db_set "$1" ""
125 db_fset "$1" seen false
126 db_input "$2" "$1" || true
127 db_go || true
128 db_get "$1"
129 local input_value="$RET"
130 db_set "$1" ""
131 db_fset "$1" seen false
132 local __result=$3
133 eval $__result="'$input_value'"
136 #collect scripting information from config file
137 PROCESS=$(collect_var process $CONFIG)
138 PLAN=$(collect_var plan $CONFIG)
140 #Don't allow re-configuration
141 if [ "$PROCESS" == "complete" ] ; then
142 unable_exit "OpenEMR has already been configured."
143 elif [ "$PROCESS" == "pending" ] ; then
144 #continue with configuration
145 log_only "Configuring package..."
146 else
147 unable_exit "Error reading process variable in configuration file."
150 if [ "$PLAN" == "upgrade" ] ; then
151 #continue with upgrade
152 OLD_VERSION=$(collect_var previous_version $CONFIG)
153 log_only "Continuing Upgrade from ($OLD_VERSION)"
155 #go to openemr directory
156 cd $OPENEMR
158 # NEED TO CONFIGURE APACHE BEFORE CONFIGURATION SINCE ZEND SUPPORT NEEDS PROPER CONFIGURATION
159 # Activate the OpenEMR conf file for apache
160 log_only "Activate OpenEMR config file for Apache"
161 a2ensite openemr.conf
162 # Ensure the apache rewrite module is turned on
163 a2enmod rewrite
164 # Restart the apache server
165 log_only "Restarting Apache service..."
166 invoke-rc.d apache2 restart >> $LOG 2>&1
168 #To support the multisite module, go through each site
169 for dir in $(find $SITEDIR/* -maxdepth 0 -type d ); do
170 #collect sitename
171 SITENAME=$(basename "$dir")
172 log_only "Configuring Site ($SITENAME)"
174 #collect more information from config file
175 SQLLOCATION=$(collect_var ${SITENAME}_sqllocation $CONFIG)
176 SQLUSER=$(collect_var ${SITENAME}_sqluser $CONFIG)
177 SQLPASSWORD=$(collect_var ${SITENAME}_sqlpassword $CONFIG)
178 SQLDATABASE=$(collect_var ${SITENAME}_sqldatabase $CONFIG)
179 SQLUTFFLAG=$(collect_var ${SITENAME}_sqlutfflag $CONFIG)
180 SQLENCODING=$(collect_var ${SITENAME}_sqlencoding $CONFIG)
182 #configure database configuration file
183 insert_var "\$host" "\'$SQLLOCATION\';" $SITEDIR/$SITENAME/sqlconf.php
184 insert_var "\$login" "\'$SQLUSER\';" $SITEDIR/$SITENAME/sqlconf.php
185 insert_var "\$pass" "\'$SQLPASSWORD\';" $SITEDIR/$SITENAME/sqlconf.php
186 insert_var "\$dbase" "\'$SQLDATABASE\';" $SITEDIR/$SITENAME/sqlconf.php
187 insert_var "\$disable_utf8_flag" "$SQLUTFFLAG;" $SITEDIR/$SITENAME/sqlconf.php
188 insert_var "\$db_encoding" "$SQLENCODING;" $SITEDIR/$SITENAME/sqlconf.php
189 sed -i "s/^[ ]*\$config[ =].*0/\$config = 1/" $SITEDIR/$SITENAME/sqlconf.php
191 #upgrade the sql database
192 CONC_VERSION=$(echo $OLD_VERSION | cut -d \- -f 1)
193 echo "<?php \$_GET['site'] = '$SITENAME'; ?>" > $OPENEMR/TEMPsql_upgrade.php
194 cat $OPENEMR/sql_upgrade.php >> $OPENEMR/TEMPsql_upgrade.php
195 sed -i "/input type='submit'/d" $OPENEMR/TEMPsql_upgrade.php
196 sed -i "s/!empty(\$_POST\['form_submit'\])/empty(\$_POST\['form_submit'\])/" $OPENEMR/TEMPsql_upgrade.php
197 sed -i "s/^[ ]*\$form_old_version[ =].*$/\$form_old_version = \"$CONC_VERSION\";/" $OPENEMR/TEMPsql_upgrade.php
198 php -f $OPENEMR/TEMPsql_upgrade.php >> $LOG 2>&1
199 rm -f $OPENEMR/TEMPsql_upgrade.php
201 #copy the old config file into new with the OLD at end to allow manual configuration of old
202 # optional settings.
203 if [ -d "$TMPDIR/openemr_web_$OLD_VERSION/sites/$SITENAME" ]; then
204 cp -f "$TMPDIR/openemr_web_$OLD_VERSION/sites/$SITENAME/config.php" "$SITEDIR/$SITENAME/config.php.OLD"
205 else
206 #need to move from old location, so sitename will always be default in this case
207 cp -f $TMPDIR/openemr_web_$OLD_VERSION/includes/config.php $SITEDIR/default/config.php.OLD
210 #log
211 log_only "Upgraded OpenEMR site ($SITENAME) with sql database ($SQLDATABASE) and sql user ($SQLUSER)."
213 done
215 # if site-specific directories are in the really old locations, move them.
216 if [ -d $OPENEMR/documents ]; then
217 if [ "$(ls $OPENEMR/documents)" ]; then
218 mv -f $OPENEMR/documents/* $SITEDIR/default/documents/
220 rm -rf $OPENEMR/documents
222 if [ -d $OPENEMR/era ]; then
223 if [ "$(ls $OPENEMR/era)" ]; then
224 mv -f $OPENEMR/era/* $SITEDIR/default/era/
226 rm -rf $OPENEMR/era
228 if [ -d $OPENEMR/edi ]; then
229 if [ "$(ls $OPENEMR/edi)" ]; then
230 mv -f $OPENEMR/edi/* $SITEDIR/default/edi/
232 rm -rf $OPENEMR/edi
234 if [ -d $OPENEMR/custom/letter_templates ]; then
235 if [ "$(ls $OPENEMR/custom/letter_templates)" ]; then
236 mv -f $OPENEMR/custom/letter_templates/* $SITEDIR/default/letter_templates/
238 rm -rf $OPENEMR/custom/letter_templates
241 # if site-specific directories are in the old locations, move them.
242 if [ -d $SITEDIR/$SITENAME/era ]; then
243 if [ "$(ls $SITEDIR/$SITENAME/era)" ]; then
244 mv -f $SITEDIR/$SITENAME/era/* $SITEDIR/$SITENAME/documents/era/
246 rm -rf $SITEDIR/$SITENAME/era
248 if [ -d $SITEDIR/$SITENAME/edi ]; then
249 if [ "$(ls $SITEDIR/$SITENAME/edi)" ]; then
250 mv -f $SITEDIR/$SITENAME/edi/* $SITEDIR/$SITENAME/documents/edi/
252 rm -rf $SITEDIR/$SITENAME/edi
254 if [ -d $SITEDIR/$SITENAME/letter_templates ]; then
255 if [ "$(ls $SITEDIR/$SITENAME/letter_templates)" ]; then
256 if [ -f $SITEDIR/$SITENAME/letter_templates/custom_pdf.php ]; then
257 mv -f $SITEDIR/$SITENAME/letter_templates/custom_pdf.php $SITEDIR/$SITENAME/
259 mv -f $SITEDIR/$SITENAME/letter_templates/* $SITEDIR/$SITENAME/documents/letter_templates/
261 rm -rf $SITEDIR/$SITENAME/letter_templates
263 if [ -d $SITEDIR/$SITENAME/procedure_results ]; then
264 if [ "$(ls $SITEDIR/$SITENAME/procedure_results)" ]; then
265 mv -f $SITEDIR/$SITENAME/procedure_results/* $SITEDIR/$SITENAME/documents/procedure_results/
267 rm -rf $SITEDIR/$SITENAME/procedure_results
270 #secure openemr
271 chown -Rf root:root $OPENEMR
272 chmod 600 $OPENEMR/acl_upgrade.php
273 chmod 600 $OPENEMR/setup.php
274 chmod 600 $OPENEMR/sql_upgrade.php
275 chmod 600 $OPENEMR/ippf_upgrade.php
277 #set writable directories (that are within sites directory)
278 # (go through each site)
279 for dir in $(find $SITEDIR/* -maxdepth 0 -type d ); do
280 #collect sitename
281 SITENAME=$(basename "$dir")
282 #set the writable directory
283 chown -R $WEB_GROUP.$WEB_USER $SITEDIR/$SITENAME/documents
284 done
286 #update config file, change process to complete and remove others
287 sed -i "s/^[ ]*process[ =].*$/process=complete/" $CONFIG
288 sed -i "/^[ ]*plan[ =].*$/d" $CONFIG
289 sed -i "/^[ ]*previous_version[ =].*$/d" $CONFIG
290 sed -i "/^[ ]*.*sqllocation[ =].*$/d" $CONFIG
291 sed -i "/^[ ]*.*sqluser[ =].*$/d" $CONFIG
292 sed -i "/^[ ]*.*sqlpassword[ =].*$/d" $CONFIG
293 sed -i "/^[ ]*.*sqldatabase[ =].*$/d" $CONFIG
294 sed -i "/^[ ]*.*sqlutfflag[ =].*$/d" $CONFIG
296 #done upgrading
297 prompt_input openemr/success_upgrade critical ret_result
298 log_only "OpenEMR upgrade is complete."
299 log_only "Recommend setting optional configuration settings in:"
300 log_only "$SITEDIR/<sitename>/config.php"
301 log_only "(We have renamed your old configuration files to *.OLD)"
302 log_only "(We recommend you delete the *.OLD files when done)"
303 log_only "We have placed backup of your old OpenEMR in $TMPDIR"
304 log_only "(We recommend you copy this somewhere protected since it"
305 log_only "contains confidential patient information)"
307 #stop db
308 db_stop
310 exit 0
312 elif [ "$PLAN" == "install" ] ; then
313 #continue with installation
314 log_only "Installing OpenEMR"
315 else
316 unable_exit "Error reading plan variable in configuration file."
319 #This Section edits the php.ini file to accomodate the proper functioning of OpenEMR using php
320 log_only "Configuring PHP for OpenEMR"
322 #check if PHP7 config file exists; if it does then use it.
323 if [ -f $PHP_ALTERNATE ]; then
324 PHP=$PHP_ALTERNATE
327 #check to ensure the php configuration file exists
328 if [ -f $PHP ]; then
329 # First, collect php variables
330 collect_php () {
331 echo `grep -i "^[[:space:]]*$1[[:space:]=]" $PHP | cut -d \= -f 2 | cut -d \; -f 1 | sed 's/[ M]//gi'`
333 collect_php_commented_out () {
334 echo `grep -i "^;[[:space:]]*$1[[:space:]=]" $PHP | cut -d \= -f 2 | cut -d \; -f 1 | sed 's/[ M]//gi'`
336 EXEC_TEXT="max_execution_time"
337 EXEC=$(collect_php "$EXEC_TEXT")
338 INPUT_TEXT="max_input_time"
339 INPUT=$(collect_php "$INPUT_TEXT")
340 MEM_TEXT="memory_limit"
341 MEM=$(collect_php "$MEM_TEXT")
342 DISP_TEXT="display_errors"
343 DISP=$(collect_php "$DISP_TEXT")
344 LOGG_TEXT="log_errors"
345 LOGG=$(collect_php "$LOGG_TEXT")
346 GLOB_TEXT="register_globals"
347 GLOB=$(collect_php "$GLOB_TEXT")
348 POST_TEXT="post_max_size"
349 POST=$(collect_php "$POST_TEXT")
350 UPLOAD_TEXT="file_uploads"
351 UPLOAD=$(collect_php "$UPLOAD_TEXT")
352 FILESIZE_TEXT="upload_max_filesize"
353 FILESIZE=$(collect_php "$FILESIZE_TEXT")
354 MAXINPUTVARS_TEXT="max_input_vars"
355 MAXINPUTVARS=$(collect_php "$MAXINPUTVARS_TEXT")
356 MAXINPUTVARS_IF_COMMENTED=$(collect_php_commented_out "$MAXINPUTVARS_TEXT")
357 ALLOWLOCALINFILE_TEXT="mysqli.allow_local_infile"
358 ALLOWLOCALINFILE=$(collect_php "$ALLOWLOCALINFILE_TEXT")
359 ALLOWLOCALINFILE_IF_COMMENTED=$(collect_php_commented_out "$ALLOWLOCALINFILE_TEXT")
361 # Second, backup the php.ini file before modifying
362 cp $PHP $PHP.BAK
364 # Third, edit the required entries
365 # Do this in a for loop.
366 # First iteration will discover the recommended changes
367 # Second iteration will make the changes (if user request this)
368 FLAG_ON=0
369 process_php () {
370 if [ "$3" -eq "1" ]; then
371 # make rec to php.ini
372 if [ "$FLAG_ON" -eq "0" ]; then
373 log_only "We changed the following setting(s) in your php configuration file at $PHP :"
375 FLAG_ON=1
376 else
377 # modify php.ini
378 sed -i "s/^[ ]*$1[ =].*$/$1 = $2/" $PHP
379 log_only "Successfully set $1 = $2"
382 process_php_commented_out () {
383 if [ "$3" -eq "1" ]; then
384 # make rec to php.ini
385 if [ "$FLAG_ON" -eq "0" ]; then
386 log_only "We changed the following setting(s) in your php configuration file at $PHP :"
388 FLAG_ON=1
389 else
390 # modify php.ini
391 sed -i "s/^;[ ]*$1[ =].*$/$1 = $2/" $PHP
392 log_only "Successfully set $1 = $2"
395 for i in `seq 1 2`; do
396 if [ ! -z "$EXEC" ] && [ "$EXEC" -lt "60" ]; then
397 process_php "$EXEC_TEXT" "60" $i
399 if [ ! -z "$INPUT" ] && [ "$INPUT" != "-1" ]; then
400 process_php "$INPUT_TEXT" "-1" $i
402 if [ ! -z "$MEM" ] && [ "$MEM" -lt "512" ]; then
403 process_php "$MEM_TEXT" "512M" $i
405 if [ ! -z "$DISP" ] && [ "$DISP" != "Off" ]; then
406 process_php "$DISP_TEXT" "Off" $i
408 if [ ! -z "$LOGG" ] && [ "$LOGG" != "On" ]; then
409 process_php "$LOGG_TEXT" "On" $i
411 if [ ! -z "$GLOB" ] && [ "$GLOB" != "Off" ]; then
412 process_php "$GLOB_TEXT" "Off" $i
414 if [ ! -z "$POST" ] && [ "$POST" -lt "30" ]; then
415 process_php "$POST_TEXT" "30M" $i
417 if [ ! -z "$UPLOAD" ] && [ "$UPLOAD" != "On" ]; then
418 process_php "$UPLOAD_TEXT" "On" $i
420 if [ ! -z "$FILESIZE" ] && [ "$FILESIZE" -lt "30" ]; then
421 process_php "$FILESIZE_TEXT" "30M" $i
423 if [ ! -z "$MAXINPUTVARS" ] && [ "$MAXINPUTVARS" -lt "3000" ]; then
424 process_php "$MAXINPUTVARS_TEXT" "3000" $i
426 if [ ! -z "$MAXINPUTVARS_IF_COMMENTED" ] && [ "$MAXINPUTVARS_IF_COMMENTED" -lt "3000" ]; then
427 process_php_commented_out "$MAXINPUTVARS_TEXT" "3000" $i
429 if [ ! -z "$ALLOWLOCALINFILE" ] && [ "$ALLOWLOCALINFILE" != "On" ]; then
430 process_php "$ALLOWLOCALINFILE_TEXT" "On" $i
432 if [ ! -z "$ALLOWLOCALINFILE_IF_COMMENTED" ] && [ "$ALLOWLOCALINFILE_IF_COMMENTED" != "On" ]; then
433 process_php_commented_out "$ALLOWLOCALINFILE_TEXT" "On" $i
435 if [ "$FLAG_ON" -eq "0" ]; then
436 log_only "Your PHP configuration is perfect for OpenEMR."
437 break
438 else
439 if [ "$i" -eq "1" ]; then
440 prompt_input openemr/php_configure high ret_result
443 if [ "$i" -eq "1" ]; then
444 log_only "(We have placed a backup of your php configuration at $PHP.BAK)"
446 done
447 else
448 #can't find php config file, so just echo instructions
449 log_only "We recommend ensuring you have below settings in your php configuration file:"
450 log_only "max_execution_time = 60"
451 log_only "max_input_time = -1"
452 log_only "memory_limit = 512M"
453 log_only "display_errors = Off"
454 log_only "log_errors = On"
455 log_only "register_globals = Off"
456 log_only "post_max_size = 30M"
457 log_only "file_uploads = On"
458 log_only "upload_max_filesize = 30M"
459 log_only "max_input_vars = 3000"
460 log_only "mysqli.allow_local_infile = On"
463 log_only "Done configuring PHP"
465 # NEED TO CONFIGURE APACHE BEFORE CONFIGURATION SINCE ZEND SUPPORT NEEDS PROPER CONFIGURATION
466 # Activate the OpenEMR conf file for apache
467 log_only "Activate OpenEMR config file for Apache"
468 a2ensite openemr.conf
469 # Ensure the apache rewrite module is turned on
470 a2enmod rewrite
471 # Restart the apache server
472 log_only "Restarting Apache service..."
473 invoke-rc.d apache2 restart >> $LOG 2>&1
475 #collect the mysql root password (if applicable)
476 MPASS=""
477 if check_mysql "$MPASS" "mysql"; then
478 log_only "Passed the mysql check loop"
479 else
480 #the blank initial mysql password didn't work, so prompt for password
481 # (will give 3 chances to provide correct password)
482 COUNTDOWN=1
483 while true; do
484 prompt_input openemr/mysql_p_install_${COUNTDOWN} critical ret_result
485 MPASS="$ret_result"
486 if check_mysql "$MPASS" "mysql"; then
487 #the mysql root password works, so can exit loop
488 log_only "Passed the mysql check loop"
489 break
490 else
491 #the mysql root password did not work
492 if [ "$COUNTDOWN" -ge "3" ]; then
493 prompt_input openemr/no_configure_mysql_root high ret_result
494 log_only "Will install OpenEMR, however will not configure OpenEMR. (unable to provide root password)"
495 break
498 let "COUNTDOWN += 1"
499 done
502 #decide whether to configure OpenEMR after it is installed
503 configure_flag=true
504 if check_mysql "$MPASS" "mysql"; then
505 #before auto configuration, ensure the openemr user and database do not exist
506 # Check for openemr database in mysql, if exist then will not configure
507 if check_mysql "$MPASS" "$INSTALL_DATABASE"; then
508 prompt_input openemr/no_configure_mysql_database high ret_result
509 log_only "Will install OpenEMR, however will not automatically configure OpenEMR. (MySQL database already exists)"
510 configure_flag=false;
512 # Check for OpenEMR user in mysql.user, if exist then will not configure
513 USER=$(mysql -s -u root -h localhost --password="$MPASS" -e "SELECT User from mysql.user where User='$INSTALL_USER'")
514 if [ "$USER" == "$INSTALL_USER" ]; then
515 prompt_input openemr/no_configure_mysql_user high ret_result
516 log_only "Will install OpenEMR, however will not automatically configure OpenEMR. (MySQL user already exists)"
517 configure_flag=false;
519 else
520 #the mysql root password didn't work, so do not configure OpenEMR
521 log_only "Will install OpenEMR, however will not automatically configure OpenEMR. (root password did not work)"
522 configure_flag=false;
525 #go to openemr directory
526 cd $OPENEMR
528 #secure openemr
529 chown -Rf root:root $OPENEMR
531 #INSTALL/CONFIGURE OPENEMR
532 # Install openemr
533 if $configure_flag; then
534 log_only "Installing/Configuring OpenEMR..."
535 else
536 log_only "Installing OpenEMR ..."
539 # Set file and directory permissions (note use default site directory for new install)
540 chmod 666 $SITEDIR/default/sqlconf.php
541 chown -R $WEB_GROUP.$WEB_USER $SITEDIR/default/documents
543 if $configure_flag; then
544 # Create a random password for the openemr mysql user
545 password=$(makepasswd --char=12)
547 # openemr installation VARIABLES
548 if [ "$MPASS" == "" ] ; then
549 rootpass="rootpass=BLANK" #MySQL server root password
550 else
551 rootpass="rootpass=$MPASS" #MySQL server root password
553 login="login=$INSTALL_USER" #username to MySQL openemr database
554 pass="pass=$password" #password to MySQL openemr database
555 dbname="dbname=$INSTALL_DATABASE" #MySQL openemr database name
558 # Run Auto Installer
560 sed -e 's@^exit;@ @' <$INST >$INSTTEMP
561 php -f $INSTTEMP $rootpass $login $pass $dbname >> $LOG 2>&1
562 rm -f $INSTTEMP
564 #remove global permission to all setup scripts
565 chmod 600 $OPENEMR/acl_upgrade.php
566 chmod 600 $OPENEMR/setup.php
567 chmod 600 $OPENEMR/sql_upgrade.php
568 chmod 600 $OPENEMR/ippf_upgrade.php
570 log_only "Done configuring OpenEMR"
573 if $configure_flag; then
574 prompt_input openemr/success_install_config high ret_result
575 log_only "You can now use OpenEMR by browsing to:"
576 log_only "http://localhost/openemr"
577 log_only "user is 'admin' and password is 'pass'"
578 log_only "See the openemr man page for further instructions:"
579 log_only "type 'man openemr' at command line"
580 else
581 prompt_input openemr/success_install high ret_result
582 log_only "You can now configure OpenEMR by browsing to:"
583 log_only "http://localhost/openemr"
584 log_only "See the openemr man page for further instructions:"
585 log_only "type 'man openemr' at command line"
588 #update config file, change process to complete and remove plan and pass
589 sed -i "s/^[ ]*process[ =].*$/process=complete/" $CONFIG
590 sed -i "/^[ ]*plan[ =].*$/d" $CONFIG
592 #stop db
593 db_stop
595 exit 0
597 abort-upgrade|abort-remove|abort-deconfigure)
599 echo "postinst asked to do $1"
600 exit 0
603 echo "postinst called with unknown argument \`$1'" >&2
604 exit 1
606 esac
608 sleep 5
609 exit 0