#!/bin/bash
#
######################################################################
# 
# TITLE:    HP ProLiant Essentials Rapid Deployment Pack Linux Edition
# Japanese Language Kit (Uninstaller)
# VERSION:  1.30 Rev A
# LANGUAGE:  Japanese (JP)
#
# DESCRIPTION:  This SoftPaq contains the Japanese Language Kit
# Installer/Uninstaller, Management agents JLK and Readme file.
# Enhancements/Fixes:
# - added KS.JA.CFG files for each operating systems directory
# in the NFS Server.
#
# HOW TO USE:
# Download the SoftPaq to a directory on your target computer. The SoftPaq
# is a .tgz file with a file name based on the SoftPaq Number. 
#
# Run this command to extract the files from the .tgz file: 
#	tar -zxvf *.tgz 
# Refer to the Softpaq README file for installation instructions and
# firmware information.
#
# Y.M 08/25/05
######################################################################
function chgcolor
{
  # Change color
  case "$1" in
       blue )
        c1=40
        c2=34
       ;;
       green )
        c1=40
        c2=32
       ;;
       red )
        c1=40
        # c2=31 moved to white for readability
        c2=37
       ;;
       aqua )
        c1=40
        c2=36
       ;;
       orange )
        c1=40
        c2=33
       ;;
       white )
        c1=40
        c2=37
       ;;
       white-blue )
        c1=44
        c2=37
       ;;
       aqua-blue )
        c1=44
        c2=36
       ;;
       orange-blue )
        c1=44
        c2=31
       ;;
       black-red )
        # moved to white for readability
        # c1=41
        # c2=30
        c1=40
        c2=37
       ;;
       reset )
        tput sgr0
       ;;
       * )
        # reset back to white on black
        tput sgr0
       ;;
  esac
  echo -en "\E[$c1;${c2}m"

}

function ListFiles
{
 echo "Searching..."
 filespec=$1
 for i in $filespec; do
 if [ -f $i ]; then
   echo " $i"
 fi
 done
 echo
}

function LetsRemove
{
 filespec=$1
 for i in $filespec; do
 if [ -f $i ]; then
   echo "   => $i"
   echo -n "      Would you like to remove the file? (y/n) : "
     while [ $prompt=[yn] ]; do
       read prompt
       case $prompt in
       y*)
        RemoveFiles $i
        echo
        break;;
       n*)
        break;;
       *)
        echo -n "      Would you like to remove the file? (y/n) : ";;
       esac
     done
 fi
 done
}

function RemoveFiles
{
  filespec=$1
  for i in $filespec; do
   if [ -e $i ]; then
    chgcolor orange
    echo -n "      $i --> Removing..."
    rm -f $i
    chgcolor white
    echo " Done"
   fi
  done
}

function InfoMessage
{

distname=$1
chgcolor green
 cat << TheTextData
-----------------------------------------------------------------------------
IMPORTANT! You must update the distribution scripted install jobs
 on your Deployment Server.
Edit the "Create Boot Environment" task and make the following changes.

 *) In case of unattendfile=[OS Name]/default.ja.cfg
   From:  set unattendfile=[OS Name]/default.ja.cfg
   To:    set unattendfile=[OS Name]/default.cfg

 *) In case of unattendfile=[OS Name]/bl10e.ja.cfg
   From:  set unattendfile=[OS Name]/bl10e.ja.cfg
   To:    set unattendfile=[OS Name]/bl10e.cfg

 *) In case of unattendfile=[OS Name]/default.ja.xml
   From:  set unattendfile=[OS Name]/default.ja.xml
   To:    set unattendfile=[OS Name]/default.xml

 *) In case of unattendfile=[OS Name]/bl10e.ja.xml
   From:  set unattendfile=[OS Name]/bl10e.ja.xml
   To:    set unattendfile=[OS Name]/bl10e.xml
-----------------------------------------------------------------------------
TheTextData
chgcolor white
#   echo
   echo -n "(Press Enter to exit)"
   read answer
}

###############################################################################
#  MAIN EXECUTION STARTS HERE
###############################################################################
chgcolor white
clear
# Switch to Aqua Blue
chgcolor white-blue
echo '                                                                    '
echo "    HP ProLiant Essentials Rapid Deployment Pack Linux Edition      "
chgcolor aqua-blue
echo -n "    Japanese Language Kit ( "
chgcolor orange-blue
echo -n "Uninstaller"
chgcolor aqua-blue
echo " )  VERSION:  1.30 Rev A     "
echo '____________________________________________________________________'
echo
chgcolor white

   echo -n "(Press Enter to start)"
   read answer

kssrc=/usr/rdp/osconfig
GetFList=$(find $kssrc -name *.ja.*)

ListFiles "$GetFList"
LetsRemove "$GetFList"
InfoMessage

# end of script
