Skip to content

Commit

Permalink
fix reversion for k8s empty volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
jesdynf committed Jan 3, 2023
1 parent 88ab53b commit 2e1a16e
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 105 deletions.
43 changes: 20 additions & 23 deletions docker/openemr/7.0.0/openemr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set -e
source /root/devtoolsLibrary.source

swarm_wait() {
if [ ! -f /var/www/localhost/htdocs/openemr/sites/default/docker-completed ]; then
if [ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
# true
return 0
else
Expand Down Expand Up @@ -50,38 +50,34 @@ if [ "$K8S" == "admin" ]; then
elif [ "$K8S" == "worker" ]; then
AUTHORITY=no
fi

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

if [ "$AUTHORITY" == "yes" ]; then
touch /var/www/localhost/htdocs/openemr/sites/default/docker-initiated
fi
fi

if [ "$SWARM_MODE" == "yes" ]; then
# Check if the shared volumes have been emptied out (persistent volumes in
# kubernetes seems to do this). If they have been emptied, then restore them.
if [ ! -f /etc/ssl/openssl.cnf ]; then
# Restore the emptied /etc/ssl directory
echo "Restoring empty /etc/ssl directory."
rsync --owner --group --perms --recursive --links /swarm-pieces/ssl /etc/
fi
if [ ! -d /var/www/localhost/htdocs/openemr/sites/default ]; then
# Restore the emptied /var/www/localhost/htdocs/openemr/sites directory
echo "Restoring empty /var/www/localhost/htdocs/openemr/sites directory."
rsync --owner --group --perms --recursive --links /swarm-pieces/sites /var/www/localhost/htdocs/openemr/
fi

if [ "$AUTHORITY" == "no" ] &&
[ ! -f /var/www/localhost/htdocs/openemr/sites/default/docker-completed ]; then
[ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
while swarm_wait; do
echo "Waiting for the docker-leader to finish configuration before proceeding."
sleep 10;
done
fi

if [ "$AUTHORITY" == "yes" ]; then
touch /var/www/localhost/htdocs/openemr/sites/docker-initiated
if [ ! -f /etc/ssl/openssl.cnf ]; then
# Restore the emptied /etc/ssl directory
echo "Restoring empty /etc/ssl directory."
rsync --owner --group --perms --recursive --links /swarm-pieces/ssl /etc/
fi
if [ ! -d /var/www/localhost/htdocs/openemr/sites/default ]; then
# Restore the emptied /var/www/localhost/htdocs/openemr/sites directory
echo "Restoring empty /var/www/localhost/htdocs/openemr/sites directory."
rsync --owner --group --perms --recursive --links /swarm-pieces/sites /var/www/localhost/htdocs/openemr/
fi
fi
fi

if [ "$AUTHORITY" == "yes" ]; then
Expand Down Expand Up @@ -194,7 +190,8 @@ fi
if [ "$AUTHORITY" == "yes" ] &&
[ "$SWARM_MODE" == "yes" ]; then
# Set flag that the docker-leader configuration is complete
touch /var/www/localhost/htdocs/openemr/sites/default/docker-completed
touch /var/www/localhost/htdocs/openemr/sites/docker-completed
rm -f /var/www/localhost/htdocs/openemr/sites/docker-leader
fi

if [ "$REDIS_SERVER" != "" ] &&
Expand Down
43 changes: 20 additions & 23 deletions docker/openemr/7.0.1/openemr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set -e
source /root/devtoolsLibrary.source

swarm_wait() {
if [ ! -f /var/www/localhost/htdocs/openemr/sites/default/docker-completed ]; then
if [ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
# true
return 0
else
Expand Down Expand Up @@ -50,38 +50,34 @@ if [ "$K8S" == "admin" ]; then
elif [ "$K8S" == "worker" ]; then
AUTHORITY=no
fi

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

if [ "$AUTHORITY" == "yes" ]; then
touch /var/www/localhost/htdocs/openemr/sites/default/docker-initiated
fi
fi

if [ "$SWARM_MODE" == "yes" ]; then
# Check if the shared volumes have been emptied out (persistent volumes in
# kubernetes seems to do this). If they have been emptied, then restore them.
if [ ! -f /etc/ssl/openssl.cnf ]; then
# Restore the emptied /etc/ssl directory
echo "Restoring empty /etc/ssl directory."
rsync --owner --group --perms --recursive --links /swarm-pieces/ssl /etc/
fi
if [ ! -d /var/www/localhost/htdocs/openemr/sites/default ]; then
# Restore the emptied /var/www/localhost/htdocs/openemr/sites directory
echo "Restoring empty /var/www/localhost/htdocs/openemr/sites directory."
rsync --owner --group --perms --recursive --links /swarm-pieces/sites /var/www/localhost/htdocs/openemr/
fi

if [ "$AUTHORITY" == "no" ] &&
[ ! -f /var/www/localhost/htdocs/openemr/sites/default/docker-completed ]; then
[ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
while swarm_wait; do
echo "Waiting for the docker-leader to finish configuration before proceeding."
sleep 10;
done
fi

if [ "$AUTHORITY" == "yes" ]; then
touch /var/www/localhost/htdocs/openemr/sites/docker-initiated
if [ ! -f /etc/ssl/openssl.cnf ]; then
# Restore the emptied /etc/ssl directory
echo "Restoring empty /etc/ssl directory."
rsync --owner --group --perms --recursive --links /swarm-pieces/ssl /etc/
fi
if [ ! -d /var/www/localhost/htdocs/openemr/sites/default ]; then
# Restore the emptied /var/www/localhost/htdocs/openemr/sites directory
echo "Restoring empty /var/www/localhost/htdocs/openemr/sites directory."
rsync --owner --group --perms --recursive --links /swarm-pieces/sites /var/www/localhost/htdocs/openemr/
fi
fi
fi

if [ "$AUTHORITY" == "yes" ]; then
Expand Down Expand Up @@ -194,7 +190,8 @@ fi
if [ "$AUTHORITY" == "yes" ] &&
[ "$SWARM_MODE" == "yes" ]; then
# Set flag that the docker-leader configuration is complete
touch /var/www/localhost/htdocs/openemr/sites/default/docker-completed
touch /var/www/localhost/htdocs/openemr/sites/docker-completed
rm -f /var/www/localhost/htdocs/openemr/sites/docker-leader
fi

if [ "$REDIS_SERVER" != "" ] &&
Expand Down
43 changes: 22 additions & 21 deletions docker/openemr/flex-3.15-8/openemr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set -e
source /root/devtoolsLibrary.source

swarm_wait() {
if [ ! -f /var/www/localhost/htdocs/openemr/sites/default/docker-completed ]; then
if [ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
# true
return 0
else
Expand Down Expand Up @@ -71,33 +71,34 @@ if [ "$K8S" == "admin" ]; then
elif [ "$K8S" == "worker" ]; then
AUTHORITY=no
fi

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

if [ "$AUTHORITY" == "yes" ]; then
touch /var/www/localhost/htdocs/openemr/sites/default/docker-initiated
fi
fi

if [ "$SWARM_MODE" == "yes" ]; then
# Check if the shared volumes have been emptied out (persistent volumes in
# kubernetes seems to do this). If they have been emptied, then restore them.
if [ ! -f /etc/ssl/openssl.cnf ]; then
# Restore the emptied /etc/ssl directory
echo "Restoring empty /etc/ssl directory."
rsync --owner --group --perms --recursive --links /swarm-pieces/ssl /etc/
fi
mkdir -p /var/www/localhost/htdocs/openemr/sites/default
if [ "$AUTHORITY" == "no" ] &&
[ ! -f /var/www/localhost/htdocs/openemr/sites/default/docker-completed ]; then
[ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
while swarm_wait; do
echo "Waiting for the docker-leader to finish configuration before proceeding."
sleep 10;
done
fi

if [ "$AUTHORITY" == "yes" ]; then
touch /var/www/localhost/htdocs/openemr/sites/docker-initiated
if [ ! -f /etc/ssl/openssl.cnf ]; then
# Restore the emptied /etc/ssl directory
echo "Restoring empty /etc/ssl directory."
rsync --owner --group --perms --recursive --links /swarm-pieces/ssl /etc/
fi
if [ ! -d /var/www/localhost/htdocs/openemr/sites/default ]; then
# Restore the emptied /var/www/localhost/htdocs/openemr/sites directory
echo "Restoring empty /var/www/localhost/htdocs/openemr/sites directory."
rsync --owner --group --perms --recursive --links /swarm-pieces/sites /var/www/localhost/htdocs/openemr/
fi
fi
fi

if [ "$AUTHORITY" == "yes" ]; then
Expand Down Expand Up @@ -131,11 +132,11 @@ if [ -f /var/www/localhost/htdocs/auto_configure.php ] &&
git checkout "$FLEX_REPOSITORY_TAG"
cd ../
fi
if [ -f /etc/docker-leader ] &&
if [ "$AUTHORITY" == "yes" ] &&
[ "$SWARM_MODE" == "yes" ]; then
touch openemr/sites/default/docker-initiated
fi
if [ ! -f /etc/docker-leader ] &&
if [ "$AUTHORITY" == "no" ] &&
[ "$SWARM_MODE" == "yes" ]; then
# non-leader is building so remove the openemr/sites directory to avoid breaking anything in leader's build
rm -fr openemr/sites
Expand Down Expand Up @@ -257,7 +258,7 @@ if [ -f /var/www/localhost/htdocs/auto_configure.php ] &&
cd /var/www/localhost/htdocs
fi

if [ -f /etc/docker-leader ] ||
if [ "$AUTHORITY" == "yes" ] ||
[ "$SWARM_MODE" != "yes" ]; then
if [ -f /var/www/localhost/htdocs/auto_configure.php ] &&
[ "$EASY_DEV_MODE" != "yes" ]; then
Expand Down Expand Up @@ -347,7 +348,7 @@ if [ -f /var/www/localhost/htdocs/auto_configure.php ]; then
fi
fi

if [ -f /etc/docker-leader ] &&
if [ "$AUTHORITY" == "yes" ] &&
[ "$SWARM_MODE" == "yes" ] &&
[ -f /var/www/localhost/htdocs/auto_configure.php ]; then
# Set flag that the docker-leader configuration is complete
Expand Down
39 changes: 20 additions & 19 deletions docker/openemr/flex-3.17/openemr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set -e
source /root/devtoolsLibrary.source

swarm_wait() {
if [ ! -f /var/www/localhost/htdocs/openemr/sites/default/docker-completed ]; then
if [ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
# true
return 0
else
Expand Down Expand Up @@ -71,32 +71,33 @@ if [ "$K8S" == "admin" ]; then
elif [ "$K8S" == "worker" ]; then
AUTHORITY=no
fi

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

if [ "$AUTHORITY" == "yes" ]; then
touch /var/www/localhost/htdocs/openemr/sites/default/docker-initiated
fi
if [ "$AUTHORITY" == "no" ] &&
[ ! -f /var/www/localhost/htdocs/openemr/sites/docker-completed ]; then
while swarm_wait; do
echo "Waiting for the docker-leader to finish configuration before proceeding."
sleep 10;
done
fi

if [ "$SWARM_MODE" == "yes" ]; then
# Check if the shared volumes have been emptied out (persistent volumes in
# kubernetes seems to do this). If they have been emptied, then restore them.
if [ "$AUTHORITY" == "yes" ]; then
touch /var/www/localhost/htdocs/openemr/sites/docker-initiated
if [ ! -f /etc/ssl/openssl.cnf ]; then
# Restore the emptied /etc/ssl directory
echo "Restoring empty /etc/ssl directory."
rsync --owner --group --perms --recursive --links /swarm-pieces/ssl /etc/
fi
mkdir -p /var/www/localhost/htdocs/openemr/sites/default
if [ "$AUTHORITY" == "no" ] &&
[ ! -f /var/www/localhost/htdocs/openemr/sites/default/docker-completed ]; then
while swarm_wait; do
echo "Waiting for the docker-leader to finish configuration before proceeding."
sleep 10;
done
if [ ! -d /var/www/localhost/htdocs/openemr/sites/default ]; then
# Restore the emptied /var/www/localhost/htdocs/openemr/sites directory
echo "Restoring empty /var/www/localhost/htdocs/openemr/sites directory."
rsync --owner --group --perms --recursive --links /swarm-pieces/sites /var/www/localhost/htdocs/openemr/
fi
fi
fi

Expand Down Expand Up @@ -131,11 +132,11 @@ if [ -f /var/www/localhost/htdocs/auto_configure.php ] &&
git checkout "$FLEX_REPOSITORY_TAG"
cd ../
fi
if [ -f /etc/docker-leader ] &&
if [ "$AUTHORITY" == "yes" ] &&
[ "$SWARM_MODE" == "yes" ]; then
touch openemr/sites/default/docker-initiated
fi
if [ ! -f /etc/docker-leader ] &&
if [ "$AUTHORITY" == "no" ] &&
[ "$SWARM_MODE" == "yes" ]; then
# non-leader is building so remove the openemr/sites directory to avoid breaking anything in leader's build
rm -fr openemr/sites
Expand Down Expand Up @@ -257,7 +258,7 @@ if [ -f /var/www/localhost/htdocs/auto_configure.php ] &&
cd /var/www/localhost/htdocs
fi

if [ -f /etc/docker-leader ] ||
if [ "$AUTHORITY" == "yes" ] ||
[ "$SWARM_MODE" != "yes" ]; then
if [ -f /var/www/localhost/htdocs/auto_configure.php ] &&
[ "$EASY_DEV_MODE" != "yes" ]; then
Expand Down Expand Up @@ -347,7 +348,7 @@ if [ -f /var/www/localhost/htdocs/auto_configure.php ]; then
fi
fi

if [ -f /etc/docker-leader ] &&
if [ "$AUTHORITY" == "yes" ] &&
[ "$SWARM_MODE" == "yes" ] &&
[ -f /var/www/localhost/htdocs/auto_configure.php ]; then
# Set flag that the docker-leader configuration is complete
Expand Down
Loading

0 comments on commit 2e1a16e

Please sign in to comment.