#!/bin/bash
#
################################################################################
#
#                     S H E L L   S C R I P T  F I L E
#
#                         COPYRIGHT 2011 MOTOROLA
#                           All Rights Reserved
#
################################################################################
#
#   FILE NAME       : omc_ipconfig
#   FUNCTION        : 
#   PARAMETERS      :  
#                      
################################################################################
#
################################################################################
#
# Revision History:
#
# Date      Prob#          Description
# --------- -------------  -----------------------------------------------------
# 01-MAr-11   Initial version
################################################################################

################################# Includes #####################################

SUCCESS=0
ERROR=1

################################# functions ####################################

# ---------------------------------------------------------------------------
# Function: 
#    show_menu
#   show and execute main menu
# Input: None.
# ---------------------------------------------------------------------------
function show_menu
{
  while [ 1 ]
  do
	  printf "\n"
      printf "          1 -> Show server-sites table\n"
	  printf "          2 -> Update server-sites table\n"
      printf "          q -> Quit\n"
      printf "\n"
      printf "  Choice? "
      read -r userchoice

      case $userchoice in

	"1")
		/opt/Motorola/mcd5000/omcserver/bin/omc_ipds_config show_server_sites_table
		;;
	"2")
		printf "\nUpdate an entry in server-sites table:\n"
		
		# find the OMC server IP address
		MY_IP=$(ifconfig eth0 | grep inet | awk '{print $2}' | awk '{print substr($$0,6,16)}')
		
		/opt/Motorola/mcd5000/omcserver/bin/omc_ipds_config update_omc_sites -pip $MY_IP
		;;		
	"q")
		printf "\nQuitting...\n"
		exit
		;;		
	*)
		printf "\n     -->  Input error: please insert 1-3,q  <--\n\n"
		;;
	esac
  done
}	


# ---------------------------------------------------------------------------
# Function: 
#    print in console and syslog.
# Input:
#    ${*} - one or more string parameters
# ---------------------------------------------------------------------------

function print_in_console_and_syslog
{
    printf ".... $1 ....\n"
    /usr/bin/logger -t $1
} 


################################# Main Body ####################################
MY_IP=

show_menu


#################################  E N D    ####################################
