generated from oci/template
clense for rebuild
This commit is contained in:
parent
40fc5d810a
commit
c772f0ca99
13 changed files with 19 additions and 1557 deletions
|
@ -1,47 +0,0 @@
|
|||
name: Build Docker Image on Commit
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- '!' # Exclude tags
|
||||
|
||||
jobs:
|
||||
build-and-publish:
|
||||
runs-on: docker-builder
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set REPO_VARS
|
||||
id: repo-url
|
||||
run: |
|
||||
echo "REPO_HOST=$(echo "${{ github.server_url }}" | sed 's~http[s]*://~~g')" >> $GITHUB_ENV
|
||||
echo "REPO_PATH=${{ github.repository }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
driver: docker-container
|
||||
driver-opts: |
|
||||
network=host
|
||||
|
||||
- name: Login to OCI registry
|
||||
run: |
|
||||
echo "${{ secrets.OCI_TOKEN }}" | docker login $REPO_HOST -u "${{ secrets.OCI_USER }}" --password-stdin
|
||||
|
||||
- name: Build and push multi-arch Docker images
|
||||
run: |
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--tag $REPO_HOST/$REPO_PATH:${{ github.sha }} \
|
||||
--tag $REPO_HOST/$REPO_PATH:nightly \
|
||||
--push \
|
||||
.
|
||||
|
||||
- name: Cleanup
|
||||
run: |
|
||||
docker buildx prune -f
|
||||
docker logout $REPO_HOST
|
|
@ -1,46 +0,0 @@
|
|||
name: Build and Publish Docker Image on Tag
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
build-and-publish:
|
||||
runs-on: docker-builder
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set REPO_VARS
|
||||
id: repo-url
|
||||
run: |
|
||||
echo "REPO_HOST=$(echo "${{ github.server_url }}" | sed 's~http[s]*://~~g')" >> $GITHUB_ENV
|
||||
echo "REPO_PATH=${{ github.repository }}" >> $GITHUB_ENV
|
||||
echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
driver: docker-container
|
||||
driver-opts: |
|
||||
network=host
|
||||
|
||||
- name: Login to OCI registry
|
||||
run: |
|
||||
echo "${{ secrets.OCI_TOKEN }}" | docker login $REPO_HOST -u "${{ secrets.OCI_USER }}" --password-stdin
|
||||
|
||||
- name: Build and push Docker images
|
||||
run: |
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--tag $REPO_HOST/$REPO_PATH:$TAG \
|
||||
--tag $REPO_HOST/$REPO_PATH:latest \
|
||||
--push \
|
||||
.
|
||||
|
||||
- name: Cleanup
|
||||
run: |
|
||||
docker buildx prune -f
|
||||
docker logout $REPO_HOST
|
18
.gitignore
vendored
18
.gitignore
vendored
|
@ -1,3 +1,21 @@
|
|||
# Environment files
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# TAK Server release files
|
||||
takserver-release/*.zip
|
||||
takserver-release/*.tar.gz
|
||||
|
||||
# Data directories
|
||||
*/data/
|
||||
|
||||
|
||||
# Local overrides
|
||||
docker-compose.override.yml
|
||||
docker-compose.local.yml
|
||||
|
||||
# Original files and releases (legacy)
|
||||
/original-files
|
||||
/takserver-release
|
||||
/data
|
46
Dockerfile
46
Dockerfile
|
@ -1,46 +0,0 @@
|
|||
FROM eclipse-temurin:17-jammy
|
||||
|
||||
# Install all required packages
|
||||
RUN apt-get update && apt-get install -y \
|
||||
postgresql-common \
|
||||
emacs-nox \
|
||||
net-tools \
|
||||
netcat \
|
||||
vim \
|
||||
unzip \
|
||||
curl \
|
||||
sudo \
|
||||
gosu
|
||||
|
||||
RUN yes | /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
|
||||
RUN apt-get update && apt-get install -y \
|
||||
postgresql-15 \
|
||||
postgresql-15-postgis-3 \
|
||||
postgresql-client-15 \
|
||||
postgresql-contrib-15
|
||||
|
||||
RUN apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create tak user and directories
|
||||
RUN useradd -m -s /bin/bash tak && \
|
||||
mkdir -p /opt/tak /opt/tak/logs /takserver-zip && \
|
||||
chown -R tak:tak /opt/tak
|
||||
|
||||
# Configure PostgreSQL data directory (initialization will be done at runtime)
|
||||
RUN mkdir -p /var/lib/postgresql/15/main && \
|
||||
chown -R postgres:postgres /var/lib/postgresql
|
||||
|
||||
# Copy all scripts into the container
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
COPY scripts/ /scripts/
|
||||
|
||||
# Make all scripts executable
|
||||
RUN chmod +x /entrypoint.sh && \
|
||||
chmod +x /scripts/*.sh
|
||||
|
||||
# Expose common TAK server ports
|
||||
EXPOSE 5432 8080 8443 8444 8446
|
||||
|
||||
# Set the entrypoint
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
224
README.md
224
README.md
|
@ -1,224 +0,0 @@
|
|||
# TAK Server Hybrid Docker Container
|
||||
|
||||
This Docker container combines both the TAK server and PostgreSQL database functionality into a single container. It automatically detects and uses the latest TAK server release from the mounted volume.
|
||||
|
||||
## ⚠️ IMPORTANT: TAK Server Files Required
|
||||
|
||||
**This container does NOT include TAK server files due to licensing restrictions.** You must provide your own TAK server release files obtained through proper channels:
|
||||
|
||||
1. Download TAK server files from the official TAK.gov website
|
||||
2. Obtain through proper military/government channels
|
||||
3. Purchase through authorized distributors
|
||||
|
||||
**You must have a valid license to use TAK server software.**
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. **Valid TAK Server License**: You must have proper licensing/authorization to use TAK server
|
||||
2. **TAK Server Files**: Download `takserver-docker-X.Y-RELEASE-Z.zip` from official sources
|
||||
3. **Docker & Docker Compose**: Installed on your system
|
||||
|
||||
## Setup Instructions
|
||||
|
||||
### Step 1: Obtain TAK Server Files
|
||||
- Download the TAK server Docker release from official channels
|
||||
- Place the `takserver-docker-X.Y-RELEASE-Z.zip` file in the `takserver-release/` directory
|
||||
- The container will automatically detect and use the latest version
|
||||
|
||||
### Step 2: File Structure
|
||||
```
|
||||
/docker/services/tak/
|
||||
├── Dockerfile # Hybrid container
|
||||
├── entrypoint.sh # Main container entrypoint
|
||||
├── scripts/ # Helper scripts
|
||||
│ ├── tak-version.sh # TAK version detection
|
||||
│ ├── db-setup.sh # Database setup
|
||||
│ └── healthcheck.sh # Health monitoring
|
||||
├── docker-compose.yml # Docker Compose configuration
|
||||
├── README.md # This documentation
|
||||
├── build.sh # Build script
|
||||
├── validate.sh # Setup validation script
|
||||
├── original-files/ # Original Dockerfile templates
|
||||
└── takserver-release/ # Place your TAK server files here
|
||||
└── takserver-docker-X.Y-RELEASE-Z.zip # Your TAK server files
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- **Hybrid Architecture**: Combines TAK server and PostgreSQL database in one container
|
||||
- **Automatic Version Detection**: Finds the latest `takserver-docker-X.Y-RELEASE-Z.zip` file
|
||||
- **Semantic Versioning**: Uses semantic version sorting to determine the latest release
|
||||
- **Complete Setup**: Includes PostGIS extension for spatial data support
|
||||
- **Runtime TAK Setup**: TAK server files are processed at container startup (licensing compliant)
|
||||
- **User-Provided Files**: No TAK server files included in the image
|
||||
|
||||
## Usage
|
||||
|
||||
### Option 1: Using Docker Compose (Recommended)
|
||||
|
||||
**First, ensure you have TAK server files in the correct directory:**
|
||||
```bash
|
||||
# Verify your TAK server files
|
||||
ls -la takserver-release/
|
||||
# Should show: takserver-docker-X.Y-RELEASE-Z.zip
|
||||
|
||||
# Build and start the hybrid container
|
||||
docker-compose up -d
|
||||
|
||||
# View logs to monitor startup
|
||||
docker-compose logs -f tak-hybrid
|
||||
|
||||
# Stop the container
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
### Option 2: Using Docker directly
|
||||
|
||||
```bash
|
||||
# Build the image
|
||||
docker build -t tak-hybrid .
|
||||
|
||||
# Run the container (replace /path/to/tak/files with your actual path)
|
||||
docker run -d \
|
||||
--name tak-hybrid \
|
||||
-p 5432:5432 \
|
||||
-p 8080:8080 \
|
||||
-p 8443:8443 \
|
||||
-p 8444:8444 \
|
||||
-v /path/to/tak/files:/takserver-zip:ro \
|
||||
-v tak-data:/opt/tak/data \
|
||||
-v tak-logs:/opt/tak/logs \
|
||||
tak-hybrid
|
||||
```
|
||||
|
||||
## TAK Server Release Files
|
||||
|
||||
Place your TAK server release files in the `takserver-release/` directory. The container will automatically detect and use the latest version based on semantic versioning.
|
||||
|
||||
**Supported filename format**: `takserver-docker-X.Y-RELEASE-Z.zip`
|
||||
|
||||
Examples:
|
||||
- `takserver-docker-5.4-RELEASE-19.zip`
|
||||
- `takserver-docker-5.5-RELEASE-1.zip`
|
||||
- `takserver-docker-6.0-RELEASE-5.zip`
|
||||
|
||||
## Ports
|
||||
|
||||
- **5432**: PostgreSQL database
|
||||
- **8080**: TAK server web interface (HTTP)
|
||||
- **8443**: TAK server web interface (HTTPS)
|
||||
- **8444**: TAK server certificate enrollment
|
||||
- **8446**: TAK server API
|
||||
|
||||
## Database Configuration
|
||||
|
||||
The container automatically sets up PostgreSQL with:
|
||||
- Database: `cot`
|
||||
- User: `martiuser`
|
||||
- Password: `password`
|
||||
- PostGIS extension enabled
|
||||
|
||||
## Environment Variables
|
||||
|
||||
The following environment variables can be customized in the docker-compose.yml:
|
||||
|
||||
- `POSTGRES_DB`: Database name (default: cot)
|
||||
- `POSTGRES_USER`: Database user (default: martiuser)
|
||||
- `POSTGRES_PASSWORD`: Database password (default: password)
|
||||
|
||||
## Helper Scripts
|
||||
|
||||
The container includes several helper scripts for management and troubleshooting:
|
||||
|
||||
### TAK Version Detection (`/scripts/tak-version.sh`)
|
||||
```bash
|
||||
# Find latest TAK release
|
||||
docker exec tak-hybrid /scripts/tak-version.sh /takserver-zip latest
|
||||
|
||||
# List all available releases
|
||||
docker exec tak-hybrid /scripts/tak-version.sh /takserver-zip list
|
||||
|
||||
# Get version from specific file
|
||||
docker exec tak-hybrid /scripts/tak-version.sh /takserver-zip version /takserver-zip/takserver-docker-5.4-RELEASE-19.zip
|
||||
```
|
||||
|
||||
### Database Setup (`/scripts/db-setup.sh`)
|
||||
```bash
|
||||
# Full database setup
|
||||
docker exec tak-hybrid /scripts/db-setup.sh setup
|
||||
|
||||
# Test database connection
|
||||
docker exec tak-hybrid /scripts/db-setup.sh test
|
||||
|
||||
# Print database configuration
|
||||
docker exec tak-hybrid /scripts/db-setup.sh config
|
||||
```
|
||||
|
||||
### Health Monitoring (`/scripts/healthcheck.sh`)
|
||||
```bash
|
||||
# Run all health checks
|
||||
docker exec tak-hybrid /scripts/healthcheck.sh all
|
||||
|
||||
# Check specific components
|
||||
docker exec tak-hybrid /scripts/healthcheck.sh postgres
|
||||
docker exec tak-hybrid /scripts/healthcheck.sh database
|
||||
docker exec tak-hybrid /scripts/healthcheck.sh tak-process
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Check container logs
|
||||
```bash
|
||||
docker-compose logs tak-hybrid
|
||||
```
|
||||
|
||||
### Access the container shell
|
||||
```bash
|
||||
docker-compose exec tak-hybrid /bin/bash
|
||||
```
|
||||
|
||||
### Verify PostgreSQL is running
|
||||
```bash
|
||||
docker-compose exec tak-hybrid pg_isready -U martiuser -d cot
|
||||
```
|
||||
|
||||
### Check TAK server status
|
||||
```bash
|
||||
docker-compose exec tak-hybrid ps aux | grep tak
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
The container includes comprehensive error checking:
|
||||
|
||||
### Missing TAK Server Files
|
||||
```
|
||||
ERROR: No TAK server files found!
|
||||
Please mount a directory containing takserver-docker-X.Y-RELEASE-Z.zip files to /takserver-zip
|
||||
```
|
||||
**Solution**: Ensure you have properly mounted the directory containing your TAK server files.
|
||||
|
||||
### Invalid File Format
|
||||
```
|
||||
ERROR: No takserver-docker-X.Y-RELEASE-Z.zip file found in /takserver-zip/
|
||||
Please ensure you have a file matching the pattern: takserver-docker-X.Y-RELEASE-Z.zip
|
||||
```
|
||||
**Solution**: Verify your TAK server file follows the correct naming convention.
|
||||
|
||||
### Licensing Compliance
|
||||
|
||||
This container design ensures license compliance by:
|
||||
- **Not redistributing TAK server files**
|
||||
- **Requiring users to provide their own licensed files**
|
||||
- **Processing files only at runtime**
|
||||
- **Clear documentation of licensing requirements**
|
||||
|
||||
## Legal Notice
|
||||
|
||||
TAK server software is subject to export control regulations and licensing requirements. Users are responsible for:
|
||||
- Obtaining proper licenses/authorization
|
||||
- Compliance with export control laws
|
||||
- Following all applicable regulations
|
||||
- Ensuring authorized use only
|
||||
|
||||
This container does not include or redistribute any TAK server software files.
|
|
@ -1,29 +0,0 @@
|
|||
networks:
|
||||
webserver:
|
||||
external: true
|
||||
|
||||
|
||||
volumes:
|
||||
takserver:
|
||||
postgres-data:
|
||||
|
||||
services:
|
||||
tak-hybrid:
|
||||
build: .
|
||||
# image: git.merith.xyz/oci/takserver:nightly
|
||||
restart: no
|
||||
ports:
|
||||
- "5432:5432" # PostgreSQL
|
||||
- "8080:8080" # TAK server web UI (typical port)
|
||||
- "8443:8443" # TAK server HTTPS (typical port)
|
||||
- "8444:8444" # TAK server cert enrollment (typical port)
|
||||
networks:
|
||||
- webserver
|
||||
volumes:
|
||||
- ./takserver-release:/takserver-zip:ro
|
||||
- ./data/takserver:/opt/tak
|
||||
- ./data/postgres-data:/var/lib/postgresql/15/main
|
||||
environment:
|
||||
POSTGRES_DB: default_db
|
||||
POSTGRES_USER: default_user
|
||||
POSTGRES_PASSWORD: default_password
|
354
entrypoint.sh
354
entrypoint.sh
|
@ -1,354 +0,0 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Colors for logging
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $(date '+%Y-%m-%d %H:%M:%S') - $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $(date '+%Y-%m-%d %H:%M:%S') - $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $(date '+%Y-%m-%d %H:%M:%S') - $1"
|
||||
}
|
||||
|
||||
log_debug() {
|
||||
echo -e "${BLUE}[DEBUG]${NC} $(date '+%Y-%m-%d %H:%M:%S') - $1"
|
||||
}
|
||||
|
||||
log_info "Starting TAK Server Hybrid Container..."
|
||||
|
||||
# Ensure proper ownership of key directories
|
||||
log_debug "Enforcing ownership permissions..."
|
||||
chown -R tak:tak /opt/tak 2>/dev/null || true
|
||||
chown -R postgres:postgres /var/lib/postgresql 2>/dev/null || true
|
||||
log_debug "Ownership permissions enforced"
|
||||
|
||||
# Source helper scripts
|
||||
log_debug "Sourcing helper scripts..."
|
||||
source /scripts/tak-version.sh
|
||||
log_debug "Helper scripts loaded successfully"
|
||||
|
||||
# Check if TAK server files are provided
|
||||
log_info "Checking for TAK server files..."
|
||||
log_debug "Looking for files in /takserver-zip directory..."
|
||||
|
||||
if [ ! -d "/takserver-zip" ]; then
|
||||
log_error "Mount point /takserver-zip does not exist!"
|
||||
log_error "Please ensure you mount a directory containing TAK server files"
|
||||
log_error "Example: docker run -v /path/to/tak/files:/takserver-zip:ro ..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if directory is empty
|
||||
if [ ! "$(ls -A /takserver-zip 2>/dev/null)" ]; then
|
||||
log_error "Directory /takserver-zip is empty!"
|
||||
log_error "Please place takserver-docker-X.Y-RELEASE-Z.zip files in the mounted directory"
|
||||
log_debug "Directory contents:"
|
||||
ls -l /takserver-zip/ || log_debug "Cannot list directory contents"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# List all files in the directory for debugging
|
||||
log_debug "Contents of /takserver-zip:"
|
||||
ls -l /takserver-zip/ | while read line; do
|
||||
log_debug " $line"
|
||||
done
|
||||
|
||||
# Check for zip files specifically
|
||||
ZIP_COUNT=$(find /takserver-zip -name "*.zip" -type f | wc -l)
|
||||
log_debug "Found $ZIP_COUNT zip files in /takserver-zip"
|
||||
|
||||
if [ $ZIP_COUNT -eq 0 ]; then
|
||||
log_error "No zip files found in /takserver-zip!"
|
||||
log_error "Please ensure you have takserver-docker-X.Y-RELEASE-Z.zip files"
|
||||
log_debug "Available files:"
|
||||
find /takserver-zip -type f | while read file; do
|
||||
log_debug " $(basename $file)"
|
||||
done
|
||||
while true; do sleep 3600; done
|
||||
fi
|
||||
|
||||
# Check for TAK server specific zip files
|
||||
TAK_ZIP_COUNT=$(find /takserver-zip -name "takserver-docker-*-RELEASE-*.zip" -type f | wc -l)
|
||||
log_debug "Found $TAK_ZIP_COUNT TAK server zip files"
|
||||
|
||||
if [ $TAK_ZIP_COUNT -eq 0 ]; then
|
||||
log_error "No TAK server zip files found matching pattern 'takserver-docker-*-RELEASE-*.zip'!"
|
||||
log_error "Available zip files:"
|
||||
find /takserver-zip -name "*.zip" -type f | while read file; do
|
||||
log_error " $(basename $file)"
|
||||
done
|
||||
log_error "Required format: takserver-docker-X.Y-RELEASE-Z.zip"
|
||||
log_error "Example: takserver-docker-5.4-RELEASE-19.zip"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use the helper script to find the latest TAK release
|
||||
log_info "Finding latest TAK server release..."
|
||||
LATEST_ZIP=$(find_latest_tak_release /takserver-zip)
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "Failed to find latest TAK release: $LATEST_ZIP"
|
||||
log_info "Available TAK releases:"
|
||||
list_tak_releases /takserver-zip
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "Found latest TAK server release: $(basename $LATEST_ZIP)"
|
||||
log_info "Version: $(get_tak_version $LATEST_ZIP)"
|
||||
log_debug "Full path: $LATEST_ZIP"
|
||||
|
||||
# Extract the zip file if not already extracted
|
||||
if [ ! -f /opt/tak/configureInDocker.sh ]; then
|
||||
log_info "TAK server files not found - extracting from ZIP..."
|
||||
log_debug "Using extraction script: /scripts/tak-extract.sh"
|
||||
|
||||
# Use the extraction script
|
||||
if /scripts/tak-extract.sh extract "$LATEST_ZIP" /opt/tak; then
|
||||
log_info "TAK server extraction completed successfully"
|
||||
|
||||
# Set proper permissions
|
||||
/scripts/tak-extract.sh permissions /opt/tak tak:tak
|
||||
|
||||
# Verify installation
|
||||
if /scripts/tak-extract.sh verify /opt/tak; then
|
||||
log_info "TAK server installation verified"
|
||||
else
|
||||
log_error "TAK server installation verification failed!"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
log_error "Failed to extract TAK server files!"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
log_info "TAK server files already exist - skipping extraction"
|
||||
log_debug "Found existing configureInDocker.sh at /opt/tak/configureInDocker.sh"
|
||||
|
||||
# Ensure permissions are correct on existing files
|
||||
log_debug "Ensuring correct permissions on existing TAK files..."
|
||||
/scripts/tak-extract.sh permissions /opt/tak tak:tak
|
||||
|
||||
# Also enforce ownership at the directory level
|
||||
log_debug "Enforcing TAK directory ownership..."
|
||||
chown -R tak:tak /opt/tak
|
||||
fi
|
||||
|
||||
# Start PostgreSQL
|
||||
log_info "Starting PostgreSQL..."
|
||||
|
||||
# Ensure PostgreSQL directories have correct ownership
|
||||
log_debug "Enforcing PostgreSQL directory ownership..."
|
||||
chown -R postgres:postgres /var/lib/postgresql
|
||||
chown -R postgres:postgres /var/run/postgresql 2>/dev/null || true
|
||||
|
||||
# Initialize PostgreSQL if not already done
|
||||
if [ ! -f /var/lib/postgresql/15/main/PG_VERSION ]; then
|
||||
log_info "Initializing PostgreSQL database cluster..."
|
||||
if sudo -u postgres /usr/lib/postgresql/15/bin/initdb -D /var/lib/postgresql/15/main; then
|
||||
log_info "PostgreSQL initialized successfully"
|
||||
|
||||
# Configure PostgreSQL
|
||||
log_info "Configuring PostgreSQL..."
|
||||
|
||||
# Create postgresql.conf
|
||||
log_debug "Creating postgresql.conf..."
|
||||
cat > /tmp/postgresql.conf <<EOF
|
||||
listen_addresses = '*'
|
||||
port = 5432
|
||||
max_connections = 100
|
||||
shared_buffers = 128MB
|
||||
log_timezone = 'UTC'
|
||||
timezone = 'UTC'
|
||||
EOF
|
||||
sudo -u postgres cp /tmp/postgresql.conf /var/lib/postgresql/15/main/postgresql.conf
|
||||
|
||||
# Create pg_hba.conf
|
||||
log_debug "Creating pg_hba.conf..."
|
||||
cat > /tmp/pg_hba.conf <<EOF
|
||||
# PostgreSQL Client Authentication Configuration File
|
||||
local all all trust
|
||||
host all all 127.0.0.1/32 trust
|
||||
host all all ::1/128 trust
|
||||
host all all 0.0.0.0/0 md5
|
||||
EOF
|
||||
sudo -u postgres cp /tmp/pg_hba.conf /var/lib/postgresql/15/main/pg_hba.conf
|
||||
|
||||
# Verify config files were created
|
||||
if [ -f /var/lib/postgresql/15/main/postgresql.conf ]; then
|
||||
log_debug "postgresql.conf created successfully"
|
||||
else
|
||||
log_error "Failed to create postgresql.conf!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f /var/lib/postgresql/15/main/pg_hba.conf ]; then
|
||||
log_debug "pg_hba.conf created successfully"
|
||||
else
|
||||
log_error "Failed to create pg_hba.conf!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "PostgreSQL configuration completed"
|
||||
|
||||
# Ensure ownership is correct after configuration
|
||||
log_debug "Ensuring PostgreSQL ownership after configuration..."
|
||||
chown -R postgres:postgres /var/lib/postgresql/15/main
|
||||
else
|
||||
log_error "Failed to initialize PostgreSQL!"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
log_info "PostgreSQL already initialized"
|
||||
|
||||
# Check if config files exist, create them if they don't
|
||||
if [ ! -f /var/lib/postgresql/15/main/postgresql.conf ]; then
|
||||
log_info "Creating missing postgresql.conf..."
|
||||
|
||||
# Create postgresql.conf
|
||||
log_debug "Creating postgresql.conf..."
|
||||
cat > /tmp/postgresql.conf <<EOF
|
||||
listen_addresses = '*'
|
||||
port = 5432
|
||||
max_connections = 100
|
||||
shared_buffers = 128MB
|
||||
log_timezone = 'UTC'
|
||||
timezone = 'UTC'
|
||||
EOF
|
||||
sudo -u postgres cp /tmp/postgresql.conf /var/lib/postgresql/15/main/postgresql.conf
|
||||
fi
|
||||
|
||||
if [ ! -f /var/lib/postgresql/15/main/pg_hba.conf ]; then
|
||||
log_info "Creating missing pg_hba.conf..."
|
||||
|
||||
# Create pg_hba.conf
|
||||
log_debug "Creating pg_hba.conf..."
|
||||
cat > /tmp/pg_hba.conf <<EOF
|
||||
# PostgreSQL Client Authentication Configuration File
|
||||
local all all trust
|
||||
host all all 127.0.0.1/32 trust
|
||||
host all all ::1/128 trust
|
||||
host all all 0.0.0.0/0 md5
|
||||
EOF
|
||||
sudo -u postgres cp /tmp/pg_hba.conf /var/lib/postgresql/15/main/pg_hba.conf
|
||||
fi
|
||||
|
||||
log_debug "Configuration files checked/created"
|
||||
|
||||
# Ensure ownership is correct after any config file creation
|
||||
log_debug "Ensuring PostgreSQL ownership after config check..."
|
||||
chown -R postgres:postgres /var/lib/postgresql/15/main
|
||||
fi
|
||||
|
||||
# Start PostgreSQL server
|
||||
log_info "Starting PostgreSQL server..."
|
||||
|
||||
# Verify config files exist before starting
|
||||
log_debug "Checking configuration files..."
|
||||
if [ -f /var/lib/postgresql/15/main/postgresql.conf ]; then
|
||||
log_debug "postgresql.conf exists"
|
||||
else
|
||||
log_error "postgresql.conf missing!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f /var/lib/postgresql/15/main/pg_hba.conf ]; then
|
||||
log_debug "pg_hba.conf exists"
|
||||
else
|
||||
log_error "pg_hba.conf missing!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Show the contents of the data directory
|
||||
log_debug "Contents of PostgreSQL data directory:"
|
||||
ls -la /var/lib/postgresql/15/main/ | while read line; do
|
||||
log_debug " $line"
|
||||
done
|
||||
|
||||
# Start PostgreSQL with verbose logging to catch any errors
|
||||
log_debug "Starting PostgreSQL with command: sudo -u postgres /usr/lib/postgresql/15/bin/postgres -D /var/lib/postgresql/15/main"
|
||||
sudo -u postgres /usr/lib/postgresql/15/bin/postgres -D /var/lib/postgresql/15/main &
|
||||
POSTGRES_PID=$!
|
||||
log_debug "PostgreSQL started with PID: $POSTGRES_PID"
|
||||
|
||||
# Give PostgreSQL a moment to start
|
||||
sleep 2
|
||||
|
||||
# Check if the process is still running
|
||||
if kill -0 $POSTGRES_PID 2>/dev/null; then
|
||||
log_debug "PostgreSQL process is still running"
|
||||
else
|
||||
log_error "PostgreSQL process died immediately!"
|
||||
log_error "Checking system logs for errors..."
|
||||
# Try to get any error output
|
||||
journalctl -u postgresql --no-pager --lines=10 2>/dev/null || log_debug "No journalctl available"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Wait for PostgreSQL to start and setup database
|
||||
log_info "Waiting for PostgreSQL to be ready..."
|
||||
POSTGRES_READY=0
|
||||
for i in {1..30}; do
|
||||
if pg_isready -h localhost -p 5432 >/dev/null 2>&1; then
|
||||
POSTGRES_READY=1
|
||||
log_info "PostgreSQL is ready after ${i} seconds"
|
||||
break
|
||||
fi
|
||||
log_debug "PostgreSQL not ready yet, waiting... (attempt $i/30)"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ $POSTGRES_READY -eq 0 ]; then
|
||||
log_error "PostgreSQL failed to become ready after 30 seconds!"
|
||||
log_error "Checking PostgreSQL process status..."
|
||||
if kill -0 $POSTGRES_PID 2>/dev/null; then
|
||||
log_error "PostgreSQL process is running but not accepting connections"
|
||||
else
|
||||
log_error "PostgreSQL process has died"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use the database setup script
|
||||
log_info "Setting up database..."
|
||||
if /scripts/db-setup.sh setup; then
|
||||
log_info "Database setup completed successfully"
|
||||
else
|
||||
log_error "Database setup failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run database configuration if it exists
|
||||
if [ -f "/opt/tak/db-utils/configureInDocker.sh" ]; then
|
||||
log_info "Configuring TAK database..."
|
||||
/opt/tak/db-utils/configureInDocker.sh &
|
||||
DB_CONFIG_PID=$!
|
||||
log_debug "TAK database configuration started with PID: $DB_CONFIG_PID"
|
||||
sleep 10
|
||||
else
|
||||
log_warn "TAK database configuration script not found, skipping..."
|
||||
fi
|
||||
|
||||
# Start TAK server
|
||||
if [ -f "/opt/tak/configureInDocker.sh" ]; then
|
||||
log_info "Starting TAK server..."
|
||||
log_debug "Executing: /opt/tak/configureInDocker.sh init"
|
||||
exec /opt/tak/configureInDocker.sh init
|
||||
else
|
||||
log_error "TAK server configuration script not found!"
|
||||
log_error "Expected file: /opt/tak/configureInDocker.sh"
|
||||
log_error "The extracted TAK server files may be incomplete or corrupted."
|
||||
log_debug "Contents of /opt/tak:"
|
||||
ls -la /opt/tak/ | while read line; do
|
||||
log_debug " $line"
|
||||
done
|
||||
exit 1
|
||||
fi
|
98
manage.sh
98
manage.sh
|
@ -1,98 +0,0 @@
|
|||
#!/bin/bash
|
||||
# TAK Server Management Script
|
||||
# This script provides easy access to container management functions
|
||||
|
||||
CONTAINER_NAME="tak-hybrid"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Check if container is running
|
||||
check_container() {
|
||||
if ! docker ps | grep -q "$CONTAINER_NAME"; then
|
||||
log_error "Container '$CONTAINER_NAME' is not running"
|
||||
log_info "Start the container with: docker-compose up -d"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Execute script in container
|
||||
exec_script() {
|
||||
check_container
|
||||
docker exec "$CONTAINER_NAME" "$@"
|
||||
}
|
||||
|
||||
# Show usage
|
||||
show_usage() {
|
||||
echo "TAK Server Management Script"
|
||||
echo "Usage: $0 <command> [options]"
|
||||
echo ""
|
||||
echo "Commands:"
|
||||
echo " health [component] - Run health checks"
|
||||
echo " db <action> - Database operations"
|
||||
echo " version [action] - TAK version operations"
|
||||
echo " logs - Show container logs"
|
||||
echo " shell - Open shell in container"
|
||||
echo " status - Show container status"
|
||||
echo " restart - Restart container"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 health all - Run all health checks"
|
||||
echo " $0 db test - Test database connection"
|
||||
echo " $0 version list - List available TAK versions"
|
||||
echo " $0 logs - Show recent logs"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"health")
|
||||
shift
|
||||
exec_script /scripts/healthcheck.sh "$@"
|
||||
;;
|
||||
"db")
|
||||
shift
|
||||
exec_script /scripts/db-setup.sh "$@"
|
||||
;;
|
||||
"version")
|
||||
shift
|
||||
exec_script /scripts/tak-version.sh /takserver-zip "$@"
|
||||
;;
|
||||
"logs")
|
||||
docker-compose logs -f tak-hybrid
|
||||
;;
|
||||
"shell")
|
||||
check_container
|
||||
docker exec -it "$CONTAINER_NAME" /bin/bash
|
||||
;;
|
||||
"status")
|
||||
if docker ps | grep -q "$CONTAINER_NAME"; then
|
||||
log_info "Container is running"
|
||||
docker ps | grep "$CONTAINER_NAME"
|
||||
else
|
||||
log_warn "Container is not running"
|
||||
fi
|
||||
;;
|
||||
"restart")
|
||||
log_info "Restarting container..."
|
||||
docker-compose restart tak-hybrid
|
||||
;;
|
||||
*)
|
||||
show_usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -1,144 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Database Setup Script for TAK Server
|
||||
set -e
|
||||
|
||||
# Database configuration
|
||||
DB_NAME="${DB_NAME:-cot}"
|
||||
DB_USER="${DB_USER:-martiuser}"
|
||||
DB_PASSWORD="${DB_PASSWORD:-password}"
|
||||
DB_HOST="${DB_HOST:-localhost}"
|
||||
DB_PORT="${DB_PORT:-5432}"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Check if PostgreSQL is running
|
||||
check_postgres() {
|
||||
if ! pg_isready -q -h "$DB_HOST" -p "$DB_PORT"; then
|
||||
log_error "PostgreSQL is not running or not accessible"
|
||||
return 1
|
||||
fi
|
||||
log_info "PostgreSQL is running"
|
||||
}
|
||||
|
||||
# Create database user if not exists
|
||||
create_db_user() {
|
||||
log_info "Creating database user '$DB_USER'..."
|
||||
|
||||
if sudo -u postgres psql -tAc "SELECT 1 FROM pg_roles WHERE rolname='$DB_USER'" | grep -q 1; then
|
||||
log_warn "User '$DB_USER' already exists"
|
||||
else
|
||||
sudo -u postgres createuser --createdb --no-superuser --no-createrole "$DB_USER"
|
||||
log_info "User '$DB_USER' created"
|
||||
fi
|
||||
|
||||
# Set password
|
||||
sudo -u postgres psql -c "ALTER USER $DB_USER PASSWORD '$DB_PASSWORD';"
|
||||
log_info "Password set for user '$DB_USER'"
|
||||
}
|
||||
|
||||
# Create database if not exists
|
||||
create_database() {
|
||||
log_info "Creating database '$DB_NAME'..."
|
||||
|
||||
if sudo -u postgres psql -lqt | cut -d \| -f 1 | grep -qw "$DB_NAME"; then
|
||||
log_warn "Database '$DB_NAME' already exists"
|
||||
else
|
||||
sudo -u postgres createdb -O "$DB_USER" "$DB_NAME"
|
||||
log_info "Database '$DB_NAME' created"
|
||||
fi
|
||||
}
|
||||
|
||||
# Install PostGIS extension
|
||||
install_postgis() {
|
||||
log_info "Installing PostGIS extension..."
|
||||
|
||||
if sudo -u postgres psql -d "$DB_NAME" -tAc "SELECT 1 FROM pg_extension WHERE extname='postgis'" | grep -q 1; then
|
||||
log_warn "PostGIS extension already installed"
|
||||
else
|
||||
sudo -u postgres psql -d "$DB_NAME" -c "CREATE EXTENSION postgis;"
|
||||
log_info "PostGIS extension installed"
|
||||
fi
|
||||
}
|
||||
|
||||
# Test database connection
|
||||
test_connection() {
|
||||
log_info "Testing database connection..."
|
||||
|
||||
if PGPASSWORD="$DB_PASSWORD" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -c "SELECT version();" > /dev/null 2>&1; then
|
||||
log_info "Database connection successful"
|
||||
else
|
||||
log_error "Database connection failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Main setup function
|
||||
setup_database() {
|
||||
log_info "Starting database setup..."
|
||||
|
||||
check_postgres
|
||||
create_db_user
|
||||
create_database
|
||||
install_postgis
|
||||
test_connection
|
||||
|
||||
log_info "Database setup completed successfully"
|
||||
}
|
||||
|
||||
# Print database configuration
|
||||
print_config() {
|
||||
echo "Database Configuration:"
|
||||
echo " Host: $DB_HOST"
|
||||
echo " Port: $DB_PORT"
|
||||
echo " Database: $DB_NAME"
|
||||
echo " User: $DB_USER"
|
||||
echo " Password: [REDACTED]"
|
||||
}
|
||||
|
||||
# Main execution
|
||||
case "${1:-setup}" in
|
||||
"setup")
|
||||
setup_database
|
||||
;;
|
||||
"test")
|
||||
test_connection
|
||||
;;
|
||||
"config")
|
||||
print_config
|
||||
;;
|
||||
"user")
|
||||
create_db_user
|
||||
;;
|
||||
"db")
|
||||
create_database
|
||||
;;
|
||||
"postgis")
|
||||
install_postgis
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [setup|test|config|user|db|postgis]"
|
||||
echo " setup - Full database setup (default)"
|
||||
echo " test - Test database connection"
|
||||
echo " config - Print database configuration"
|
||||
echo " user - Create database user only"
|
||||
echo " db - Create database only"
|
||||
echo " postgis - Install PostGIS extension only"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -1,224 +0,0 @@
|
|||
#!/bin/bash
|
||||
# TAK Server Health Check Script
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
log_check() {
|
||||
echo -e "${BLUE}[CHECK]${NC} $1"
|
||||
}
|
||||
|
||||
# Check if PostgreSQL is running
|
||||
check_postgres() {
|
||||
log_check "Checking PostgreSQL..."
|
||||
|
||||
if pg_isready -q -h localhost -p 5432; then
|
||||
log_info "PostgreSQL is running"
|
||||
return 0
|
||||
else
|
||||
log_error "PostgreSQL is not running"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check database connectivity
|
||||
check_database() {
|
||||
log_check "Checking database connectivity..."
|
||||
|
||||
if PGPASSWORD="password" psql -h localhost -p 5432 -U martiuser -d cot -c "SELECT 1;" > /dev/null 2>&1; then
|
||||
log_info "Database connection successful"
|
||||
return 0
|
||||
else
|
||||
log_error "Database connection failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check PostGIS extension
|
||||
check_postgis() {
|
||||
log_check "Checking PostGIS extension..."
|
||||
|
||||
if PGPASSWORD="password" psql -h localhost -p 5432 -U martiuser -d cot -tAc "SELECT 1 FROM pg_extension WHERE extname='postgis'" | grep -q 1; then
|
||||
log_info "PostGIS extension is installed"
|
||||
return 0
|
||||
else
|
||||
log_error "PostGIS extension is not installed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check TAK server files
|
||||
check_tak_files() {
|
||||
log_check "Checking TAK server files..."
|
||||
|
||||
if [ -f "/opt/tak/configureInDocker.sh" ]; then
|
||||
log_info "TAK server configuration script found"
|
||||
return 0
|
||||
else
|
||||
log_error "TAK server configuration script not found"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check TAK server process
|
||||
check_tak_process() {
|
||||
log_check "Checking TAK server process..."
|
||||
|
||||
if pgrep -f "takserver" > /dev/null; then
|
||||
log_info "TAK server process is running"
|
||||
return 0
|
||||
else
|
||||
log_warn "TAK server process not found"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check network ports
|
||||
check_ports() {
|
||||
log_check "Checking network ports..."
|
||||
|
||||
local ports=(5432 8080 8443 8444 8446)
|
||||
local all_good=true
|
||||
|
||||
for port in "${ports[@]}"; do
|
||||
if netstat -tuln | grep -q ":$port "; then
|
||||
log_info "Port $port is listening"
|
||||
else
|
||||
log_warn "Port $port is not listening"
|
||||
all_good=false
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$all_good" = true ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check disk space
|
||||
check_disk_space() {
|
||||
log_check "Checking disk space..."
|
||||
|
||||
local usage=$(df /opt/tak | tail -1 | awk '{print $5}' | sed 's/%//')
|
||||
|
||||
if [ "$usage" -lt 80 ]; then
|
||||
log_info "Disk space usage: ${usage}% (OK)"
|
||||
return 0
|
||||
elif [ "$usage" -lt 90 ]; then
|
||||
log_warn "Disk space usage: ${usage}% (WARNING)"
|
||||
return 1
|
||||
else
|
||||
log_error "Disk space usage: ${usage}% (CRITICAL)"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check memory usage
|
||||
check_memory() {
|
||||
log_check "Checking memory usage..."
|
||||
|
||||
local mem_info=$(free | grep Mem)
|
||||
local total=$(echo $mem_info | awk '{print $2}')
|
||||
local used=$(echo $mem_info | awk '{print $3}')
|
||||
local usage=$((used * 100 / total))
|
||||
|
||||
if [ "$usage" -lt 80 ]; then
|
||||
log_info "Memory usage: ${usage}% (OK)"
|
||||
return 0
|
||||
elif [ "$usage" -lt 90 ]; then
|
||||
log_warn "Memory usage: ${usage}% (WARNING)"
|
||||
return 1
|
||||
else
|
||||
log_error "Memory usage: ${usage}% (CRITICAL)"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Run all health checks
|
||||
run_all_checks() {
|
||||
log_info "Running TAK Server Health Checks..."
|
||||
echo "=================================="
|
||||
|
||||
local failed=0
|
||||
|
||||
check_postgres || ((failed++))
|
||||
check_database || ((failed++))
|
||||
check_postgis || ((failed++))
|
||||
check_tak_files || ((failed++))
|
||||
check_tak_process || ((failed++))
|
||||
check_ports || ((failed++))
|
||||
check_disk_space || ((failed++))
|
||||
check_memory || ((failed++))
|
||||
|
||||
echo "=================================="
|
||||
|
||||
if [ $failed -eq 0 ]; then
|
||||
log_info "All health checks passed!"
|
||||
return 0
|
||||
else
|
||||
log_error "$failed health check(s) failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Main execution
|
||||
case "${1:-all}" in
|
||||
"all")
|
||||
run_all_checks
|
||||
;;
|
||||
"postgres")
|
||||
check_postgres
|
||||
;;
|
||||
"database")
|
||||
check_database
|
||||
;;
|
||||
"postgis")
|
||||
check_postgis
|
||||
;;
|
||||
"tak-files")
|
||||
check_tak_files
|
||||
;;
|
||||
"tak-process")
|
||||
check_tak_process
|
||||
;;
|
||||
"ports")
|
||||
check_ports
|
||||
;;
|
||||
"disk")
|
||||
check_disk_space
|
||||
;;
|
||||
"memory")
|
||||
check_memory
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [all|postgres|database|postgis|tak-files|tak-process|ports|disk|memory]"
|
||||
echo " all - Run all health checks (default)"
|
||||
echo " postgres - Check PostgreSQL service"
|
||||
echo " database - Check database connectivity"
|
||||
echo " postgis - Check PostGIS extension"
|
||||
echo " tak-files - Check TAK server files"
|
||||
echo " tak-process- Check TAK server process"
|
||||
echo " ports - Check network ports"
|
||||
echo " disk - Check disk space"
|
||||
echo " memory - Check memory usage"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -1,193 +0,0 @@
|
|||
#!/bin/bash
|
||||
# TAK Server Extraction Script
|
||||
|
||||
# Colors for logging
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
log_info() {
|
||||
echo -e "${GREEN}[EXTRACT-INFO]${NC} $(date '+%Y-%m-%d %H:%M:%S') - $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[EXTRACT-WARN]${NC} $(date '+%Y-%m-%d %H:%M:%S') - $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[EXTRACT-ERROR]${NC} $(date '+%Y-%m-%d %H:%M:%S') - $1"
|
||||
}
|
||||
|
||||
log_debug() {
|
||||
echo -e "${BLUE}[EXTRACT-DEBUG]${NC} $(date '+%Y-%m-%d %H:%M:%S') - $1"
|
||||
}
|
||||
|
||||
# Extract TAK server from zip file
|
||||
extract_tak_server() {
|
||||
local zip_file="$1"
|
||||
local target_dir="$2"
|
||||
|
||||
if [ -z "$zip_file" ] || [ -z "$target_dir" ]; then
|
||||
log_error "Usage: extract_tak_server <zip_file> <target_dir>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$zip_file" ]; then
|
||||
log_error "ZIP file does not exist: $zip_file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
log_info "Extracting TAK server from: $(basename $zip_file)"
|
||||
log_debug "Target directory: $target_dir"
|
||||
|
||||
# Create temporary extraction directory
|
||||
local temp_dir="/tmp/tak_extract_$$"
|
||||
mkdir -p "$temp_dir"
|
||||
|
||||
log_debug "Using temporary directory: $temp_dir"
|
||||
|
||||
# Extract ZIP file
|
||||
cd "$temp_dir"
|
||||
if ! unzip -q "$zip_file"; then
|
||||
log_error "Failed to extract ZIP file"
|
||||
rm -rf "$temp_dir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
log_debug "ZIP extraction completed"
|
||||
|
||||
# Find the tak directory - it could be at root level or nested
|
||||
local tak_source_dir=""
|
||||
|
||||
# First check if tak directory is at root level
|
||||
if [ -d "$temp_dir/tak" ]; then
|
||||
tak_source_dir="$temp_dir/tak"
|
||||
log_info "Found 'tak' directory at root level"
|
||||
else
|
||||
# Look for tak directory in subdirectories
|
||||
log_debug "Looking for 'tak' directory in subdirectories..."
|
||||
tak_source_dir=$(find "$temp_dir" -type d -name "tak" -print -quit)
|
||||
|
||||
if [ -n "$tak_source_dir" ] && [ -d "$tak_source_dir" ]; then
|
||||
log_info "Found 'tak' directory at: $tak_source_dir"
|
||||
else
|
||||
log_error "Expected 'tak' directory not found in ZIP file"
|
||||
log_debug "Available directories:"
|
||||
find "$temp_dir" -type d -maxdepth 3 | while read dir; do
|
||||
log_debug " $dir"
|
||||
done
|
||||
rm -rf "$temp_dir"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Ensure target directory exists
|
||||
mkdir -p "$target_dir"
|
||||
|
||||
# Copy TAK files to target directory
|
||||
log_debug "Copying files from $tak_source_dir/ to $target_dir/"
|
||||
if cp -r "$tak_source_dir/"* "$target_dir/"; then
|
||||
log_info "TAK files copied successfully"
|
||||
else
|
||||
log_error "Failed to copy TAK files"
|
||||
rm -rf "$temp_dir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Show what was extracted
|
||||
log_debug "Files extracted to $target_dir:"
|
||||
find "$target_dir" -maxdepth 2 -type f | head -10 | while read file; do
|
||||
log_debug " $(basename $file)"
|
||||
done
|
||||
|
||||
# Clean up
|
||||
rm -rf "$temp_dir"
|
||||
log_debug "Temporary directory cleaned up"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Verify TAK installation
|
||||
verify_tak_installation() {
|
||||
local install_dir="$1"
|
||||
|
||||
log_info "Verifying TAK installation in: $install_dir"
|
||||
|
||||
# Check for required files
|
||||
local required_files=(
|
||||
"configureInDocker.sh"
|
||||
"takserver.sh"
|
||||
)
|
||||
|
||||
for file in "${required_files[@]}"; do
|
||||
if [ -f "$install_dir/$file" ]; then
|
||||
log_debug "Found required file: $file"
|
||||
else
|
||||
log_warn "Missing file: $file"
|
||||
fi
|
||||
done
|
||||
|
||||
# Check for key directories
|
||||
local key_dirs=(
|
||||
"bin"
|
||||
"conf"
|
||||
"lib"
|
||||
)
|
||||
|
||||
for dir in "${key_dirs[@]}"; do
|
||||
if [ -d "$install_dir/$dir" ]; then
|
||||
log_debug "Found directory: $dir"
|
||||
else
|
||||
log_warn "Missing directory: $dir"
|
||||
fi
|
||||
done
|
||||
|
||||
# Main verification
|
||||
if [ -f "$install_dir/configureInDocker.sh" ]; then
|
||||
log_info "TAK installation verification successful"
|
||||
return 0
|
||||
else
|
||||
log_error "TAK installation verification failed - configureInDocker.sh not found"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Set proper permissions
|
||||
set_tak_permissions() {
|
||||
local install_dir="$1"
|
||||
local owner="${2:-tak:tak}"
|
||||
|
||||
log_info "Setting permissions on TAK installation"
|
||||
|
||||
# Make scripts executable
|
||||
find "$install_dir" -name "*.sh" -exec chmod +x {} \; 2>/dev/null
|
||||
|
||||
# Set ownership
|
||||
chown -R "$owner" "$install_dir" 2>/dev/null
|
||||
|
||||
log_debug "Permissions set successfully"
|
||||
}
|
||||
|
||||
# Main execution if script is run directly
|
||||
if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
|
||||
case "${1:-extract}" in
|
||||
"extract")
|
||||
extract_tak_server "$2" "$3"
|
||||
;;
|
||||
"verify")
|
||||
verify_tak_installation "$2"
|
||||
;;
|
||||
"permissions")
|
||||
set_tak_permissions "$2" "$3"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [extract|verify|permissions] <args>"
|
||||
echo " extract <zip_file> <target_dir> - Extract TAK server from ZIP"
|
||||
echo " verify <install_dir> - Verify TAK installation"
|
||||
echo " permissions <install_dir> [owner] - Set TAK permissions"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
|
@ -1,68 +0,0 @@
|
|||
#!/bin/bash
|
||||
# TAK Server Version Detection Script
|
||||
set -e
|
||||
|
||||
# Find the latest takserver-docker-X.Y-RELEASE-Z.zip file
|
||||
find_latest_tak_release() {
|
||||
local takserver_dir="$1"
|
||||
|
||||
if [ ! -d "$takserver_dir" ]; then
|
||||
echo "ERROR: Directory $takserver_dir does not exist"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local latest_zip=$(find "$takserver_dir" -name "takserver-docker-*-RELEASE-*.zip" -type f | \
|
||||
sed -n 's/.*takserver-docker-\([0-9]\+\.[0-9]\+\)-RELEASE-\([0-9]\+\)\.zip/\1.\2 &/p' | \
|
||||
sort -V | tail -1 | cut -d' ' -f2-)
|
||||
|
||||
if [ -z "$latest_zip" ]; then
|
||||
echo "ERROR: No takserver-docker-X.Y-RELEASE-Z.zip file found in $takserver_dir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "$latest_zip"
|
||||
}
|
||||
|
||||
# Extract version information
|
||||
get_tak_version() {
|
||||
local zip_file="$1"
|
||||
local version=$(basename "$zip_file" | sed -n 's/takserver-docker-\([0-9]\+\.[0-9]\+\)-RELEASE-\([0-9]\+\)\.zip/\1-\2/p')
|
||||
echo "$version"
|
||||
}
|
||||
|
||||
# List all available TAK releases
|
||||
list_tak_releases() {
|
||||
local takserver_dir="$1"
|
||||
|
||||
echo "Available TAK server releases:"
|
||||
find "$takserver_dir" -name "takserver-docker-*-RELEASE-*.zip" -type f | while read -r file; do
|
||||
local version=$(get_tak_version "$file")
|
||||
echo " - $(basename "$file") (version: $version)"
|
||||
done
|
||||
}
|
||||
|
||||
# Main execution if script is run directly
|
||||
if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
|
||||
TAKSERVER_DIR="${1:-/takserver-zip}"
|
||||
|
||||
case "${2:-latest}" in
|
||||
"latest")
|
||||
find_latest_tak_release "$TAKSERVER_DIR"
|
||||
;;
|
||||
"list")
|
||||
list_tak_releases "$TAKSERVER_DIR"
|
||||
;;
|
||||
"version")
|
||||
if [ -n "$3" ]; then
|
||||
get_tak_version "$3"
|
||||
else
|
||||
echo "Usage: $0 <dir> version <zip_file>"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 <directory> [latest|list|version <zip_file>]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
83
validate.sh
83
validate.sh
|
@ -1,83 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# TAK Server Setup Validation Script
|
||||
|
||||
echo "TAK Server Hybrid Container - Setup Validation"
|
||||
echo "=============================================="
|
||||
|
||||
# Check if takserver-release directory exists
|
||||
if [ ! -d "takserver-release" ]; then
|
||||
echo "❌ takserver-release directory not found"
|
||||
echo " Please create the directory: mkdir -p takserver-release"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for TAK server files
|
||||
TAK_FILES=$(find takserver-release -name "takserver-docker-*.zip" 2>/dev/null)
|
||||
|
||||
if [ -z "$TAK_FILES" ]; then
|
||||
echo "❌ No TAK server files found in takserver-release/"
|
||||
echo ""
|
||||
echo "Required:"
|
||||
echo " - File format: takserver-docker-X.Y-RELEASE-Z.zip"
|
||||
echo " - Example: takserver-docker-5.4-RELEASE-19.zip"
|
||||
echo ""
|
||||
echo "Please:"
|
||||
echo " 1. Obtain TAK server files through proper channels"
|
||||
echo " 2. Ensure you have valid licensing/authorization"
|
||||
echo " 3. Place files in takserver-release/ directory"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ TAK server files found:"
|
||||
for file in $TAK_FILES; do
|
||||
echo " - $(basename $file)"
|
||||
done
|
||||
|
||||
# Find latest version
|
||||
LATEST_ZIP=$(echo "$TAK_FILES" | \
|
||||
sed -n 's/.*takserver-docker-\([0-9]\+\.[0-9]\+\)-RELEASE-\([0-9]\+\)\.zip/\1.\2 &/p' | \
|
||||
sort -V | tail -1 | cut -d' ' -f2-)
|
||||
|
||||
if [ -n "$LATEST_ZIP" ]; then
|
||||
echo "✅ Latest version detected: $(basename $LATEST_ZIP)"
|
||||
fi
|
||||
|
||||
# Check Docker
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo "❌ Docker not found - please install Docker"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ Docker found"
|
||||
|
||||
# Check Docker Compose
|
||||
if ! command -v docker-compose &> /dev/null; then
|
||||
echo "❌ Docker Compose not found - please install Docker Compose"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ Docker Compose found"
|
||||
|
||||
# Check if Dockerfile exists
|
||||
if [ ! -f "Dockerfile" ]; then
|
||||
echo "❌ Dockerfile not found"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ Dockerfile found"
|
||||
|
||||
# Check if docker-compose.yml exists
|
||||
if [ ! -f "docker-compose.yml" ]; then
|
||||
echo "❌ docker-compose.yml not found"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ Docker Compose configuration found"
|
||||
|
||||
echo ""
|
||||
echo "🎉 All checks passed! You're ready to build and run the container."
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Build: ./build.sh"
|
||||
echo " 2. Start: docker-compose up -d"
|
||||
echo " 3. Logs: docker-compose logs -f tak-hybrid"
|
||||
echo ""
|
||||
echo "⚠️ Remember: Ensure you have proper licensing for TAK server software"
|
Loading…
Add table
Add a link
Reference in a new issue