#!/bin/sh # Run from the folder where you want to keep your Sydekyks installation. set -eu umask 077 fail() { printf '%s\n' "$*" >&2; exit 1; } command -v docker >/dev/null 2>&1 || fail 'Install Docker first: https://docs.docker.com/get-docker/' command -v curl >/dev/null 2>&1 || fail 'Install curl first, then run this script again.' docker info >/dev/null 2>&1 || fail 'Start Docker and check that your user can run docker, then try again.' [ "$(docker info --format '{{.OSType}}')" = linux ] || fail 'Switch Docker Desktop to Linux containers, then try again.' docker compose version >/dev/null 2>&1 || fail 'Install Docker Compose v2, then try again.' docker compose up --help | grep -q -- '--wait-timeout' || fail 'Update Docker Compose to a version that supports --wait-timeout.' mkdir -p sydekyks/deployment cd sydekyks temporary=$(mktemp -d deployment/.install-XXXXXX) trap 'rm -rf "$temporary"' EXIT trap 'exit 1' HUP INT TERM base=https://docs.sydekyks.com/resources/operators if [ ! -e deployment/compose.yaml ]; then curl -fsSL "$base/sydekyks-compose.yaml" -o "$temporary/compose.yaml" mv "$temporary/compose.yaml" deployment/compose.yaml fi if [ ! -e deployment/.env ]; then curl -fsSL "$base/sydekyks-env.example.txt" -o "$temporary/env.example" random_hex() { value=$(od -An -N "$1" -tx1 /dev/urandom | tr -d ' \n') [ "${#value}" -eq "$(( $1 * 2 ))" ] || fail 'Could not generate installation secrets.' printf '%s' "$value" } encryption=$(random_hex 16) jwt=$(random_hex 32) password=$(random_hex 24) sed -e "s/^AP_ENCRYPTION_KEY=$/AP_ENCRYPTION_KEY=$encryption/" \ -e "s/^AP_JWT_SECRET=$/AP_JWT_SECRET=$jwt/" \ -e "s/^AP_POSTGRES_PASSWORD=$/AP_POSTGRES_PASSWORD=$password/" \ "$temporary/env.example" > "$temporary/.env" mv "$temporary/.env" deployment/.env printf '%s\n' 'Created private configuration in sydekyks/deployment/.env.' else printf '%s\n' 'Reusing your existing configuration and secrets.' fi compose() { docker compose --env-file deployment/.env -f deployment/compose.yaml "$@"; } compose config --quiet printf '%s\n' 'Downloading and starting Sydekyks. The first run can take several minutes.' compose up -d --wait --wait-timeout 300 compose ps printf '%s\n' 'Sydekyks is running. Open your configured address (default: http://localhost:8080).' \ 'Create your first account to become the administrator.' \ 'Keep sydekyks/deployment/.env and your Docker volumes for backups and restarts.'