#!/bin/bash # Check if correct number of arguments are provided if [ "$#" -ne 3 ]; then echo "Usage: ./script.sh [host_name] [redirect_target] [template_file]" read -p "Enter the template file path: " template_file read -p "Enter the host name: " host_name read -p "Enter the redirect target: " redirect_target else # Assign command line arguments to variables template_file=$1 host_name=$2 redirect_target=$3 fi # Check if template file exists if [ ! -f "$template_file" ]; then echo "Template file not found: $template_file" exit 1 fi # Read the template file template=$(cat "$template_file") # Use sed to replace placeholders with user input config=$(echo "$template" | sed "s/HOST_NAME/$host_name/g; s/REDIRECT_TARGET/$redirect_target/g") # Print the configuration echo "$config"