#!/bin/bash # Script to create a configuration file at /home/perplexica/config.toml # The configuration includes sections [GENERAL], [API_KEYS], and [API_ENDPOINTS] # Values are sourced from environment variables if available; otherwise, default values are used. # Define the output configuration file path CONFIG_DIR="/home/perplexica" CONFIG_FILE="$CONFIG_DIR/config.toml" # Ensure the configuration directory exists if [ ! -d "$CONFIG_DIR" ]; then echo "Directory '$CONFIG_DIR' does not exist. Creating it..." mkdir -p "$CONFIG_DIR" if [ $? -ne 0 ]; then echo "Failed to create directory '$CONFIG_DIR'. Please check your permissions." exit 1 fi fi # Create or overwrite the configuration file cat > "$CONFIG_FILE" <