2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-11-08 14:21:05 +00:00

refactor: style as per google style guide (tried)

- https://google.github.io/styleguide/
This commit is contained in:
pratikbalar 2021-06-22 15:44:25 +05:30
parent 7f26399ebc
commit e6a5209001
4 changed files with 160 additions and 182 deletions

View File

@ -1,36 +1,36 @@
#!/bin/bash
function configureEnv() {
if [ ! -f /home/frappe/frappe-bench/sites/common_site_config.json ]; then
if [[ ! -f /home/frappe/frappe-bench/sites/common_site_config.json ]]; then
if [[ -z "$MARIADB_HOST" ]]; then
if [[ -z "$POSTGRES_HOST" ]]; then
if [[ -z "${MARIADB_HOST}" ]]; then
if [[ -z "${POSTGRES_HOST}" ]]; then
echo "MARIADB_HOST or POSTGRES_HOST is not set"
exit 1
fi
fi
if [[ -z "$REDIS_CACHE" ]]; then
if [[ -z "${REDIS_CACHE}" ]]; then
echo "REDIS_CACHE is not set"
exit 1
fi
if [[ -z "$REDIS_QUEUE" ]]; then
if [[ -z "${REDIS_QUEUE}" ]]; then
echo "REDIS_QUEUE is not set"
exit 1
fi
if [[ -z "$REDIS_SOCKETIO" ]]; then
if [[ -z "${REDIS_SOCKETIO}" ]]; then
echo "REDIS_SOCKETIO is not set"
exit 1
fi
if [[ -z "$SOCKETIO_PORT" ]]; then
if [[ -z "${SOCKETIO_PORT}" ]]; then
echo "SOCKETIO_PORT is not set"
exit 1
fi
if [[ -z "$DB_PORT" ]]; then
if [[ -z "${DB_PORT}" ]]; then
export DB_PORT=3306
fi
@ -41,21 +41,21 @@ function configureEnv() {
${REDIS_CACHE}
${REDIS_QUEUE}
${REDIS_SOCKETIO}
${SOCKETIO_PORT}' < /opt/frappe/common_site_config.json.template > /home/frappe/frappe-bench/sites/common_site_config.json
${SOCKETIO_PORT}' </opt/frappe/common_site_config.json.template >/home/frappe/frappe-bench/sites/common_site_config.json
fi
}
function checkConnection() {
. /home/frappe/frappe-bench/env/bin/activate \
&& python /home/frappe/frappe-bench/commands/check_connection.py
. /home/frappe/frappe-bench/env/bin/activate
python /home/frappe/frappe-bench/commands/check_connection.py
}
function checkConfigExists() {
COUNTER=0
while [[ ! -e /home/frappe/frappe-bench/sites/common_site_config.json ]] && [[ $COUNTER -le 30 ]] ; do
sleep 1
(( COUNTER=COUNTER+1 ))
echo "config file not created, retry $COUNTER"
while [[ ! -e /home/frappe/frappe-bench/sites/common_site_config.json ]] && [[ ${COUNTER} -le 30 ]]; do
sleep 1
((COUNTER = COUNTER + 1))
echo "config file not created, retry ${COUNTER}"
done
if [[ ! -e /home/frappe/frappe-bench/sites/common_site_config.json ]]; then
@ -65,49 +65,49 @@ function checkConfigExists() {
}
if [[ ! -e /home/frappe/frappe-bench/sites/apps.txt ]]; then
find /home/frappe/frappe-bench/apps -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort -r > /home/frappe/frappe-bench/sites/apps.txt
find /home/frappe/frappe-bench/apps -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort -r >/home/frappe/frappe-bench/sites/apps.txt
fi
# symlink node_modules
ln -sfn /home/frappe/frappe-bench/sites/assets/frappe/node_modules \
/home/frappe/frappe-bench/apps/frappe/node_modules
if [ "$1" = 'start' ]; then
if [[ "$1" == 'start' ]]; then
configureEnv
checkConnection
if [[ -z "$WORKERS" ]]; then
if [[ -z "${WORKERS}" ]]; then
export WORKERS=2
fi
if [[ -z "$FRAPPE_PORT" ]]; then
if [[ -z "${FRAPPE_PORT}" ]]; then
export FRAPPE_PORT=8000
fi
if [[ -z "$WORKER_CLASS" ]]; then
if [[ -z "${WORKER_CLASS}" ]]; then
export WORKER_CLASS=gthread
fi
export LOAD_CONFIG_FILE=""
if [ "$WORKER_CLASS" = "gevent" ]; then
if [ "${WORKER_CLASS}" = "gevent" ]; then
export LOAD_CONFIG_FILE="-c /home/frappe/frappe-bench/commands/gevent_patch.py"
fi
if [[ ! -z "$AUTO_MIGRATE" ]]; then
. /home/frappe/frappe-bench/env/bin/activate \
&& python /home/frappe/frappe-bench/commands/auto_migrate.py
if [[ ! -z "${AUTO_MIGRATE}" ]]; then
. /home/frappe/frappe-bench/env/bin/activate
python /home/frappe/frappe-bench/commands/auto_migrate.py
fi
. /home/frappe/frappe-bench/env/bin/activate
gunicorn $LOAD_CONFIG_FILE -b 0.0.0.0:$FRAPPE_PORT \
gunicorn ${LOAD_CONFIG_FILE} -b 0.0.0.0:${FRAPPE_PORT} \
--worker-tmp-dir /dev/shm \
--threads=4 \
--workers $WORKERS \
--worker-class=$WORKER_CLASS \
--workers ${WORKERS} \
--worker-class=${WORKER_CLASS} \
--log-file=- \
-t 120 frappe.app:application --preload
elif [ "$1" = 'worker' ]; then
elif [[ "$1" == 'worker' ]]; then
checkConfigExists
checkConnection
# default WORKER_TYPE=default
@ -115,14 +115,14 @@ elif [ "$1" = 'worker' ]; then
. /home/frappe/frappe-bench/env/bin/activate
python /home/frappe/frappe-bench/commands/worker.py
elif [ "$1" = 'schedule' ]; then
elif [[ "$1" == 'schedule' ]]; then
checkConfigExists
checkConnection
. /home/frappe/frappe-bench/env/bin/activate
python /home/frappe/frappe-bench/commands/background.py
elif [ "$1" = 'new' ]; then
elif [[ "$1" == 'new' ]]; then
checkConfigExists
checkConnection
@ -130,7 +130,7 @@ elif [ "$1" = 'new' ]; then
python /home/frappe/frappe-bench/commands/new.py
exit
elif [ "$1" = 'drop' ]; then
elif [[ "$1" == 'drop' ]]; then
checkConfigExists
checkConnection
@ -138,25 +138,25 @@ elif [ "$1" = 'drop' ]; then
python /home/frappe/frappe-bench/commands/drop.py
exit
elif [ "$1" = 'migrate' ]; then
elif [[ "$1" = 'migrate' ]]; then
. /home/frappe/frappe-bench/env/bin/activate \
&& python /home/frappe/frappe-bench/commands/migrate.py
. /home/frappe/frappe-bench/env/bin/activate
python /home/frappe/frappe-bench/commands/migrate.py
exit
elif [ "$1" = 'doctor' ]; then
elif [[ "$1" == 'doctor' ]]; then
. /home/frappe/frappe-bench/env/bin/activate \
&& python /home/frappe/frappe-bench/commands/doctor.py ${@:2}
. /home/frappe/frappe-bench/env/bin/activate
python /home/frappe/frappe-bench/commands/doctor.py ${@:2}
exit
elif [ "$1" = 'backup' ]; then
elif [[ "$1" == 'backup' ]]; then
. /home/frappe/frappe-bench/env/bin/activate
python /home/frappe/frappe-bench/commands/backup.py
exit
elif [ "$1" = 'console' ]; then
elif [[ "$1" == 'console' ]]; then
if [[ -z "$2" ]]; then
echo "Need to specify a sitename with the command:"
@ -168,20 +168,19 @@ elif [ "$1" = 'console' ]; then
python /home/frappe/frappe-bench/commands/console.py "$2"
exit
elif [ "$1" = 'push-backup' ]; then
elif [[ "$1" = 'push-backup' ]]; then
. /home/frappe/frappe-bench/env/bin/activate \
&& python /home/frappe/frappe-bench/commands/push_backup.py
. /home/frappe/frappe-bench/env/bin/activate
python /home/frappe/frappe-bench/commands/push_backup.py
exit
elif [ "$1" = 'restore-backup' ]; then
elif [[ "$1" = 'restore-backup' ]]; then
. /home/frappe/frappe-bench/env/bin/activate \
&& python /home/frappe/frappe-bench/commands/restore_backup.py
. /home/frappe/frappe-bench/env/bin/activate
python /home/frappe/frappe-bench/commands/restore_backup.py
exit
else
exec $@
fi

View File

@ -39,7 +39,7 @@ wait-for-it "$REDIS_QUEUE" -t 1
echo "Check $REDIS_SOCKETIO"
wait-for-it "$REDIS_SOCKETIO" -t 1
if [[ "$1" = "-p" ]] || [[ "$1" = "--ping-service" ]]; then
if [[ "$1" = "-p" || "$1" = "--ping-service" ]]; then
echo "Check $2"
wait-for-it "$2" -t 1
fi

View File

@ -1,11 +1,11 @@
#!/bin/bash
#!/bin/bash -e
function checkConfigExists() {
COUNTER=0
while [[ ! -e /home/frappe/frappe-bench/sites/common_site_config.json ]] && [[ $COUNTER -le 30 ]] ; do
sleep 1
let COUNTER=COUNTER+1
echo "config file not created, retry $COUNTER"
while [[ ! -e /home/frappe/frappe-bench/sites/common_site_config.json && ${COUNTER} -le 30 ]]; do
((COUNTER = COUNTER + 1))
echo "config file not created, retry ${COUNTER}"
sleep 1
done
if [[ ! -e /home/frappe/frappe-bench/sites/common_site_config.json ]]; then
@ -14,16 +14,14 @@ function checkConfigExists() {
fi
}
if [ "$1" = 'start' ]; then
if [[ "$1" == 'start' ]]; then
checkConfigExists
node /home/frappe/frappe-bench/apps/frappe/socketio.js
elif [ "$1" = 'doctor' ]; then
elif [[ "$1" == 'doctor' ]]; then
node /home/frappe/frappe-bench/apps/frappe/health.js
else
exec -c "$@"
fi

View File

@ -1,4 +1,7 @@
#!/bin/bash
ULINE='\e[1m\e[4m'
ENDULINE='\e[0m'
NEWLINE='\n'
function checkMigrationComplete() {
echo "Check Migration"
@ -9,21 +12,21 @@ function checkMigrationComplete() {
-f installation/erpnext-publish.yml \
ps -q erpnext-python)
DOCKER_LOG=$(docker logs $CONTAINER_ID 2>&1 | grep "Starting gunicorn")
DOCKER_LOG=$(docker logs ${CONTAINER_ID} 2>&1 | grep "Starting gunicorn")
INCREMENT=0
while [[ $DOCKER_LOG != *"Starting gunicorn"* && $INCREMENT -lt 60 ]]; do
while [[ ${DOCKER_LOG} != *"Starting gunicorn"* && ${INCREMENT} -lt 60 ]]; do
sleep 3
echo "Wait for migration to complete ..."
((INCREMENT=INCREMENT+1))
DOCKER_LOG=$(docker logs $CONTAINER_ID 2>&1 | grep "Starting gunicorn")
if [[ $DOCKER_LOG != *"Starting gunicorn"* && $INCREMENT -eq 60 ]]; then
docker logs $CONTAINER_ID
((INCREMENT = INCREMENT + 1))
DOCKER_LOG=$(docker logs ${CONTAINER_ID} 2>&1 | grep "Starting gunicorn")
if [[ ${DOCKER_LOG} != *"Starting gunicorn"* && ${INCREMENT} -eq 60 ]]; then
docker logs ${CONTAINER_ID}
exit 1
fi
done
echo -e "\e[4mMigration Log\e[0m"
docker logs $CONTAINER_ID
echo -e "${ULINE}Migration Log${ENDULINE}"
docker logs ${CONTAINER_ID}
}
function loopHealthCheck() {
@ -35,24 +38,22 @@ function loopHealthCheck() {
echo "Loop Health Check"
FRAPPE_LOG=$(docker logs frappe_doctor | grep "Health check successful" || echo "")
while [[ -z "$FRAPPE_LOG" ]]; do
while [[ -z "${FRAPPE_LOG}" ]]; do
sleep 1
CONTAINER=$(docker start frappe_doctor)
echo "Restarting $CONTAINER ..."
echo "Restarting ${CONTAINER} ..."
FRAPPE_LOG=$(docker logs frappe_doctor | grep "Health check successful" || echo "")
done
echo "Health check successful"
}
echo -e "\e[1m\e[4mCopy env-example file\e[0m"
echo -e "${ULINE}Copy env-example file${ENDULINE}"
cp env-example .env
echo -e "\n"
echo -e "\e[1m\e[4mSet version to v13\e[0m"
echo -e "${NEWLINE}${ULINE}Set version to v13${ENDULINE}"
sed -i -e "s/edge/v13/g" .env
echo -e "\n"
echo -e "\e[1m\e[4mStart Services\e[0m"
echo -e "${NEWLINE}${ULINE}Start Services${ENDULINE}"
docker-compose \
--project-name frappebench00 \
-f installation/docker-compose-common.yml \
@ -74,30 +75,25 @@ docker run --name postgresql -d \
postgres:11.8
loopHealthCheck
echo -e "\n"
echo -e "\e[1m\e[4mCreate new site (v13)\e[0m"
echo -e "${NEWLINE}${ULINE}Create new site (v13)${ENDULINE}"
docker run -it \
-e "SITE_NAME=test.localhost" \
-e "INSTALL_APPS=erpnext" \
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
--network frappebench00_default \
frappe/erpnext-worker:v13 new
echo -e "\n"
echo -e "\e[1m\e[4mPing created site\e[0m"
echo -e "${NEWLINE}${ULINE}Ping created site${ENDULINE}"
curl -sS http://test.localhost/api/method/version
echo -e "\n"
echo -e "\e[1m\e[4mCheck Created Site Index Page\e[0m"
echo -e "${NEWLINE}${ULINE}Check Created Site Index Page${ENDULINE}"
curl -s http://test.localhost | w3m -T text/html -dump
echo -e "\n"
echo -e "\e[1m\e[4mSet version to edge\e[0m"
echo -e "${NEWLINE}${ULINE}Set version to edge${ENDULINE}"
sed -i -e "s/v13/edge/g" .env
echo -e "\n"
echo -e "\e[1m\e[4mRestart containers with edge image\e[0m"
echo -e "${NEWLINE}${ULINE}Restart containers with edge image${ENDULINE}"
docker-compose \
--project-name frappebench00 \
-f installation/docker-compose-common.yml \
@ -112,18 +108,17 @@ docker-compose \
up -d
checkMigrationComplete
echo -e "\n"
echo -e "\e[1m\e[4mPing migrated site\e[0m"
echo -e "${NEWLINE}${ULINE}Ping migrated site${ENDULINE}"
sleep 3
curl -sS http://test.localhost/api/method/version
echo -e "\n"
echo -e "\e[1m\e[4mCheck Migrated Site Index Page\e[0m"
echo -e "${NEWLINE}${ULINE}Check Migrated Site Index Page${ENDULINE}"
curl -s http://test.localhost | w3m -T text/html -dump
echo -e "\n"
echo -e "\e[1m\e[4mCreate new site (pgsql)\e[0m"
echo -e "${NEWLINE}${ULINE}Create new site (pgsql)${ENDULINE}"
docker run -it \
-e "SITE_NAME=pgsql.localhost" \
-e "POSTGRES_HOST=postgresql" \
@ -132,96 +127,95 @@ docker run -it \
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
--network frappebench00_default \
frappe/erpnext-worker:edge new
echo -e "\n"
echo -e "\e[1m\e[4mCheck New PGSQL Site\e[0m"
echo -e "${NEWLINE}${ULINE}Check New PGSQL Site${ENDULINE}"
sleep 3
RESTORE_STATUS=$(curl -sS http://pgsql.localhost/api/method/version || echo "")
INCREMENT=0
while [[ -z "$RESTORE_STATUS" && $INCREMENT -lt 60 ]]; do
while [[ -z "${RESTORE_STATUS}" && ${INCREMENT} -lt 60 ]]; do
sleep 1
echo -e "\e[1m\e[4mWait for restoration to complete ..."
echo -e "${ULINE}Wait for restoration to complete ..."
RESTORE_STATUS=$(curl -sS http://pgsql.localhost/api/method/version || echo "")
((INCREMENT=INCREMENT+1))
if [[ -z "$RESTORE_STATUS" && $INCREMENT -eq 60 ]]; then
((INCREMENT = INCREMENT + 1))
if [[ -z "${RESTORE_STATUS}" && ${INCREMENT} -eq 60 ]]; then
CONTAINER_ID=$(docker-compose \
--project-name frappebench00 \
-f installation/docker-compose-common.yml \
-f installation/docker-compose-erpnext.yml \
-f installation/erpnext-publish.yml \
ps -q erpnext-python)
docker logs $CONTAINER_ID
docker logs ${CONTAINER_ID}
exit 1
fi
done
echo -e "\n"
echo -e "\e[1m\e[4mPing new pgsql site\e[0m"
echo -e "${NEWLINE}${ULINE}Ping new pgsql site${ENDULINE}"
echo $RESTORE_STATUS
echo -e "\n"
echo -e "\e[1m\e[4mCheck New PGSQL Index Page\e[0m"
echo -e "${NEWLINE}${ULINE}Check New PGSQL Index Page${ENDULINE}"
curl -s http://pgsql.localhost | w3m -T text/html -dump
echo -e "\n"
echo -e "\e[1m\e[4mBackup site\e[0m"
echo -e "${NEWLINE}${ULINE}Backup site${ENDULINE}"
docker run -it \
-e "WITH_FILES=1" \
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
--network frappebench00_default \
frappe/erpnext-worker:edge backup
echo -e "\n"
export MINIO_ACCESS_KEY="AKIAIOSFODNN7EXAMPLE"
export MINIO_SECRET_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
echo -e "\e[1m\e[4mStart MinIO container for s3 compatible storage\e[0m"
echo -e "${ULINE}Start MinIO container for s3 compatible storage${ENDULINE}"
docker run -d --name minio \
-e "MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY" \
-e "MINIO_SECRET_KEY=$MINIO_SECRET_KEY" \
--network frappebench00_default \
minio/minio server /data
echo -e "\n"
-e "MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY}" \
-e "MINIO_SECRET_KEY=${MINIO_SECRET_KEY}" \
--network frappebench00_default \
minio/minio server /data
echo -e "\e[1m\e[4mCreate bucket named erpnext\e[0m"
echo -e "${NEWLINE}${ULINE}Create bucket named erpnext${ENDULINE}"
docker run \
--network frappebench00_default \
vltgroup/s3cmd:latest s3cmd --access_key=$MINIO_ACCESS_KEY \
--secret_key=$MINIO_SECRET_KEY \
vltgroup/s3cmd:latest s3cmd --access_key=${MINIO_ACCESS_KEY} \
--secret_key=${MINIO_SECRET_KEY} \
--region=us-east-1 \
--no-ssl \
--host=minio:9000 \
--host-bucket=minio:9000 \
mb s3://erpnext
echo -e "\n"
echo -e "\e[1m\e[4mPush backup to MinIO s3\e[0m"
echo -e "${NEWLINE}${NEWLINE}${ULINE}Push backup to MinIO s3${ENDULINE}"
docker run \
-e BUCKET_NAME=erpnext \
-e REGION=us-east-1 \
-e BUCKET_DIR=local \
-e ACCESS_KEY_ID=$MINIO_ACCESS_KEY \
-e SECRET_ACCESS_KEY=$MINIO_SECRET_KEY \
-e ACCESS_KEY_ID=${MINIO_ACCESS_KEY} \
-e SECRET_ACCESS_KEY=${MINIO_SECRET_KEY} \
-e ENDPOINT_URL=http://minio:9000 \
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
--network frappebench00_default \
frappe/erpnext-worker:edge push-backup
echo -e "\n"
echo -e "\e[1m\e[4mStop Services\e[0m"
echo -e "${NEWLINE}${ULINE}Stop Services${ENDULINE}"
docker-compose \
--project-name frappebench00 \
-f installation/docker-compose-common.yml \
-f installation/docker-compose-erpnext.yml \
-f installation/erpnext-publish.yml \
stop
echo -e "\n"
echo -e "\e[1m\e[4mPrune Containers\e[0m"
echo -e "${NEWLINE}${ULINE}Prune Containers${ENDULINE}"
docker container prune -f && docker volume prune -f
echo -e "\n"
echo -e "\e[1m\e[4mStart Services\e[0m"
echo -e "${NEWLINE}${ULINE}Start Services${ENDULINE}"
docker-compose \
--project-name frappebench00 \
-f installation/docker-compose-common.yml \
@ -230,120 +224,112 @@ docker-compose \
up -d
loopHealthCheck
echo -e "\n"
echo -e "\e[1m\e[4mRestore backup from MinIO / S3\e[0m"
echo -e "${NEWLINE}${ULINE}Restore backup from MinIO / S3${ENDULINE}"
docker run \
-e MYSQL_ROOT_PASSWORD=admin \
-e BUCKET_NAME=erpnext \
-e BUCKET_DIR=local \
-e ACCESS_KEY_ID=$MINIO_ACCESS_KEY \
-e SECRET_ACCESS_KEY=$MINIO_SECRET_KEY \
-e ACCESS_KEY_ID=${MINIO_ACCESS_KEY} \
-e SECRET_ACCESS_KEY=${MINIO_SECRET_KEY} \
-e ENDPOINT_URL=http://minio:9000 \
-e REGION=us-east-1 \
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
--network frappebench00_default \
frappe/erpnext-worker:edge restore-backup
echo -e "\n"
echo -e "\e[1m\e[4mCheck Restored Site (test)\e[0m"
echo -e "${NEWLINE}${ULINE}Check Restored Site (test)${ENDULINE}"
sleep 3
RESTORE_STATUS=$(curl -sS http://test.localhost/api/method/version || echo "")
INCREMENT=0
while [[ -z "$RESTORE_STATUS" && $INCREMENT -lt 60 ]]; do
while [[ -z "${RESTORE_STATUS}" && ${INCREMENT} -lt 60 ]]; do
sleep 1
echo "Wait for restoration to complete ..."
RESTORE_STATUS=$(curl -sS http://test.localhost/api/method/version || echo "")
((INCREMENT=INCREMENT+1))
if [[ -z "$RESTORE_STATUS" && $INCREMENT -eq 60 ]]; then
((INCREMENT = INCREMENT + 1))
if [[ -z "${RESTORE_STATUS}" && ${INCREMENT} -eq 60 ]]; then
CONTAINER_ID=$(docker-compose \
--project-name frappebench00 \
-f installation/docker-compose-common.yml \
-f installation/docker-compose-erpnext.yml \
-f installation/erpnext-publish.yml \
ps -q erpnext-python)
docker logs $CONTAINER_ID
docker logs ${CONTAINER_ID}
exit 1
fi
done
echo -e "\e[1m\e[4mPing restored site (test)\e[0m"
echo $RESTORE_STATUS
echo -e "\n"
echo -e "${ULINE}Ping restored site (test)${ENDULINE}"
echo ${RESTORE_STATUS}
echo -e "\e[1m\e[4mCheck Restored Site Index Page (test)\e[0m"
echo -e "${NEWLINE}${ULINE}Check Restored Site Index Page (test)${ENDULINE}"
curl -s http://test.localhost | w3m -T text/html -dump
echo -e "\n"
echo -e "\e[1m\e[4mCheck Restored Site (pgsql)\e[0m"
echo -e "${NEWLINE}${ULINE}Check Restored Site (pgsql)${ENDULINE}"
sleep 3
RESTORE_STATUS=$(curl -sS http://pgsql.localhost/api/method/version || echo "")
INCREMENT=0
while [[ -z "$RESTORE_STATUS" && $INCREMENT -lt 60 ]]; do
while [[ -z "${RESTORE_STATUS}" && ${INCREMENT} -lt 60 ]]; do
sleep 1
echo "Wait for restoration to complete ..."
RESTORE_STATUS=$(curl -sS http://pgsql.localhost/api/method/version || echo "")
((INCREMENT=INCREMENT+1))
if [[ -z "$RESTORE_STATUS" && $INCREMENT -eq 60 ]]; then
((INCREMENT = INCREMENT + 1))
if [[ -z "${RESTORE_STATUS}" && ${INCREMENT} -eq 60 ]]; then
CONTAINER_ID=$(docker-compose \
--project-name frappebench00 \
-f installation/docker-compose-common.yml \
-f installation/docker-compose-erpnext.yml \
-f installation/erpnext-publish.yml \
ps -q erpnext-python)
docker logs $CONTAINER_ID
docker logs ${CONTAINER_ID}
exit 1
fi
done
echo -e "\e[1m\e[4mPing restored site (pgsql)\e[0m"
echo $RESTORE_STATUS
echo -e "\n"
echo -e "${ULINE}Ping restored site (pgsql)${ENDULINE}"
echo ${RESTORE_STATUS}
echo -e "\e[1m\e[4mCheck Restored Site Index Page (pgsql)\e[0m"
echo -e "${NEWLINE}${ULINE}Check Restored Site Index Page (pgsql)${ENDULINE}"
curl -s http://pgsql.localhost | w3m -T text/html -dump
echo -e "\n"
echo -e "\e[1m\e[4mCreate new site (edge)\e[0m"
echo -e "${NEWLINE}${ULINE}Create new site (edge)${ENDULINE}"
docker run -it \
-e "SITE_NAME=edge.localhost" \
-e "INSTALL_APPS=erpnext" \
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
--network frappebench00_default \
frappe/erpnext-worker:edge new
echo -e "\n"
echo -e "\e[1m\e[4mCheck New Edge Site\e[0m"
echo -e "${NEWLINE}${ULINE}Check New Edge Site${ENDULINE}"
sleep 3
RESTORE_STATUS=$(curl -sS http://edge.localhost/api/method/version || echo "")
INCREMENT=0
while [[ -z "$RESTORE_STATUS" && $INCREMENT -lt 60 ]]; do
while [[ -z "${RESTORE_STATUS}" && ${INCREMENT} -lt 60 ]]; do
sleep 1
echo -e "\e[1m\e[4mWait for restoration to complete ..."
echo -e "${ULINE}Wait for restoration to complete ...${ENDULINE}"
RESTORE_STATUS=$(curl -sS http://edge.localhost/api/method/version || echo "")
((INCREMENT=INCREMENT+1))
if [[ -z "$RESTORE_STATUS" && $INCREMENT -eq 60 ]]; then
((INCREMENT = INCREMENT + 1))
if [[ -z "${RESTORE_STATUS}" && ${INCREMENT} -eq 60 ]]; then
CONTAINER_ID=$(docker-compose \
--project-name frappebench00 \
-f installation/docker-compose-common.yml \
-f installation/docker-compose-erpnext.yml \
-f installation/erpnext-publish.yml \
ps -q erpnext-python)
docker logs $CONTAINER_ID
docker logs ${CONTAINER_ID}
exit 1
fi
done
echo -e "\n"
echo -e "\e[1m\e[4mPing new edge site\e[0m"
echo $RESTORE_STATUS
echo -e "\n"
echo -e "${NEWLINE}${ULINE}Ping new edge site${ENDULINE}"
echo ${RESTORE_STATUS}
echo -e "\e[1m\e[4mCheck New Edge Index Page\e[0m"
echo -e "${NEWLINE}${ULINE}Check New Edge Index Page${ENDULINE}"
curl -s http://edge.localhost | w3m -T text/html -dump
echo -e "\n"
echo -e "\e[1m\e[4mMigrate command in edge container\e[0m"
echo -e "${NEWLINE}${ULINE}Migrate command in edge container${ENDULINE}"
docker run -it \
-e "MAINTENANCE_MODE=1" \
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
@ -352,79 +338,74 @@ docker run -it \
frappe/erpnext-worker:edge migrate
checkMigrationComplete
echo -e "\n"
echo -e "\e[1m\e[4mRestore backup from MinIO / S3 (Overwrite)\e[0m"
echo -e "${NEWLINE}${ULINE}Restore backup from MinIO / S3 (Overwrite)${ENDULINE}"
docker run \
-e MYSQL_ROOT_PASSWORD=admin \
-e BUCKET_NAME=erpnext \
-e BUCKET_DIR=local \
-e ACCESS_KEY_ID=$MINIO_ACCESS_KEY \
-e SECRET_ACCESS_KEY=$MINIO_SECRET_KEY \
-e ACCESS_KEY_ID=${MINIO_ACCESS_KEY} \
-e SECRET_ACCESS_KEY=${MINIO_SECRET_KEY} \
-e ENDPOINT_URL=http://minio:9000 \
-e REGION=us-east-1 \
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
--network frappebench00_default \
frappe/erpnext-worker:edge restore-backup
echo -e "\n"
echo -e "\e[1m\e[4mCheck Overwritten Site\e[0m"
echo -e "${NEWLINE}${ULINE}Check Overwritten Site${ENDULINE}"
sleep 3
RESTORE_STATUS=$(curl -sS http://test.localhost/api/method/version || echo "")
INCREMENT=0
while [[ -z "$RESTORE_STATUS" && $INCREMENT -lt 60 ]]; do
while [[ -z "${RESTORE_STATUS}" && ${INCREMENT} -lt 60 ]]; do
sleep 1
echo -e "\e[1m\e[4mWait for restoration to complete ..."
echo -e "${ULINE}Wait for restoration to complete ..."
RESTORE_STATUS=$(curl -sS http://test.localhost/api/method/version || echo "")
((INCREMENT=INCREMENT+1))
if [[ -z "$RESTORE_STATUS" && $INCREMENT -eq 60 ]]; then
((INCREMENT = INCREMENT + 1))
if [[ -z "${RESTORE_STATUS}" && ${INCREMENT} -eq 60 ]]; then
CONTAINER_ID=$(docker-compose \
--project-name frappebench00 \
-f installation/docker-compose-common.yml \
-f installation/docker-compose-erpnext.yml \
-f installation/erpnext-publish.yml \
ps -q erpnext-python)
docker logs $CONTAINER_ID
docker logs ${CONTAINER_ID}
exit 1
fi
done
echo -e "\n"
echo -e "\e[1m\e[4mPing overwritten site\e[0m"
echo $RESTORE_STATUS
echo -e "\n"
echo -e "${NEWLINE}${ULINE}Ping overwritten site${ENDULINE}"
echo ${RESTORE_STATUS}
echo -e "\e[1m\e[4mCheck Overwritten Index Page\e[0m"
echo -e "${NEWLINE}${ULINE}Check Overwritten Index Page${ENDULINE}"
curl -s http://test.localhost | w3m -T text/html -dump
echo -e "\n"
echo -e "\e[1m\e[4mCheck console command for site test.localhost\e[0m"
echo -e "${NEWLINE}${ULINE}Check console command for site test.localhost${ENDULINE}"
docker run \
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
--network frappebench00_default \
frappe/erpnext-worker:edge console test.localhost
echo -e "\e[1m\e[4mCheck console command for site pgsql.localhost\e[0m"
echo -e "${NEWLINE}${ULINE}Check console command for site pgsql.localhost${ENDULINE}"
docker run \
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
--network frappebench00_default \
frappe/erpnext-worker:edge console pgsql.localhost
echo -e "\e[1m\e[4mCheck drop site: test.localhost (mariadb)\e[0m"
echo -e "${NEWLINE}${ULINE}Check drop site: test.localhost (mariadb)${ENDULINE}"
docker run \
-e SITE_NAME=test.localhost \
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
--network frappebench00_default \
frappe/erpnext-worker:edge drop
echo -e "\e[1m\e[4mCheck drop site: pgsql.localhost (pgsql)\e[0m"
echo -e "${NEWLINE}${ULINE}Check drop site: pgsql.localhost (pgsql)${ENDULINE}"
docker run \
-e SITE_NAME=pgsql.localhost \
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
--network frappebench00_default \
frappe/erpnext-worker:edge drop
echo -e "\e[1m\e[4mCheck bench --help\e[0m"
echo -e "${NEWLINE}${ULINE}Check bench --help${ENDULINE}"
docker run \
-v frappebench00_sites-vol:/home/frappe/frappe-bench/sites \
--network frappebench00_default \