#!/bin/bash

export TEST_HOME="/Users/janvier/Sites/data/sc_data"
export LIVE_HOME="/Library/WebServer/Documents/data/sc_data"

function copyDirectory {
  local srcDir=$1
  local dstDir=$2

  if [[ ! -d ${srcDir} ]]; then
    echo "Skipping ${srcDir}"
  elif [[ ! -d ${dstDir} ]]; then
    echo "Copying ${srcDir}"
    cp -R ${srcDir} ${dstDir}
    rm -rf ${srcDir}
  else
    echo "Replacing ${srcDir}"
    rm -rf ${dstDir}
    cp -R ${srcDir} ${dstDir}
    rm -rf ${srcDir}
  fi
}

crNumList=( `ps_print_seq_num.sh "$1"` )
if [[ $? -ne ${STATUS_OK} ]]; then
  ps_print_err.sh "$0" "Invalid string index(es): $1"
  exit 1
fi

for crNum in ${crNumList[@]}; do
  copyDirectory ${TEST_HOME}/cr${crNum} ${LIVE_HOME}/cr${crNum}
done
