Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 59 additions & 41 deletions docker/openemr/7.0.3/openemr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,54 @@ set -e
# shellcheck source=SCRIPTDIR/utilities/devtoolsLibrary.source
. /root/devtoolsLibrary.source

swarm_wait() {
if [ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
# true
return 0
else
# false
return 1
fi
}
# defaults
: "${DEMO_MODE:=no}" \
"${DEVELOPER_TOOLS:=no}" \
"${EASY_DEV_MODE:=no}" \
"${EASY_DEV_MODE_NEW:=no}" \
"${EMPTY:=no}" \
"${FLEX_REPOSITORY_TAG:=}" \
"${FORCE_NO_BUILD_MODE:=no}" \
"${GITHUB_COMPOSER_TOKEN:=}" \
"${GITHUB_COMPOSER_TOKEN_ENCODED:=}" \
"${INSANE_DEV_MODE:=no}" \
"${K8S:=}" \
"${MANUAL_SETUP:=no}" \
"${PHPREDIS_BUILD:=}" \
"${REDIS_PASSWORD:=}" \
"${REDIS_SERVER:=}" \
"${REDIS_TLS:=}" \
"${REDIS_USERNAME:=}" \
"${REDIS_X509:=}" \
"${SWARM_MODE:=no}" \
"${XDEBUG_IDE_KEY:=}" \
"${XDEBUG_ON:=no}"

auto_setup() {
prepareVariables

find . -not -perm 600 -exec chmod 600 {} \+

#create temporary file cache directory for auto_configure.php to use
# create temporary file cache directory for auto_configure.php to use
TMP_FILE_CACHE_LOCATION="/tmp/php-file-cache"
mkdir ${TMP_FILE_CACHE_LOCATION}

#create auto_configure.ini to be able to leverage opcache for operations
touch auto_configure.ini
echo "opcache.enable=1" >> auto_configure.ini
echo "opcache.enable_cli=1" >> auto_configure.ini
echo "opcache.file_cache=${TMP_FILE_CACHE_LOCATION}" >> auto_configure.ini
echo "opcache.file_cache_only=1" >> auto_configure.ini
echo "opcache.file_cache_consistency_checks=1" >> auto_configure.ini
echo "opcache.enable_file_override=1" >> auto_configure.ini
echo "opcache.max_accelerated_files=1000000" >> auto_configure.ini
mkdir "${TMP_FILE_CACHE_LOCATION}"

# create auto_configure.ini to be able to leverage opcache for operations
{
echo "opcache.enable=1"
echo "opcache.enable_cli=1"
echo "opcache.file_cache=${TMP_FILE_CACHE_LOCATION}"
echo "opcache.file_cache_only=1"
echo "opcache.file_cache_consistency_checks=1"
echo "opcache.enable_file_override=1"
echo "opcache.max_accelerated_files=1000000"
} > auto_configure.ini

#run auto_configure
php auto_configure.php -c auto_configure.ini -f ${CONFIGURATION} || return 1
php auto_configure.php -c auto_configure.ini -f "${CONFIGURATION}" || return 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this require this change (both for 7.0.3 and 7.0.4) if not already there:

// Collect parameters(if exist) for installation configuration settings
for ($i=1; $i < count($argv); $i++) {
if ($argv[$i] == '-f' && isset($argv[$i+1])) {
// Handle case where a single string contains all parameters
$configString = $argv[$i+1];
$configPairs = preg_split('/\s+/', trim($configString));
foreach ($configPairs as $pair) {
if (strpos($pair, '=') !== false) {
list($index, $value) = explode('=', $pair, 2);
$installSettings[$index] = $value;
}
}
// Skip the next argument since we already processed it
$i++;
} else {
// Handle standard key=value parameters
$indexandvalue = explode("=", $argv[$i]);
$index = $indexandvalue[0];
$value = $indexandvalue[1] ?? '';
$installSettings[$index] = $value;
}
}


#remove temporary file cache directory and auto_configure.ini
rm -r ${TMP_FILE_CACHE_LOCATION}
rm -r "${TMP_FILE_CACHE_LOCATION}"
rm auto_configure.ini

echo "OpenEMR configured."
Expand All @@ -66,21 +80,21 @@ auto_setup() {
# - false for the Kubernetes startup job and manual image runs
AUTHORITY=yes
OPERATOR=yes
if [ "${K8S}" = "admin" ]; then
OPERATOR=no
elif [ "${K8S}" = "worker" ]; then
AUTHORITY=no
fi
case "${K8S}" in
admin) OPERATOR=no;;
worker) AUTHORITY=no;;
*) :;;
esac

if [ "${SWARM_MODE}" = "yes" ]; then
if [ "${SWARM_MODE}" = yes ]; then
# atomically test for leadership
set -o noclobber
{ > /var/www/localhost/htdocs/openemr/sites/docker-leader ; } &> /dev/null || AUTHORITY=no
{ : > /var/www/localhost/htdocs/openemr/sites/docker-leader ; } > /dev/null 2>&1 || AUTHORITY=no
set +o noclobber

if [ "${AUTHORITY}" = "no" ] &&
[ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
while swarm_wait; do
until [ -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; do
echo "Waiting for the docker-leader to finish configuration before proceeding."
sleep 10;
done
Expand Down Expand Up @@ -222,13 +236,16 @@ if [ "${AUTHORITY}" = "yes" ]; then
[ "${MANUAL_SETUP}" != "yes" ]; then

echo "Running quick setup!"
while ! auto_setup; do
set +e
# shellcheck disable=SC2310
until auto_setup; do
echo "Couldn't set up. Any of these reasons could be what's wrong:"
echo " - You didn't spin up a MySQL container or connect your OpenEMR container to a mysql instance"
echo " - MySQL is still starting up and wasn't ready for connection yet"
echo " - The Mysql credentials were incorrect"
sleep 1;
done
set -e
echo "Setup Complete!"
fi
fi
Expand All @@ -246,13 +263,13 @@ if
while [ "${c}" -le "${DOCKER_VERSION_ROOT}" ]; do
if [ "${c}" -gt "${DOCKER_VERSION_SITES}" ] ; then
echo "Start: Processing fsupgrade-${c}.sh upgrade script"
sh /root/fsupgrade-${c}.sh
sh "/root/fsupgrade-${c}.sh"
echo "Completed: Processing fsupgrade-${c}.sh upgrade script"
fi
c=$(( c + 1 ))
done
echo -n ${DOCKER_VERSION_ROOT} > /var/www/localhost/htdocs/openemr/sites/default/docker-version
echo "Completed upgrade"
printf '%s' "${DOCKER_VERSION_ROOT}" > /var/www/localhost/htdocs/openemr/sites/default/docker-version
echo 'Completed upgrade'
fi
fi

Expand Down Expand Up @@ -282,7 +299,8 @@ if [ "${REDIS_SERVER}" != "" ] &&
phpize83
# note for php 8.3, needed to change from './configure --enable-redis-igbinary' to:
./configure --with-php-config=/usr/bin/php-config83 --enable-redis-igbinary
make -j $(nproc --all)
num_procs=$(nproc --all)
make -j "${num_procs}"
make install
echo "extension=redis" > /etc/php83/conf.d/20_redis.ini
rm -fr /tmpredis/phpredis
Expand Down Expand Up @@ -333,7 +351,7 @@ fi

if
[ "${AUTHORITY}" = "yes" ] ||
[ "${SWARM_MODE}" = "yes" ]; then
[ "${SWARM_MODE}" = yes ]; then
if
[ "${CONFIG}" = "1" ] &&
[ "${MANUAL_SETUP}" != "yes" ]; then
Expand All @@ -355,7 +373,7 @@ if
# Set file and directory permissions
# Note this is only done once in swarm mode (to prevent breakage) since is a shared volume.
if
[ "${SWARM_MODE}" != "yes" ] ||
[ "${SWARM_MODE}" != yes ] ||
[ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
echo "Setting sites/default/documents permissions to 700"
find sites/default/documents -not -perm 700 -exec chmod 700 {} \+
Expand All @@ -377,7 +395,7 @@ fi

# Note this is only done once in swarm mode (to prevent breakage) since is a shared volume.
if
[ "${SWARM_MODE}" != "yes" ] ||
[ "${SWARM_MODE}" != yes ] ||
[ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
if [ -f /var/www/localhost/htdocs/openemr/sites/default/documents/certificates/mysql-ca ]; then
# for specific issue in docker and kubernetes that is required for successful openemr adodb/laminas connections
Expand Down Expand Up @@ -429,13 +447,13 @@ else
fi

if [ "${AUTHORITY}" = "yes" ] &&
[ "${SWARM_MODE}" = "yes" ]; then
[ "${SWARM_MODE}" = yes ]; then
# Set flag that the docker-leader configuration is complete
touch /var/www/localhost/htdocs/openemr/sites/docker-completed
rm -f /var/www/localhost/htdocs/openemr/sites/docker-leader
fi

if [ "${SWARM_MODE}" = "yes" ]; then
if [ "${SWARM_MODE}" = yes ]; then
# Set flag that the instance is ready when in swarm mode
echo
echo "swarm mode on: this instance is ready"
Expand Down
19 changes: 9 additions & 10 deletions docker/openemr/7.0.3/utilities/devtoolsLibrary.source
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ resetOpenemr() {
installOpenemr() {
echo "Re-installing OpenEMR"
cp /root/auto_configure.php /var/www/localhost/htdocs/
php /var/www/localhost/htdocs/auto_configure.php -f ${CONFIGURATION}
php /var/www/localhost/htdocs/auto_configure.php -f "${CONFIGURATION}"
rm -f /var/www/localhost/htdocs/auto_configure.php
}

Expand Down Expand Up @@ -259,21 +259,20 @@ generateMultisiteBank() {
# Activate older versions of InstallerAuto that require `sed` activation.
sed -i "s@exit;@//exit;@" /var/www/localhost/htdocs/openemr/contrib/util/installScripts/InstallerAuto.php
a=1
while [ ${a} -le "$1" ]
do
while [ "${a}" -le "$1" ]; do
run="run${a}"
echo "dropping ${run} sql database, sql user, and directory if they already exist (just ignore any errors that are displayed)"
mysql -u "${CUSTOM_ROOT_USER}" --password="${MYSQL_ROOT_PASS}" -h "${MYSQL_HOST}" -P "${CUSTOM_PORT}" -e "DROP DATABASE ${run}"
mysql -u "${CUSTOM_ROOT_USER}" --password="${MYSQL_ROOT_PASS}" -h "${MYSQL_HOST}" -P "${CUSTOM_PORT}" -e "DROP USER '${run}'"
rm -fr /var/www/localhost/htdocs/openemr/sites/${run}
rm -fr "/var/www/localhost/htdocs/openemr/sites/${run}"
rm /tmp/setup_dump.sql
echo "adding ${run} multisite"
php /var/www/localhost/htdocs/openemr/contrib/util/installScripts/InstallerAuto.php rootpass="${MYSQL_ROOT_PASS}" server="${MYSQL_HOST}" port="${CUSTOM_PORT}" loginhost=% login=${run} pass=${run} dbname=${run} site=${run} source_site_id=default clone_database=yes
chown -R apache /var/www/localhost/htdocs/openemr/sites/${run}
find /var/www/localhost/htdocs/openemr/sites/${run} -type d -print0 | xargs -0 chmod 500
find /var/www/localhost/htdocs/openemr/sites/${run} -type f -print0 | xargs -0 chmod 400
find /var/www/localhost/htdocs/openemr/sites/${run}/documents -type d -print0 | xargs -0 chmod 700
find /var/www/localhost/htdocs/openemr/sites/${run}/documents -type f -print0 | xargs -0 chmod 700
php /var/www/localhost/htdocs/openemr/contrib/util/installScripts/InstallerAuto.php rootpass="${MYSQL_ROOT_PASS}" server="${MYSQL_HOST}" port="${CUSTOM_PORT}" loginhost=% "login=${run}" "pass=${run}" "dbname=${run}" "site=${run}" source_site_id=default clone_database=yes
chown -R apache "/var/www/localhost/htdocs/openemr/sites/${run}"
find "/var/www/localhost/htdocs/openemr/sites/${run}" -type d -print0 | xargs -0 chmod 500
find "/var/www/localhost/htdocs/openemr/sites/${run}" -type f -print0 | xargs -0 chmod 400
find "/var/www/localhost/htdocs/openemr/sites/${run}/documents" -type d -print0 | xargs -0 chmod 700
find "/var/www/localhost/htdocs/openemr/sites/${run}/documents" -type f -print0 | xargs -0 chmod 700
echo "completed adding ${run} multisite"
a=$((a + 1))
done
Expand Down
18 changes: 9 additions & 9 deletions docker/openemr/7.0.4/utilities/devtoolsLibrary.source
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ resetOpenemr() {
installOpenemr() {
echo "Re-installing OpenEMR"
cp /root/auto_configure.php /var/www/localhost/htdocs/
php /var/www/localhost/htdocs/auto_configure.php -f ${CONFIGURATION}
php /var/www/localhost/htdocs/auto_configure.php -f "${CONFIGURATION}"
rm -f /var/www/localhost/htdocs/auto_configure.php
}

Expand Down Expand Up @@ -260,21 +260,21 @@ generateMultisiteBank() {
# Activate older versions of InstallerAuto that require `sed` activation.
sed -i "s@exit;@//exit;@" /var/www/localhost/htdocs/openemr/contrib/util/installScripts/InstallerAuto.php
a=1
while [ ${a} -le "$1" ]
while [ "${a}" -le "$1" ]
do
run="run${a}"
echo "dropping ${run} sql database, sql user, and directory if they already exist (just ignore any errors that are displayed)"
mariadb --skip-ssl -u "${CUSTOM_ROOT_USER}" --password="${MYSQL_ROOT_PASS}" -h "${MYSQL_HOST}" -P "${CUSTOM_PORT}" -e "DROP DATABASE ${run}"
mariadb --skip-ssl -u "${CUSTOM_ROOT_USER}" --password="${MYSQL_ROOT_PASS}" -h "${MYSQL_HOST}" -P "${CUSTOM_PORT}" -e "DROP USER '${run}'"
rm -fr /var/www/localhost/htdocs/openemr/sites/${run}
rm -fr "/var/www/localhost/htdocs/openemr/sites/${run}"
rm /tmp/setup_dump.sql
echo "adding ${run} multisite"
php /var/www/localhost/htdocs/openemr/contrib/util/installScripts/InstallerAuto.php rootpass="${MYSQL_ROOT_PASS}" server="${MYSQL_HOST}" port="${CUSTOM_PORT}" loginhost=% login=${run} pass=${run} dbname=${run} site=${run} source_site_id=default clone_database=yes
chown -R apache /var/www/localhost/htdocs/openemr/sites/${run}
find /var/www/localhost/htdocs/openemr/sites/${run} -type d -print0 | xargs -0 chmod 500
find /var/www/localhost/htdocs/openemr/sites/${run} -type f -print0 | xargs -0 chmod 400
find /var/www/localhost/htdocs/openemr/sites/${run}/documents -type d -print0 | xargs -0 chmod 700
find /var/www/localhost/htdocs/openemr/sites/${run}/documents -type f -print0 | xargs -0 chmod 700
php /var/www/localhost/htdocs/openemr/contrib/util/installScripts/InstallerAuto.php rootpass="${MYSQL_ROOT_PASS}" server="${MYSQL_HOST}" port="${CUSTOM_PORT}" loginhost=% "login=${run}" "pass=${run}" "dbname=${run}" "site=${run}" source_site_id=default clone_database=yes
chown -R apache "/var/www/localhost/htdocs/openemr/sites/${run}"
find "/var/www/localhost/htdocs/openemr/sites/${run}" -type d -print0 | xargs -0 chmod 500
find "/var/www/localhost/htdocs/openemr/sites/${run}" -type f -print0 | xargs -0 chmod 400
find "/var/www/localhost/htdocs/openemr/sites/${run}/documents" -type d -print0 | xargs -0 chmod 700
find "/var/www/localhost/htdocs/openemr/sites/${run}/documents" -type f -print0 | xargs -0 chmod 700
echo "completed adding ${run} multisite"
a=$((a + 1))
done
Expand Down
11 changes: 6 additions & 5 deletions docker/openemr/flex/openemr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ set -e
"${INSANE_DEV_MODE:=no}" \
"${K8S:=}" \
"${MANUAL_SETUP:=no}" \
"${PHP_VERSION_ABBR:=}" \
"${REDIS_PASSWORD:=}" \
"${REDIS_SERVER:=}" \
"${REDIS_USERNAME:=}" \
Expand Down Expand Up @@ -492,8 +493,8 @@ if [ "${REDIS_SERVER}" != "" ] &&
echo "redis setup"
fi

sed -i "[email protected]_handler = [email protected]_handler = redis@" /etc/php${PHP_VERSION_ABBR}/php.ini
sed -i 's@;session.save_path = "/tmp"@session.save_path = "'"${REDIS_PATH}"'"@"' /etc/php${PHP_VERSION_ABBR}/php.ini
sed -i "[email protected]_handler = [email protected]_handler = redis@" "/etc/php${PHP_VERSION_ABBR}/php.ini"
sed -i 's@;session.save_path = "/tmp"@session.save_path = "'"${REDIS_PATH}"'"@"' "/etc/php${PHP_VERSION_ABBR}/php.ini"
# Ensure only configure this one time
touch /etc/php-redis-configured
fi
Expand All @@ -503,14 +504,14 @@ if [ "${XDEBUG_IDE_KEY}" != "" ] ||
sh xdebug.sh
#also need to turn off opcache since it can not be turned on with xdebug
if [ ! -f /etc/php-opcache-jit-configured ]; then
echo "opcache.enable=0" >> /etc/php${PHP_VERSION_ABBR}/php.ini
echo "opcache.enable=0" >> "/etc/php${PHP_VERSION_ABBR}/php.ini"
touch /etc/php-opcache-jit-configured
fi
else
# Configure opcache jit if Xdebug is not being used (note opcache is already on, so just need to add setting(s) to php.ini that are different from the default setting(s))
if [ ! -f /etc/php-opcache-jit-configured ]; then
echo "opcache.jit=tracing" >> /etc/php${PHP_VERSION_ABBR}/php.ini
echo "opcache.jit_buffer_size=100M" >> /etc/php${PHP_VERSION_ABBR}/php.ini
echo "opcache.jit=tracing" >> "/etc/php${PHP_VERSION_ABBR}/php.ini"
echo "opcache.jit_buffer_size=100M" >> "/etc/php${PHP_VERSION_ABBR}/php.ini"
touch /etc/php-opcache-jit-configured
fi
fi
Expand Down
Loading
Loading