#!/bin/bash # This script checks the availability of an IP address (common::check_ip_availability) # Extract parameters network="$PT_network" # Determine which IP to ping based on network if [ "$network" = "internal-moeny" ]; then ping_ip="10.44.0.250" elif [ "$network" = "wan-verizon" ]; then ping_ip="100.40.223.190" else echo "{\"status\": \"error\", \"message\": \"Unsupported network type: $network. Must be either internal-moeny or wan-verizon.\"}" exit 1 fi # Ping the target IP with 3 second timeout if ping -c 1 -W 3 "$ping_ip" > /dev/null 2>&1; then echo "{\"status\": \"error\", \"message\": \"IP $ping_ip is already in use. Please choose a different IP.\"}" exit 1 else echo "{\"status\": \"success\", \"message\": \"IP $ping_ip is available.\"}" exit 0 fi