This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Reset Gardomatic demo data
|
||||
After=postgresql.service
|
||||
ConditionPathExists=/etc/gardomatic/demo-password
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=gardomatic
|
||||
Group=gardomatic
|
||||
EnvironmentFile=/etc/gardomatic/gardomatic.env
|
||||
WorkingDirectory=/var/lib/gardomatic
|
||||
StandardInput=file:/etc/gardomatic/demo-password
|
||||
ExecStart=/usr/local/bin/gardomatic-cli --yes demo reset --email ${GARDOMATIC_DEMO_ACCOUNT_EMAIL} --password-stdin
|
||||
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Reset Gardomatic demo data every night
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* 04:00:00 Europe/Berlin
|
||||
Persistent=true
|
||||
Unit=gardomatic-demo-reset.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
# Installs artifacts uploaded by `make production/deploy`. Run as root or as an
|
||||
# Installs artifacts uploaded by a Make deployment target. Run as root or as an
|
||||
# administrator with passwordless sudo.
|
||||
if [[ $(id -u) -ne 0 ]]; then
|
||||
exec sudo -n "$0" "$@"
|
||||
@@ -18,6 +18,8 @@ required_files=(
|
||||
cli
|
||||
api.service
|
||||
web.service
|
||||
demo-reset.service
|
||||
demo-reset.timer
|
||||
create-admin.sh
|
||||
)
|
||||
for file in "${required_files[@]}"; do
|
||||
@@ -31,11 +33,11 @@ done
|
||||
exit 1
|
||||
}
|
||||
[[ -f "$ENV_FILE" ]] || {
|
||||
printf 'Missing runtime configuration: %s; run production/provision first.\n' "$ENV_FILE" >&2
|
||||
printf 'Missing runtime configuration: %s; provision this deployment target first.\n' "$ENV_FILE" >&2
|
||||
exit 1
|
||||
}
|
||||
id gardomatic >/dev/null 2>&1 || {
|
||||
printf 'Missing service user gardomatic; run production/provision first.\n' >&2
|
||||
printf 'Missing service user gardomatic; provision this deployment target first.\n' >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -49,6 +51,8 @@ rsync --archive --delete "$SCRIPT_DIR/migrations/" "$APPLICATION_DIR/migrations/
|
||||
|
||||
install -m 0644 -o root -g root "$SCRIPT_DIR/api.service" /etc/systemd/system/api.service
|
||||
install -m 0644 -o root -g root "$SCRIPT_DIR/web.service" /etc/systemd/system/web.service
|
||||
install -m 0644 -o root -g root "$SCRIPT_DIR/demo-reset.service" /etc/systemd/system/gardomatic-demo-reset.service
|
||||
install -m 0644 -o root -g root "$SCRIPT_DIR/demo-reset.timer" /etc/systemd/system/gardomatic-demo-reset.timer
|
||||
install -m 0755 -o root -g root "$SCRIPT_DIR/create-admin.sh" /usr/local/sbin/gardomatic-create-admin
|
||||
|
||||
# provision-server.sh writes a file compatible with systemd and Bash. Loading it
|
||||
@@ -61,6 +65,22 @@ migrate -path "$APPLICATION_DIR/migrations" -database "$GARDOMATIC_DB_DSN" up
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable api web
|
||||
if [[ "${GARDOMATIC_DEMO_RESET_ENABLED:-false}" == true ]]; then
|
||||
[[ -n "${GARDOMATIC_DEMO_ACCOUNT_EMAIL:-}" ]] || {
|
||||
printf 'Demo reset is enabled, but GARDOMATIC_DEMO_ACCOUNT_EMAIL is empty.\n' >&2
|
||||
exit 1
|
||||
}
|
||||
[[ -f /etc/gardomatic/demo-password ]] || {
|
||||
printf 'Demo reset is enabled, but /etc/gardomatic/demo-password is missing.\n' >&2
|
||||
exit 1
|
||||
}
|
||||
chown root:gardomatic /etc/gardomatic/demo-password
|
||||
chmod 0640 /etc/gardomatic/demo-password
|
||||
systemctl enable --now gardomatic-demo-reset.timer
|
||||
systemctl start gardomatic-demo-reset.service
|
||||
else
|
||||
systemctl disable --now gardomatic-demo-reset.timer >/dev/null 2>&1 || true
|
||||
fi
|
||||
systemctl restart api web
|
||||
|
||||
printf 'Gardomatic deployment complete.\n'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Copy this file to .env next to provision-server.sh and restrict it to the
|
||||
# administrator. The file is sourced as Bash configuration and must be trusted.
|
||||
# cp .env.example .env
|
||||
# chmod 600 .env
|
||||
# Copy this template to .env, .env.testserver, and .env.demo as needed. Keep
|
||||
# separate database credentials and URLs in every file. The files are sourced
|
||||
# as Bash configuration and must be trusted and restricted to the administrator.
|
||||
# `make config/init` creates all three with mode 0600.
|
||||
|
||||
# Server provisioning ---------------------------------------------------------
|
||||
|
||||
@@ -70,6 +70,13 @@ GARDOMATIC_RATE_LIMIT_BURST='40'
|
||||
# https://garden.example.com,https://admin.example.com
|
||||
GARDOMATIC_CORS_TRUSTED_ORIGINS=''
|
||||
|
||||
# Destructive demo reset. Leave false on every non-demo database. When true,
|
||||
# deployments require /etc/gardomatic/demo-password and enable the nightly timer.
|
||||
GARDOMATIC_DEMO_RESET_ENABLED='false'
|
||||
# Required when the demo reset is enabled. The API protects this shared account's
|
||||
# profile, email address, password and sessions from changes by visitors.
|
||||
GARDOMATIC_DEMO_ACCOUNT_EMAIL=''
|
||||
|
||||
# Delivery mode. Allowed exactly: file or smtp. Production normally uses smtp.
|
||||
GARDOMATIC_SMTP_MODE='smtp'
|
||||
# Required in smtp mode: resolvable SMTP hostname and TCP port.
|
||||
|
||||
@@ -74,6 +74,12 @@ require_variable GARDOMATIC_WEB_BASE_URL
|
||||
require_identifier GARDOMATIC_DB_NAME
|
||||
require_identifier GARDOMATIC_DB_USER
|
||||
|
||||
GARDOMATIC_DEMO_RESET_ENABLED=${GARDOMATIC_DEMO_RESET_ENABLED:-false}
|
||||
[[ "$GARDOMATIC_DEMO_RESET_ENABLED" == true || "$GARDOMATIC_DEMO_RESET_ENABLED" == false ]] || die "GARDOMATIC_DEMO_RESET_ENABLED must be true or false"
|
||||
if [[ "$GARDOMATIC_DEMO_RESET_ENABLED" == true ]]; then
|
||||
require_variable GARDOMATIC_DEMO_ACCOUNT_EMAIL
|
||||
fi
|
||||
|
||||
case "${GARDOMATIC_SMTP_MODE:-file}" in
|
||||
smtp)
|
||||
require_variable GARDOMATIC_SMTP_HOST
|
||||
@@ -218,6 +224,8 @@ runtime_variables=(
|
||||
GARDOMATIC_RATE_LIMIT_RPS
|
||||
GARDOMATIC_RATE_LIMIT_BURST
|
||||
GARDOMATIC_CORS_TRUSTED_ORIGINS
|
||||
GARDOMATIC_DEMO_RESET_ENABLED
|
||||
GARDOMATIC_DEMO_ACCOUNT_EMAIL
|
||||
GARDOMATIC_SMTP_MODE
|
||||
GARDOMATIC_SMTP_HOST
|
||||
GARDOMATIC_SMTP_PORT
|
||||
|
||||
Reference in New Issue
Block a user