Fix OCI docker script for marketplace (#187)

* Add noninteractive mode

* Add the ability to pull images
This commit is contained in:
Evgeniy Antonyuk 2024-03-29 19:09:52 +07:00 committed by GitHub
parent b0bcd5d691
commit f2dadbbb2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -463,6 +463,13 @@ while [ "$1" != "" ]; do
fi
;;
-noni | --noninteractive )
if [ "$2" != "" ]; then
NON_INTERACTIVE=$2
shift
fi
;;
-? | -h | --help )
echo " Usage: bash $HELP_TARGET [PARAMETER] [[PARAMETER], ...]"
echo
@ -511,6 +518,7 @@ while [ "$1" != "" ]; do
echo " -lem, --letsencryptmail defines the domain administator mail address for Let's Encrypt certificate"
echo " -cf, --certfile path to the certificate file for the domain"
echo " -ckf, --certkeyfile path to the private key file for the certificate"
echo " -noni, --noninteractive auto confirm all questions (true|false)"
echo " -dbm, --databasemigration database migration (true|false)"
echo " -ms, --makeswap make swap file (true|false)"
echo " -?, -h, --help this help"
@ -884,6 +892,10 @@ create_network () {
}
read_continue_installation () {
if [[ "${NON_INTERACTIVE}" = "true" ]]; then
return 0
fi
read -p "Continue installation [Y/N]? " CHOICE_INSTALLATION
case "$CHOICE_INSTALLATION" in
y|Y )
@ -1196,10 +1208,12 @@ install_mysql_server () {
reconfigure MYSQL_USER ${MYSQL_USER}
reconfigure MYSQL_PASSWORD ${MYSQL_PASSWORD}
reconfigure MYSQL_ROOT_PASSWORD ${MYSQL_ROOT_PASSWORD}
reconfigure MYSQL_VERSION ${MYSQL_VERSION}
if [[ -z ${MYSQL_HOST} ]] && [ "$INSTALL_MYSQL_SERVER" == "true" ]; then
reconfigure MYSQL_VERSION ${MYSQL_VERSION}
docker-compose -f $BASE_DIR/db.yml up -d
elif [ "$INSTALL_MYSQL_SERVER" == "pull" ]; then
docker-compose -f $BASE_DIR/db.yml pull
elif [ ! -z "$MYSQL_HOST" ]; then
establish_conn ${MYSQL_HOST} "${MYSQL_PORT:-"3306"}" "MySQL"
reconfigure MYSQL_HOST ${MYSQL_HOST}
@ -1210,9 +1224,11 @@ install_mysql_server () {
install_document_server () {
reconfigure DOCUMENT_SERVER_JWT_HEADER ${DOCUMENT_SERVER_JWT_HEADER}
reconfigure DOCUMENT_SERVER_JWT_SECRET ${DOCUMENT_SERVER_JWT_SECRET}
if [[ -z ${DOCUMENT_SERVER_HOST} ]] && [ "$INSTALL_DOCUMENT_SERVER" == "true" ]; then
reconfigure DOCUMENT_SERVER_IMAGE_NAME "${DOCUMENT_SERVER_IMAGE_NAME}:${DOCUMENT_SERVER_VERSION:-$(get_available_version "$DOCUMENT_SERVER_IMAGE_NAME")}"
if [[ -z ${DOCUMENT_SERVER_HOST} ]] && [ "$INSTALL_DOCUMENT_SERVER" == "true" ]; then
docker-compose -f $BASE_DIR/ds.yml up -d
elif [ "$INSTALL_DOCUMENT_SERVER" == "pull" ]; then
docker-compose -f $BASE_DIR/ds.yml pull
elif [ ! -z "$DOCUMENT_SERVER_HOST" ]; then
APP_URL_PORTAL=${APP_URL_PORTAL:-"http://$(curl -s ifconfig.me):${EXTERNAL_PORT}"}
establish_conn ${DOCUMENT_SERVER_HOST} ${DOCUMENT_SERVER_PORT} "${PACKAGE_SYSNAME^^} Docs"
@ -1224,6 +1240,8 @@ install_document_server () {
install_rabbitmq () {
if [[ -z ${RABBIT_HOST} ]] && [ "$INSTALL_RABBITMQ" == "true" ]; then
docker-compose -f $BASE_DIR/rabbitmq.yml up -d
elif [ "$INSTALL_RABBITMQ" == "pull" ]; then
docker-compose -f $BASE_DIR/rabbitmq.yml pull
elif [ ! -z "$RABBIT_HOST" ]; then
establish_conn ${RABBIT_HOST} "${RABBIT_PORT:-"5672"}" "RabbitMQ"
reconfigure RABBIT_HOST ${RABBIT_HOST}
@ -1237,6 +1255,8 @@ install_rabbitmq () {
install_redis () {
if [[ -z ${REDIS_HOST} ]] && [ "$INSTALL_REDIS" == "true" ]; then
docker-compose -f $BASE_DIR/redis.yml up -d
elif [ "$INSTALL_REDIS" == "pull" ]; then
docker-compose -f $BASE_DIR/redis.yml pull
elif [ ! -z "$REDIS_HOST" ]; then
establish_conn ${REDIS_HOST} "${REDIS_PORT:-"6379"}" "Redis"
reconfigure REDIS_HOST ${REDIS_HOST}
@ -1247,14 +1267,16 @@ install_redis () {
}
install_elasticsearch () {
reconfigure ELK_VERSION ${ELK_VERSION}
if [[ -z ${ELK_HOST} ]] && [ "$INSTALL_ELASTICSEARCH" == "true" ]; then
if [ $(free --mega | grep -oP '\d+' | head -n 1) -gt "12000" ]; then #RAM ~12Gb
sed -i 's/Xms[0-9]g/Xms4g/g; s/Xmx[0-9]g/Xmx4g/g' $BASE_DIR/opensearch.yml
else
sed -i 's/Xms[0-9]g/Xms1g/g; s/Xmx[0-9]g/Xmx1g/g' $BASE_DIR/opensearch.yml
fi
reconfigure ELK_VERSION ${ELK_VERSION}
docker-compose -f $BASE_DIR/opensearch.yml up -d
elif [ "$INSTALL_ELASTICSEARCH" == "pull" ]; then
docker-compose -f $BASE_DIR/opensearch.yml pull
elif [ ! -z "$ELK_HOST" ]; then
establish_conn ${ELK_HOST} "${ELK_PORT:-"9200"}" "search engine"
reconfigure ELK_SHEME "${ELK_SHEME:-"http"}"
@ -1266,7 +1288,7 @@ install_elasticsearch () {
install_product () {
DOCKER_TAG="${DOCKER_TAG:-$(get_available_version ${IMAGE_NAME})}"
reconfigure DOCKER_TAG ${DOCKER_TAG}
if [ "$INSTALL_PRODUCT" == "true" ]; then
[ "${UPDATE}" = "true" ] && LOCAL_CONTAINER_TAG="$(docker inspect --format='{{index .Config.Image}}' ${CONTAINER_NAME} | awk -F':' '{print $2}')"
if [ "${UPDATE}" = "true" ] && [ "${LOCAL_CONTAINER_TAG}" != "${DOCKER_TAG}" ]; then
@ -1298,6 +1320,13 @@ install_product () {
elif [ ! -z "${LETS_ENCRYPT_DOMAIN}" ] && [ ! -z "${LETS_ENCRYPT_MAIL}" ]; then
bash $BASE_DIR/config/${PRODUCT}-ssl-setup "${LETS_ENCRYPT_MAIL}" "${LETS_ENCRYPT_DOMAIN}"
fi
elif [ "$INSTALL_PRODUCT" == "pull" ]; then
docker-compose -f $BASE_DIR/migration-runner.yml pull
docker-compose -f $BASE_DIR/${PRODUCT}.yml pull
docker-compose -f ${PROXY_YML} pull
docker-compose -f $BASE_DIR/notify.yml pull
docker-compose -f $BASE_DIR/healthchecks.yml pull
fi
}
make_swap () {
@ -1382,9 +1411,7 @@ start_installation () {
install_elasticsearch
if [ "$INSTALL_PRODUCT" == "true" ]; then
install_product
fi
echo ""
echo "Thank you for installing ${PACKAGE_SYSNAME^^} ${PRODUCT_NAME}."