#!/bin/bash
IP_ADDRESS="202.12.108.56"
HOSTNAME="ps.gosweetspot.com"
HOSTS_FILE="/etc/hosts"
# Check if the entry already exists
grep -q "$IP_ADDRESS[[:space:]]$HOSTNAME" "$HOSTS_FILE"
if [ $? -eq 0 ]; then
    echo "Entry already exists in $HOSTS_FILE"
    exit 0
fi
# Append the new entry to the hosts file using sudo
echo "$IP_ADDRESS $HOSTNAME" | sudo tee -a "$HOSTS_FILE" > /dev/null
if [ $? -eq 0 ]; then
    echo "Successfully added $IP_ADDRESS $HOSTNAME to $HOSTS_FILE"
else
    echo "Failed to add entry. Check your permissions."
    exit 1
fi