#!/bin/csh -f
set basedir=`dirname $0`
cd $basedir
# determine which Ex Libris application
source util_sp_set_app

# set default values for SP
set ftp_server="downloads-eu.hosted.exlibrisgroup.com"
set ftp_opts=""
set language="english"
set sp_dir="$app_scratch/sp"
set exl_mail="${app}-SP-Install@exlibrisgroup.com"
set cust_code=""
set cust_mail=""
set mail_exl_flag = "Y"
set ftp_user=$ftp_def_user
# End of configuration file
if (! -f $sp_conf) then
    echo "Creating first time configuration file..."
    source $util_proc/util_sp_write_config
endif
if (! -f $sp_passfile) then
    echo "xxxxxx" > $sp_passfile
    chmod 600 $sp_passfile
endif
source $sp_conf
set ftp_pass=`cat $sp_passfile`

echo "SP Customer details"
echo "--------------------------"
echo "Enter new values or press <Enter> to keep existing"
echo ""

echo "Ex Libris customer code (country code + customer) [$cust_code]:"
set ans="$<"
if ("$ans" != "") then
    set cust_code=$ans
    set touched
endif
echo "Customer mail address for download status notifications (leave empty for none) [$cust_mail]"
set ans="$<"
if ("$ans" != "") then
    set cust_mail = ( $ans )
    set touched
endif

if ($app == ALEPH) then
    echo "If you want to change the language please type it now [$language]:"
    echo "(This is an option for future usage)"
    set ans="$<"
    if ("$ans" != "") then
        set language=$ans
        set touched
    endif
endif



echo ""
echo "Configuration summary:"
echo "----------------------"
echo "Language:                  $language"
echo "Customer code:             $cust_code"
echo "Notification address:      $cust_mail"
echo ""
#echo "Press <Enter> to continue"
#set ans="$<"
if ($?touched) then
    echo "Configuration has changed, do you want to save it?[y/n]"
    set ans="$<"
    set ans=`echo $ans | tr '[A-Z]' '[a-z]'`
    while ( "$ans" != "y" && "$ans" != "n" )
        echo "Do you want to save [y/n]?"
        set ans="$<"
    end
    if ("$ans" == "y" || $ans == "Y") then
      source $util_proc/util_sp_write_config
      unset touched
    else
        echo "All changes will be discarded"
    endif
endif

exit:
echo "Press <Enter> to continue"
set ans="$<"
