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

92 lines
2.9 KiB
Bash
Raw Normal View History

2022-11-19 13:19:37 +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
2022-11-19 17:57:17 +00:00
#if ! podman volume exists ${uploadsvolume} ; then
# echo "Error : UPLOADS volume ${uploasvolume} does not exists. Consider running 05_freshinstall.sh if this is the first install."
# exit 1
#fi
2022-11-19 13:19:37 +00:00
2022-11-19 19:34:59 +00:00
cat <<EOT > .env
2022-11-19 13:19:37 +00:00
# HedgeDoc https://docs.hedgedoc.org/configuration/
## Node.JS
NODE_ENV=production
DEBUG=false
## HedgeDoc basics
2022-11-19 13:53:24 +00:00
#CMD_CONFIG_FILE=/data/config.json
2022-11-19 20:58:31 +00:00
CMD_DB_USERNAME=hedgedoc
CMD_DB_PASSWORD=${GARBAYE_HEDGEDOC_DATABASE_PASSWORD}
CMD_DB_DATABASE=hedgedoc
CMD_DB_HOST=database
CMD_DB_PORT=${database_port}
CMD_DB_DIALECT=${database_dialect}
2022-11-19 14:01:16 +00:00
#CMD_DB_URL=sqlite:///data/sqlite.db
2022-11-19 20:58:31 +00:00
#CMD_DB_URL=CMD_DB_URL=postgres://hedgedoc:${GARBAYE_HEDGEDOC_DATABASE_PASSWORD}@database:5432/hedgedoc
2022-11-19 13:19:37 +00:00
#CMD_DB_URL=CMD_DB_URL=mysql://hedgedoc:${GARBAYE_HEDGEDOC_DATABASE_PASSWORD}@database:3306/hedgedoc
CMD_IMAGE_UPLOAD_TYPE=filesystem
## HedgeDoc Location
CMD_DOMAIN=${GARBAYE_HEDGEDOC_DOMAIN}
CMD_PROTOCOL_USESSL=true
2022-11-19 23:21:47 +00:00
CMD_URL_ADDPORT=false
2022-11-19 19:34:59 +00:00
CMD_ALLOW_ORIGIN=["localhost","${GARBAYE_HEDGEDOC_DOMAIN}"]
2022-11-19 13:19:37 +00:00
## Web security aspects
CMD_CSP_ALLOW_FRAMING=false
CMD_CSP_ALLOW_PDF_EMBED=false
CMD_COOKIE_POLICY=strict
## Privacy and External Requests
CMD_ALLOW_GRAVATAR=false
## Users and Privileges
CMD_ALLOW_ANONYMOUS=false
## Login methods
CMD_ALLOW_EMAIL_REGISTER=false
# PostgreSQL
POSTGRES_DB=hedgedoc
POSTGRES_PASSWORD=${GARBAYE_HEDGEDOC_DATABASE_PASSWORD}
POSTGRES_USER=hedgedoc
# MySQL
MYSQL_USER=hedgedoc
MYSQL_PASSWORD=${GARBAYE_HEDGEDOC_DATABASE_PASSWORD}
MYSQL_DATABASE=hedgedoc
MYSQL_RANDOM_ROOT_PASSWORD=true
2022-11-19 13:19:37 +00:00
EOT
export hedgedoc_image
export hedgedoc_version
export database_image
export database_version
export database_path
2022-11-19 18:16:17 +00:00
export container_name
export db_container_name
2022-11-19 13:19:37 +00:00
if ! podman image exists ${hedgedoc_image}:${hedgedoc_version}; then
podman image pull ${hedgedoc_image}:${hedgedoc_version} || exit 1
fi
if ! podman image exists ${database_image}:${database_version}; then
2022-11-19 18:37:02 +00:00
podman image pull ${database_image}:${database_version} || exit 1
2022-11-19 13:19:37 +00:00
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 hedgedoc to finish starting " &&
2022-11-19 19:34:59 +00:00
( podman logs -f ${container_name} 2>&1 & ) | grep -q 'HTTP Server listening at ' &&
echo "OK" &&
podman pod stop ${pod_name} &&
echo Pod built and stopped. &&
shred -u .env