@@ -12,40 +12,54 @@ set -e
1212# shellcheck source=SCRIPTDIR/utilities/devtoolsLibrary.source
1313. /root/devtoolsLibrary.source
1414
15- swarm_wait () {
16- if [ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
17- # true
18- return 0
19- else
20- # false
21- return 1
22- fi
23- }
15+ # defaults
16+ : " ${DEMO_MODE:= no} " \
17+ " ${DEVELOPER_TOOLS:= no} " \
18+ " ${EASY_DEV_MODE:= no} " \
19+ " ${EASY_DEV_MODE_NEW:= no} " \
20+ " ${EMPTY:= no} " \
21+ " ${FLEX_REPOSITORY_TAG:= } " \
22+ " ${FORCE_NO_BUILD_MODE:= no} " \
23+ " ${GITHUB_COMPOSER_TOKEN:= } " \
24+ " ${GITHUB_COMPOSER_TOKEN_ENCODED:= } " \
25+ " ${INSANE_DEV_MODE:= no} " \
26+ " ${K8S:= } " \
27+ " ${MANUAL_SETUP:= no} " \
28+ " ${PHPREDIS_BUILD:= } " \
29+ " ${REDIS_PASSWORD:= } " \
30+ " ${REDIS_SERVER:= } " \
31+ " ${REDIS_TLS:= } " \
32+ " ${REDIS_USERNAME:= } " \
33+ " ${REDIS_X509:= } " \
34+ " ${SWARM_MODE:= no} " \
35+ " ${XDEBUG_IDE_KEY:= } " \
36+ " ${XDEBUG_ON:= no} "
2437
2538auto_setup () {
2639 prepareVariables
2740
2841 find . -not -perm 600 -exec chmod 600 {} \+
2942
30- # create temporary file cache directory for auto_configure.php to use
43+ # create temporary file cache directory for auto_configure.php to use
3144 TMP_FILE_CACHE_LOCATION=" /tmp/php-file-cache"
32- mkdir ${TMP_FILE_CACHE_LOCATION}
33-
34- # create auto_configure.ini to be able to leverage opcache for operations
35- touch auto_configure.ini
36- echo " opcache.enable=1" >> auto_configure.ini
37- echo " opcache.enable_cli=1" >> auto_configure.ini
38- echo " opcache.file_cache=${TMP_FILE_CACHE_LOCATION} " >> auto_configure.ini
39- echo " opcache.file_cache_only=1" >> auto_configure.ini
40- echo " opcache.file_cache_consistency_checks=1" >> auto_configure.ini
41- echo " opcache.enable_file_override=1" >> auto_configure.ini
42- echo " opcache.max_accelerated_files=1000000" >> auto_configure.ini
45+ mkdir " ${TMP_FILE_CACHE_LOCATION} "
46+
47+ # create auto_configure.ini to be able to leverage opcache for operations
48+ {
49+ echo " opcache.enable=1"
50+ echo " opcache.enable_cli=1"
51+ echo " opcache.file_cache=${TMP_FILE_CACHE_LOCATION} "
52+ echo " opcache.file_cache_only=1"
53+ echo " opcache.file_cache_consistency_checks=1"
54+ echo " opcache.enable_file_override=1"
55+ echo " opcache.max_accelerated_files=1000000"
56+ } > auto_configure.ini
4357
4458 # run auto_configure
45- php auto_configure.php -c auto_configure.ini -f ${CONFIGURATION} || return 1
59+ php auto_configure.php -c auto_configure.ini -f " ${CONFIGURATION} " || return 1
4660
4761 # remove temporary file cache directory and auto_configure.ini
48- rm -r ${TMP_FILE_CACHE_LOCATION}
62+ rm -r " ${TMP_FILE_CACHE_LOCATION} "
4963 rm auto_configure.ini
5064
5165 echo " OpenEMR configured."
@@ -66,21 +80,21 @@ auto_setup() {
6680# - false for the Kubernetes startup job and manual image runs
6781AUTHORITY=yes
6882OPERATOR=yes
69- if [ " ${K8S} " = " admin " ] ; then
70- OPERATOR=no
71- elif [ " ${K8S} " = " worker" ] ; then
72- AUTHORITY=no
73- fi
83+ case " ${K8S} " in
84+ admin) OPERATOR=no;;
85+ worker) AUTHORITY=no;;
86+ * ) : ;;
87+ esac
7488
75- if [ " ${SWARM_MODE} " = " yes" ]; then
89+ if [ " ${SWARM_MODE} " = yes ]; then
7690 # atomically test for leadership
7791 set -o noclobber
78- { > /var/www/localhost/htdocs/openemr/sites/docker-leader ; } & > /dev/null || AUTHORITY=no
92+ { : > /var/www/localhost/htdocs/openemr/sites/docker-leader ; } > /dev/null 2>&1 || AUTHORITY=no
7993 set +o noclobber
8094
8195 if [ " ${AUTHORITY} " = " no" ] &&
8296 [ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
83- while swarm_wait ; do
97+ until [ -f /var/www/localhost/htdocs/openemr/sites/docker-completed ] ; do
8498 echo " Waiting for the docker-leader to finish configuration before proceeding."
8599 sleep 10;
86100 done
@@ -222,13 +236,16 @@ if [ "${AUTHORITY}" = "yes" ]; then
222236 [ " ${MANUAL_SETUP} " != " yes" ]; then
223237
224238 echo " Running quick setup!"
225- while ! auto_setup; do
239+ set +e
240+ # shellcheck disable=SC2310
241+ until auto_setup; do
226242 echo " Couldn't set up. Any of these reasons could be what's wrong:"
227243 echo " - You didn't spin up a MySQL container or connect your OpenEMR container to a mysql instance"
228244 echo " - MySQL is still starting up and wasn't ready for connection yet"
229245 echo " - The Mysql credentials were incorrect"
230246 sleep 1;
231247 done
248+ set -e
232249 echo " Setup Complete!"
233250 fi
234251fi
246263 while [ " ${c} " -le " ${DOCKER_VERSION_ROOT} " ]; do
247264 if [ " ${c} " -gt " ${DOCKER_VERSION_SITES} " ] ; then
248265 echo " Start: Processing fsupgrade-${c} .sh upgrade script"
249- sh /root/fsupgrade-${c} .sh
266+ sh " /root/fsupgrade-${c} .sh"
250267 echo " Completed: Processing fsupgrade-${c} .sh upgrade script"
251268 fi
252269 c=$(( c + 1 ))
253270 done
254- echo -n ${DOCKER_VERSION_ROOT} > /var/www/localhost/htdocs/openemr/sites/default/docker-version
255- echo " Completed upgrade"
271+ printf ' %s ' " ${DOCKER_VERSION_ROOT} " > /var/www/localhost/htdocs/openemr/sites/default/docker-version
272+ echo ' Completed upgrade'
256273 fi
257274fi
258275
@@ -282,7 +299,8 @@ if [ "${REDIS_SERVER}" != "" ] &&
282299 phpize83
283300 # note for php 8.3, needed to change from './configure --enable-redis-igbinary' to:
284301 ./configure --with-php-config=/usr/bin/php-config83 --enable-redis-igbinary
285- make -j $( nproc --all)
302+ num_procs=$( nproc --all)
303+ make -j " ${num_procs} "
286304 make install
287305 echo " extension=redis" > /etc/php83/conf.d/20_redis.ini
288306 rm -fr /tmpredis/phpredis
333351
334352if
335353 [ " ${AUTHORITY} " = " yes" ] ||
336- [ " ${SWARM_MODE} " = " yes" ]; then
354+ [ " ${SWARM_MODE} " = yes ]; then
337355 if
338356 [ " ${CONFIG} " = " 1" ] &&
339357 [ " ${MANUAL_SETUP} " != " yes" ]; then
355373 # Set file and directory permissions
356374 # Note this is only done once in swarm mode (to prevent breakage) since is a shared volume.
357375 if
358- [ " ${SWARM_MODE} " != " yes" ] ||
376+ [ " ${SWARM_MODE} " != yes ] ||
359377 [ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
360378 echo " Setting sites/default/documents permissions to 700"
361379 find sites/default/documents -not -perm 700 -exec chmod 700 {} \+
377395
378396# Note this is only done once in swarm mode (to prevent breakage) since is a shared volume.
379397if
380- [ " ${SWARM_MODE} " != " yes" ] ||
398+ [ " ${SWARM_MODE} " != yes ] ||
381399 [ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
382400 if [ -f /var/www/localhost/htdocs/openemr/sites/default/documents/certificates/mysql-ca ]; then
383401 # for specific issue in docker and kubernetes that is required for successful openemr adodb/laminas connections
@@ -429,13 +447,13 @@ else
429447fi
430448
431449if [ " ${AUTHORITY} " = " yes" ] &&
432- [ " ${SWARM_MODE} " = " yes" ]; then
450+ [ " ${SWARM_MODE} " = yes ]; then
433451 # Set flag that the docker-leader configuration is complete
434452 touch /var/www/localhost/htdocs/openemr/sites/docker-completed
435453 rm -f /var/www/localhost/htdocs/openemr/sites/docker-leader
436454fi
437455
438- if [ " ${SWARM_MODE} " = " yes" ]; then
456+ if [ " ${SWARM_MODE} " = yes ]; then
439457 # Set flag that the instance is ready when in swarm mode
440458 echo
441459 echo " swarm mode on: this instance is ready"
0 commit comments