Files
2025-07-20 15:02:38 -05:00

82 lines
2.4 KiB
Bash

#!/bin/bash
# Gisgraphy Docker Setup Script
# This script creates the necessary directory structure and sets permissions
set -e
# Default configuration - CUSTOMIZE THESE VALUES
DEFAULT_DATA_DIR="/home/localuser/KNELDevStack-CDS/docker-data/GIS/gisgraphy"
DEFAULT_USER="localuser"
# Allow command line arguments to override defaults
DATA_DIR="${1:-$DEFAULT_DATA_DIR}"
USER="${2:-$DEFAULT_USER}"
echo "🚀 Setting up Gisgraphy data directory structure..."
echo "📁 Data directory: $DATA_DIR"
echo "👤 User: $USER"
echo ""
# Validate user exists
if ! id "$USER" &>/dev/null; then
echo "❌ Error: User '$USER' does not exist!"
echo "💡 Usage: $0 [DATA_DIR] [USER]"
echo "💡 Example: $0 /path/to/your/data/gisgraphy yourusername"
exit 1
fi
# Create the main data directory and subdirectories
echo "📂 Creating directory structure at $DATA_DIR"
mkdir -p "$DATA_DIR"/{data,app,logs,config,dumps}
# Set ownership
echo "🔑 Setting ownership to $USER:$USER"
sudo chown -R "$USER:$USER" "$DATA_DIR"
# Set permissions
echo "🔒 Setting permissions (755)"
chmod -R 755 "$DATA_DIR"
# Create a simple README in the data directory
cat > "$DATA_DIR/README.md" << EOF
# Gisgraphy Data Directory
This directory contains all persistent data for your Gisgraphy Docker setup.
## Directory Structure:
- **data/**: PostgreSQL database files
- **app/**: Gisgraphy application files and configuration
- **logs/**: Application and system logs
- **config/**: Custom Gisgraphy configuration files (place custom configs here)
- **dumps/**: Data import files (place premium dump files here)
## Configuration:
- Data Path: $DATA_DIR
- Owner: $USER
- Created: $(date)
## Setup by: Gisgraphy Docker Compose configuration
EOF
echo "✅ Directory structure created successfully!"
echo ""
echo "📁 Data directory: $DATA_DIR"
echo "📋 Structure:"
tree "$DATA_DIR" 2>/dev/null || ls -la "$DATA_DIR"
echo ""
echo "⚠️ IMPORTANT: Before running docker-compose:"
echo "1. 📝 Edit .env file and update the data directory path:"
echo " GISGRAPHY_DATA_DIR=$DATA_DIR"
echo ""
echo "2. 🌐 Edit .env file and set your desired ports:"
echo " GISGRAPHY_WEB_PORT=12001"
echo " GISGRAPHY_API_PORT=12002"
echo ""
echo "3. 🚀 Start the services:"
echo " docker-compose up -d"
echo ""
echo "4. 🌍 Access Gisgraphy at:"
echo " http://localhost:12001 (or your configured port)"
echo ""
echo "📖 For complete setup instructions, see SetupGuide.md"