+echo "Emerald CTAN package installer..."
+
+if [ ! $(command -v kpsewhich) ] ; then
+ echo " ** Cannot find kpsewhich! Is TeX really installed?"
+ exit 1
+fi
+
+if [ ! $(command -v unzip) ] ; then
+ echo " ** Cannot find unzip! Please install it and try again."
+ exit 2
+fi
+
+if [ `ps -o uid= $$` -ne 0 ] ; then
+ echo " ** This script must be run as root"
+ exit 3
+fi
+
+if [ -f $EMERALD_PKG ] ; then
+ echo "Found $EMERALD_PKG right here."
+else
+ echo "Attempting download from $EMERALD_URL..."
+ if [ $(command -v curl) ] ; then
+ echo "Downloading $EMERALD_URL using curl."
+ command curl -L $EMERALD_URL -o $EMERALD_PKG
+ elif [ $(command -v wget) ] ; then
+ echo "Downloading $EMERALD_URL using wget."
+ command wget $EMERALD_URL -O $EMERALD_PKG
+ else
+ echo " ** Neither curl nor wget are present."
+ echo " ** Please download the emerald package manually,"
+ echo " ** put it in this directory, and try again."
+ exit 4
+ fi
+fi
+
+echo "Unpacking $EMERALD_PKG..."
+unzip -q $EMERALD_PKG
+