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

63 lines
2 KiB
Bash
Raw Normal View History

2022-11-26 22:00:34 +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
ensure_pod_not_exists ${pod_name}
ensure_variables_are_defined "$envvars"
if ! podman volume exists ${dbvolume} ; then
echo "Error : DB volume ${dbvolume} does not exists. Consider running 05_freshinstall.sh if this is the first install."
exit 1
fi
if ! podman volume exists ${datavolume} ; then
echo "Error : DATA volume ${datavolume} does not exists. Consider running 05_freshinstall.sh if this is the first install."
exit 1
fi
cat <<EOT > .env
# vaultwarden
DATABASE_URL=postgresql://vaultwarden:${GARBAYE_VAULTWARDEN_DATABASE_PASSWORD}@database:${database_port}/vaultwarden
ADMIN_TOKEN=${GARBAYE_VAULTWARDEN_ADMIN_PASSWORD}
DOMAIN=${GARBAYE_VAULTWARDEN_DOMAIN}
2022-11-26 22:00:34 +00:00
# PostgreSQL
POSTGRES_DB=vaultwarden
POSTGRES_PASSWORD=${GARBAYE_VAULTWARDEN_DATABASE_PASSWORD}
POSTGRES_USER=vaultwarden
# Signups
SIGNUPS_VERIFY=true
# SMTP
SMTP_HOST=${GARBAYE_SEAFILE_SMTP_SERVER}
SMTP_FROM=vaultwarden@garbaye.fr
SMTP_FROM_NAME=Vaultwarden
SMTP_SECURITY=off
SMTP_PORT=25
2022-11-26 22:00:34 +00:00
EOT
export vaultwarden_image
export vaultwarden_version
export database_image
export database_version
export database_path
export container_name
export db_container_name
if ! podman image exists ${vaultwarden_image}:${vaultwarden_version}; then
podman image pull ${vaultwarden_image}:${vaultwarden_version} || exit 1
fi
if ! podman image exists ${database_image}:${database_version}; then
podman image pull ${database_image}:${database_version} || exit 1
fi
podman-compose --pod-args="--infra=true --infra-name=${project_name}_infra --share=" --podman-run-args "--requires=${project_name}_infra --env-file .env" up -d &&
echo -n "Waiting for vaultwarden to finish starting " &&
( podman container logs -f ${container_name} 2>&1 & ) | grep -q 'Rocket has launched from ' &&
2022-11-26 22:00:34 +00:00
echo "OK" &&
podman pod stop ${pod_name} &&
echo Pod built and stopped. &&
shred -u .env