#!/bin/bash

updateComposeFileNetwork()
{
    local compose_file="$1"
    local old_subnet="$2"
    local new_subnet="$3"
    
    # Update network subnet references
    sed -i "s|subnet: $old_subnet|subnet: $new_subnet|g" "$compose_file"
    
    # Update IP range references  
    local old_ip_range="${old_subnet%.*}.0/24"
    local new_ip_range="${new_subnet%.*}.0/24"
    sed -i "s|ip-range: $old_ip_range|ip-range: $new_ip_range|g" "$compose_file"
    
    # Update gateway references
    local old_gateway="${old_subnet%.*}.1"
    local new_gateway="${new_subnet%.*}.1"
    sed -i "s|gateway: $old_gateway|gateway: $new_gateway|g" "$compose_file"
    
    # Update static IP assignments if any
    local old_network_base="${old_subnet%/*}"
    local new_network_base="${new_subnet%/*}"
    sed -i "s|$old_network_base\.|$new_network_base\.|g" "$compose_file"
    
}
