# FreeTAKServer Docker Scripts This directory contains the scripts used by the FreeTAKServer Docker container. These scripts have been extracted from the Dockerfile for better maintainability and easier development. ## Scripts Overview ### `install_freetak.sh` - **Purpose**: Installs FreeTAKServer using Ansible playbooks - **Usage**: Called during Docker build process - **Environment Variables**: - `INSTALL_TYPE`: Installation type (latest, stable, legacy) - `FTS_VENV`: Path to Python virtual environment - `STABLE_FTS_VERSION`: Stable version number - `LEGACY_FTS_VERSION`: Legacy version number - `CFG_RPATH`: Configuration path ### `start_freetak.sh` - **Purpose**: Simple startup script for FreeTAKServer - **Usage**: Basic container startup (deprecated, use entrypoint.sh) - **Environment Variables**: - `FTS_VENV`: Path to Python virtual environment - `CFG_RPATH`: Configuration path ### `entrypoint.sh` - **Purpose**: Main entrypoint script with signal handling and logging - **Usage**: Default container entrypoint - **Features**: - Graceful shutdown handling - Proper signal forwarding - Timestamped logging - Dynamic configuration path detection - Environment-based configuration ### `healthcheck.sh` - **Purpose**: Health check script for Docker container - **Usage**: Called by Docker healthcheck - **Functionality**: Checks if FreeTAKServer process is running ### `dev-helper.sh` - **Purpose**: Development helper script for validation and testing - **Usage**: `./scripts/dev-helper.sh [validate|test|info|help]` - **Features**: - Script validation - Syntax checking - Information display - Development workflow support ## Development Workflow 1. **Validate Scripts**: Ensure all scripts exist and are executable ```bash ./scripts/dev-helper.sh validate ``` 2. **Test Syntax**: Check all scripts for syntax errors ```bash ./scripts/dev-helper.sh test ``` 3. **View Information**: Display script information ```bash ./scripts/dev-helper.sh info ``` ## Script Maintenance ### Adding New Scripts 1. Create the script in the `scripts/` directory 2. Make it executable: `chmod +x scripts/your-script.sh` 3. Add it to the Dockerfile `COPY` instruction 4. Update the `dev-helper.sh` script to include validation ### Modifying Existing Scripts 1. Edit the script file directly 2. Test syntax: `./scripts/dev-helper.sh test` 3. Rebuild the Docker image to apply changes ### Best Practices - Always include proper error handling (`set -e`) - Use descriptive variable names - Add comments for complex logic - Follow consistent formatting - Test scripts before committing ## Environment Variables The scripts use these key environment variables: - `FTS_VENV`: Python virtual environment path (default: `/opt/fts.venv`) - `INSTALL_TYPE`: Installation type - `latest`, `stable`, or `legacy` - `CFG_RPATH`: Configuration path (auto-detected based on install type) - `STABLE_FTS_VERSION`: Stable version number - `LEGACY_FTS_VERSION`: Legacy version number ## Troubleshooting ### Script Not Executable ```bash chmod +x scripts/script-name.sh ``` ### Syntax Errors ```bash bash -n scripts/script-name.sh ``` ### Testing Individual Scripts ```bash # Test in container context docker run --rm -it freetak-server /bin/bash # Then run: /opt/script-name.sh ``` ### Debugging Add `set -x` at the beginning of scripts to enable debug output. ## Integration with Dockerfile The scripts are copied into the container during build: ```dockerfile # Copy the scripts COPY scripts/install_freetak.sh /opt/install_freetak.sh COPY scripts/start_freetak.sh /opt/start_freetak.sh COPY scripts/healthcheck.sh /opt/healthcheck.sh COPY scripts/entrypoint.sh /opt/entrypoint.sh # Make the scripts executable RUN chmod +x /opt/*.sh ``` ## License These scripts are part of the FreeTAKServer Docker container project and follow the same licensing as the original FreeTAKHub-Installation project (Eclipse Public License 2.0).