added install script

This commit is contained in:
2025-11-30 13:46:10 +01:00
parent 7e5eaebca9
commit 62c12cceba
3 changed files with 67 additions and 11 deletions

View File

@@ -1,11 +0,0 @@
POSTGRES_USER=root
POSTGRES_PASSWORD=very_secure
POSTGRES_API_USER=api_nutzer
POSTGRES_API_PASS=password
POSTGRES_PATH=../DB
POSTGRES_DB=arbeitszeitmessung
EXPOSED_PORT=8000
TZ=Europe/Berlin
PGTZ=Europe/Berlin
API_TOKEN=dont_access
EMPTY_DAYS=false

10
Docker/env.example Normal file
View File

@@ -0,0 +1,10 @@
POSTGRES_USER=root # Postgres ADMIN Nutzername
POSTGRES_PASSWORD=very_secure # Postgres ADMIN Passwort
POSTGRES_API_USER=api_nutzer # Postgres API Nutzername (für Arbeitszeitmessung)
POSTGRES_API_PASS=password # Postgres API Passwort (für Arbeitszeitmessung)
POSTGRES_PATH=../DB # Datebank Pfad (relativ zu Docker Ordner oder absoluter pfad mit /...)
POSTGRES_DB=arbeitszeitmessung # Postgres Datenbank Name
EXPOSED_PORT=8000 # Port auf welchem Arbeitszeitmessung läuft
TZ=Europe/Berlin # Zeitzone
PGTZ=Europe/Berlin # Zeitzone
API_TOKEN=dont_access # API Token für ESP Endpoints

57
install.sh Executable file
View File

@@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -e
# --- CHECK PREREQUISITES -----------------------------------------------------
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
curl -fsSL https://get.docker.com | sh
else
echo "Docker is required. Exiting."
exit 1
fi
else
echo "Docker is already installed."
fi
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 ------------------------------------------------------------
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
else
echo "A .env file is required. Exiting."
exit 1
fi
else
echo "Using existing .env file (Docker/.env)."
fi
# --- START DOCKER COMPOSE -----------------------------------------------------
echo "Start containers now with docker compose up -d? [y/N]"
read -r start_containers
if [ "$start_containers" = "y" ] || [ "$start_containers" = "Y" ]; then
cd Docker
docker compose up -d
echo "Containers started."
else
echo "You can start containers manually with: docker compose up -d"
fi