services-garbaye/podman-matrix/10_install.sh

38 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
source ${ABSDIR}/../functions.sh
source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir
ensure_not_root
ensure_pod_not_exists ${pod_name}
ensure_variables_are_defined "$envvars"
if ! podman volume exists ${confvolume} ; then
echo "Error : conf volume ${confvolume} does not exists. Consider running 05_freshinstall.sh if this is the first install."
exit 1
fi
if ! podman volume exists ${dbvolume} ; then
echo "Error : conf volume ${dbvolume} does not exists. Consider running 05_freshinstall.sh if this is the first install."
exit 1
fi
podman pod create --publish ${listen_if}:8086:8008 --name ${pod_name} && \
podman run -d --name ${db_container_name} --pod ${pod_name} \
--mount type=volume,src=${dbvolume},dst=/var/lib/postgresql/data/ \
-e POSTGRES_PASSWORD=${GARBAYE_MATRIX_POSTGRES_PASSWORD} \
-e POSTGRES_USER=${container_name} \
-e POSTGRES_DB=${container_name} \
-e POSTGRES_INITDB_ARGS="--encoding=UTF8 --locale=C" \
${postgres_image}:${postgres_version} && \
podman run -d --name ${container_name} --pod ${pod_name} \
--mount type=volume,src=${confvolume},dst=/data ${synapse_image}:${synapse_version}
echo "Waiting for background tasks to end..."
( podman logs -f synapse synapse-db 2>&1 & ) | grep -q 'No more background updates to do' && \
podman pod stop ${pod_name} && \
echo "Done. Pod built and stopped."