Pandoc and Full Texlive install on Centos 7

#!/bin/bash
# 2015 Ken A. 
# run as a normal user with sudo permissions
# installs pandoc and full texlive install (4+ GB) to /usr/local/ 

USER=`whoami`
NOW=`date +"%Y%m%d%s"`
die() {
    echo "$*" 1>&2
    exit 1
}
if [ $USER == "root" ]; then die "please run this script as a normal user with sudo root privileges"; fi;
# remove any distro installed versions 
echo "removing distro installed pandoc or texlive packages"
sudo yum -y remove texlive* pandoc pandoc-citeproc || die "yum remove failed with status $?"
# prerequisites
echo "installing prerequisites"
sudo yum -y install epel-release || die "yum install failed with status $?"
sudo yum -y install haskell-platform perl-Digest-MD5 || die "yum install failed with status $?"
# create an install dir 
echo "creating an installation files dir at /usr/local/src/pandoc_$NOW"
sudo mkdir /usr/local/src/pandoc_$NOW || die "mkdir failed with status $?"
sudo chown $USER:$USER /usr/local/src/pandoc_$NOW 
cd /usr/local/src/pandoc_$NOW
echo "fixing up cabal config file"
export "HOME=/home/$USER" && cabal update || die "cabal update failed with status $?"
sed -i 's/-- user-install: True/user-install: False/g' /home/$USER/.cabal/config || die "sed 1 failed with status $?"
sed -i 's/-- root-cmd:/root-cmd: sudo/g' /home/$USER/.cabal/config || die "sed 2 failed with status $?"
sed -i 's/-- prefix: \/usr\/local/ prefix: \/usr\/local/g' /home/$USER/.cabal/config || die "sed 3 failed with status $?"

# test config 
# cabal install pandoc pandoc-citeproc --dry-run -v
echo "installing pandoc"
cabal install pandoc pandoc-citeproc || die "cabal install pandoc failed with status $?"
echo "fetching latest version of texlive"
wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz || die "wget texlive failed with status $?"
tar xvfz install-tl-unx.tar.gz --strip-components=1
echo "installing texlive. This takes a couple hours."
sudo ./install-tl --profile=/dev/null || die "texlive install-tl failed with status $?"

echo " "
echo " Done "
echo "   If everything worked, you might want to clean up /usr/local/src/"
echo "   Various install dirs may be present"
echo " "