# this script sets up a MyroC directory/subdirectory
#   for Web distribution for MyroC.3.3 and eSpeakPackage.3.0
#
#
# the script works with a main release directory (e.g., MyroC.3.3)
#    (the directory is created under the current directory,
#     if not already present)
#

baseSourceDir="/home/public_html/MyroC"

# check command line contains release number and subrelease ID
echo "Script to set up a MyroC directory/subdirectory"

#baseSource="$baseSourceDir/MyroC.3.3" # script to be run from base directory
baseSource="."
releaseDir="."
eSpeakSource="$baseSource/eSpeak"
eSpeakDocumentationSource="$baseSource/eSpeak-documentation"
MyroCSource="$baseSource/MyroC.3.3a"
MyroCDocumentationSource="$baseSource/MyroC-documentation"
testProgSource="$baseSource/test-programs"
README="README.txt"
License-"License.txt"

echo
echo "Source and Target Directories"
if [ ! -e $baseSource ]; then
   echo "     Main Source:        $baseSource, NOT found"
   exit
else
   echo "     Main Source:        $baseSource"
fi

if [ ! -e $eSpeakSource ]; then
   echo "     eSpeak-Linux Source:$eSpeakSource, NOT found"
   exit
else
   echo "     eSpeak-Linux-Source:$eSpeakSource"
fi

if [ ! -e $eSpeakdocumenationSource ]; then
   echo "     eSpeakDocumentationSource:    $eSpeakDocumentation, NOT found"
   exit
else
   echo "     eSpeakDocumentationSource:    $eSpeakDocumentationSource"
fi
if [ ! -e $MyroCDocumentationSource ]; then
   echo "     Documentation:      $MyroCDocumentationSource, NOT found"
   exit
else
   echo "     Documentation:      $MyroCDocumentationSource"
fi

if [ ! -e $MyroCSource ]; then
   echo "     MyroC Source:       $MyroCSource, NOT found"
   exit
else
   echo "     MyroC Source:       $MyroCSource"
fi

if [ ! -e $testProgCSource ]; then
   echo "     Test Programs:      $testProgSource, NOT found"
   exit
else
   echo "     Test Programs:      $testProgSource"
fi

if [ ! -e "README.txt" ]; then
   echo "     README.txt:         NOT found"
   exit
else
   echo "     README.txt:         found"
fi

if [ ! -e "License.txt" ]; then
   echo "     License.txt:        NOT found"
   exit
else
   echo "     License.txt:        found"
fi




echo
echo "Confirm:  Enter 'y' or 'n'"

read confirm

shopt -s nocasematch
if [[ $confirm != y* ]]; then
   echo "exiting script without further processing"
   exit;
fi

echo
compressedFile="$releaseDir/MyroC.3.3a.tgz"
echo "Creating archived tar file $compressedFile"

tar -czvf $compressedFile \
          "README.txt" \
          "License.txt" \
          $eSpeakSource \
          $eSpeakDocumentationSource \
          $MyroCSource \
          $MyroCDocumentationSource \
          $testProgSource 
chmod 755 $compressedFile

echo "Decompress with the command:"
echo "     tar -xzvf $compressedFile"
echo
echo "Copy-release script completed"
