2021-06-14 10:42:59 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
|
|
|
|
source ${ABSDIR}/../functions.sh
|
|
|
|
source ${ABSDIR}/vars.sh
|
|
|
|
|
|
|
|
ensure_pwd_is_scriptdir
|
|
|
|
ensure_not_root
|
|
|
|
|
2022-01-28 20:15:15 +00:00
|
|
|
ensure_pod_not_exists ${pod_name}
|
2021-07-01 17:28:13 +00:00
|
|
|
ensure_variables_are_defined "$envvars"
|
|
|
|
|
2022-01-28 13:21:27 +00:00
|
|
|
if ! podman volume exists ${confvolume} ; then
|
2021-06-14 10:42:59 +00:00
|
|
|
echo "Error : conf volume ${confvolume} does not exists. Consider running 05_freshinstall.sh if this is the first install."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-01-28 13:21:27 +00:00
|
|
|
if ! podman volume exists ${dbvolume} ; then
|
2021-06-14 10:42:59 +00:00
|
|
|
echo "Error : conf volume ${dbvolume} does not exists. Consider running 05_freshinstall.sh if this is the first install."
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-07-04 19:21:54 +00:00
|
|
|
|
2023-07-29 13:51:24 +00:00
|
|
|
cat <<EOT >> .env
|
|
|
|
POSTGRES_PASSWORD=${GARBAYE_MATRIX_POSTGRES_PASSWORD}
|
2023-08-10 21:37:49 +00:00
|
|
|
POSTGRES_USER=synapse
|
|
|
|
POSTGRES_DB=synapse
|
2023-07-29 13:51:24 +00:00
|
|
|
POSTGRES_INITDB_ARGS=--encoding=UTF8 --locale=C
|
|
|
|
EOT
|
|
|
|
|
|
|
|
export postgres_image
|
|
|
|
export postgres_version
|
|
|
|
export synapse_image
|
|
|
|
export synapse_version
|
|
|
|
export listen_if
|
|
|
|
export listen_port
|
|
|
|
|
2023-05-20 13:59:37 +00:00
|
|
|
if ! podman image exists ${synapse_image}:${synapse_version}; then
|
2022-11-13 13:08:31 +00:00
|
|
|
podman image pull ${synapse_image}:${synapse_version} || exit 1
|
|
|
|
fi
|
2023-04-21 11:53:55 +00:00
|
|
|
podman image pull ${postgres_image}:${postgres_version} &&
|
2024-06-11 20:04:14 +00:00
|
|
|
${my_podman_compose} --pod-args="--infra=true --infra-name=${project_name}_infra --share=" --podman-run-args "--requires=${project_name}_infra --env-file .env" up -d &&
|
2023-07-29 13:51:24 +00:00
|
|
|
|
2023-08-10 21:32:42 +00:00
|
|
|
end=$((SECONDS+120))
|
2023-07-29 13:51:24 +00:00
|
|
|
while [ $SECONDS -lt $end ]; do
|
|
|
|
sleep 1
|
2023-08-12 11:54:12 +00:00
|
|
|
if check_container_running ${container_name}; then
|
|
|
|
podman logs ${container_name} 2>&1 | grep -qe 'Preparing for databases' &&
|
2023-07-29 13:51:24 +00:00
|
|
|
break
|
|
|
|
else
|
2023-08-12 11:54:12 +00:00
|
|
|
podman logs ${container_name} 2>&1 | grep -qe 'psycopg2.OperationalError: could not connect to server: Connection refused' &&
|
|
|
|
podman healthcheck run ${db_container_name} &&
|
2023-07-29 13:51:24 +00:00
|
|
|
echo "Oops, synapse didn't wait for PostgreSQL, restarting"
|
2023-08-12 11:54:12 +00:00
|
|
|
podman start ${container_name}
|
2023-07-29 13:51:24 +00:00
|
|
|
fi
|
|
|
|
done &&
|
|
|
|
|
2023-08-12 11:54:12 +00:00
|
|
|
podman container wait --condition=running ${container_name} &&
|
2022-02-12 18:09:02 +00:00
|
|
|
echo -n "Waiting for background tasks to end... " &&
|
2023-08-12 11:54:12 +00:00
|
|
|
( podman container logs --tail=50 -f ${container_name} 2>&1 & ) | grep -q 'No more background updates to do' &&
|
|
|
|
echo "OK." || retval=false
|
2022-02-12 18:09:02 +00:00
|
|
|
podman pod stop ${pod_name} &&
|
2023-08-12 11:54:12 +00:00
|
|
|
echo "Done. Pod stopped."
|
2023-07-29 13:51:24 +00:00
|
|
|
shred -u .env
|
2023-08-12 11:54:12 +00:00
|
|
|
eval "$retval"
|