dev/install #58

Merged
tom_trgr merged 6 commits from dev/install into dev/pdf 2025-11-30 21:25:48 +01:00
Showing only changes of commit 8cb63d3342 - Show all commits

View File

@@ -1,13 +1,14 @@
#!/usr/bin/env bash
set -e
# --- CHECK PREREQUISITES -----------------------------------------------------
envFile=Docker/.env
envExample=Docker/env.example
echo "Checking Docker installation..."
if ! command -v docker >/dev/null 2>&1; then
echo "Docker not found. Install Docker? [y/N]"
read -r install_docker
if [ "$install_docker" = "y" ] || [ "$install_docker" = "Y" ]; then
if [[ "$install_docker" =~ ^[Yy]$ ]]; then
curl -fsSL https://get.docker.com | sh
else
echo "Docker is required. Exiting."
@@ -21,37 +22,41 @@ echo "Checking Docker Compose..."
if ! docker compose version >/dev/null 2>&1; then
echo "Docker Compose plugin missing. You may need to update Docker."
exit 1
else
echo "Docker Compose available."
fi
# --- LOAD ENV FILE ------------------------------------------------------------
echo "Preparing .env file..."
if [ ! -f $envFile ]; then
if [ -f $envExample ]; then
echo ".env not found. Creating interactively from .env.example."
> $envFile
if [ ! -f "Docker/.env" ]; then
echo ".env file not found in the current directory."
echo "Create one now? [y/N]"
read -r create_env
if [ "$create_env" = "y" ] || [ "$create_env" = "Y" ]; then
cp Docker/env.example Docker/.env 2>/dev/null || touch .env
echo "Created .env (./Docker/.env). Edit it before continuing."
exit 0
while IFS="=" read -r key val; do
[[ "$key" =~ ^#.*$ || -z "$key" ]] && continue
default_value=$(echo "$val" | sed 's/"//g')
printf "Value for $key (default: $default_value): "
read -r user_value < /dev/tty
if [ -z "$user_value" ]; then
echo "$key=$default_value" >> $envFile
else
echo "$key=$user_value" >> $envFile
fi
done < $envExample
echo ".env created."
else
echo "A .env file is required. Exiting."
exit 1
echo "No .env or .env.example found."
echo "Creating an empty .env file for manual editing."
touch $envFile
fi
else
echo "Using existing .env file (Docker/.env)."
echo "Using existing .env. (found at $envFile)"
fi
# --- START DOCKER COMPOSE -----------------------------------------------------
echo "Start containers now with docker compose up -d? [y/N]"
echo "Start containers with docker compose up -d? [y/N]"
read -r start_containers
if [ "$start_containers" = "y" ] || [ "$start_containers" = "Y" ]; then
cd Docker
if [[ "$start_containers" =~ ^[Yy]$ ]]; then
docker compose up -d
echo "Containers started."
else
echo "You can start containers manually with: docker compose up -d"
echo "You can start them manually with: docker compose up -d"
fi