URL=$1
BACKUP_ID=`date +"%Y%m%d%H%M%S"`

echo ">>>>>      BACKUP ID: ${BACKUP_ID}           <<<<<"

tmpdir=`mktemp -d`
cd $tmpdir

source /etc/profile.d/ecm_env.sh
if [ -f /etc/profile.d/hdfs.sh ]; then
  source /etc/profile.d/hdfs.sh
fi
if [[ $URL == oss* ]]; then
  hadoop fs -get $URL .
elif [[ $URL == http* ]]; then
  wget $URL
fi
unzip hadoop-patches-tools.zip

sudo sh ./hadoop-patches-tools/patch/do-patch.sh ${BACKUP_ID}
