#!/bin/sh
# Windows module back
# ---------------------------------------------- #


##### Main routine ###############################

# Function read
. ${INST_HOME}/function.sh

##### TRAP #######################################
# Deny Ctrl+C
trap 'echo "Deny Ctrl+C"' 1 2 3 15

# init
initialize

# result init
FLAG=0

# judge LOG output
if [ "${UN}" = "" ] ; then
  OUTLOG="arize_err \"dmy\""
else
  OUTLOG="write_log"
fi

# START
echo_sp "${SMX_WINLOGON_BACK}."
${OUTLOG} "${SMX_WINLOGON_BACKSTART}"

#----- Delete windowsLogon now module -------#
###### XP ######
$rm -f ${WIN_DOWNLOAD_PATH}/${WIN_XP_DOWNLOAD_MODULE} ${WIN_XP_FILE_PATH}/${WIN_XP_MODULE} 1> /dev/null 2>> ${ERR_LOG_FILE}
if [ $? -ne 0 ] ; then
  FLAG=1
fi
###### VISTA ######
$rm -f ${WIN_DOWNLOAD_PATH}/${WIN_VISTA_DOWNLOAD_MODULE} ${WIN_VISTA_FILE_PATH}/${WIN_VISTA_MODULE} 1> /dev/null 2>> ${ERR_LOG_FILE}
if [ $? -ne 0 ] ; then
  FLAG=1
fi

#----- Backup Winlogon module deploy --------#
$tar $ZX_OPT ${BACKUP_WIN} -C / 1> /dev/null 2>> ${ERR_LOG_FILE}
if [ $? -ne 0 ] ; then
  FLAG=1
fi

# result
if [ $FLAG -eq 0 ] ; then
  $echo "${END}"
  ${OUTLOG} "${SMX_WINLOGON_MODULEBACK}"
else
  $echo "${OCCURED_ERROR}"
  $echo ""
  msg_err "${SMX_WINLOGON_MODULEBACK_MISS}" \
          "${PROSECC_QUIT}" \
          " " \
          "<!> ${NOEXPECT_ERROR_SAPORT}"
  arize_err "dmy" "${SMX_WINLOGON_MODULEBACK_MISS}"
fi

exit ${FLAG}
