#!/bin/sh # # this script will unpack and install the xop files # the installation can also be done manually. # # # step 1 ask for user input # RESP=0 DIR_FROM=`pwd` echo "please type full directory path where the downloaded files can be found " echo " (default: $DIR_FROM) " read RESP if [ "$RESP" != "" ]; then DIR_FROM=$RESP fi DIR_TO=$HOME/xop echo "please type full directory path xop will be installed " echo " (default: $DIR_TO) " read RESP if [ "$RESP" != "" ]; then DIR_TO=$RESP fi if test ! -d $DIR_TO; then echo "Directory $DIR_TO not found. Create it [Yes, 0=No]?" read RESP if [ "$RESP" != "" ]; then echo "xop_unpack aborted." exit 1 fi mkdir $DIR_TO if test $? -ne 0; then echo "ERROR: Problem creating $DIR_TO" echo "xop_unpack aborted." exit 1 fi fi echo "please type the installation key [obtained by email from srio@esrf.fr] " read RESP CRYPT_KEY=$RESP echo "**********************************************" echo "Starting unpacking with the following inputs: " echo " Directory with downloaded files: $DIR_FROM" echo " Directory where xop will be installed (=xop home dir): $DIR_TO" echo " Decrypting key: $CRYPT_KEY" echo "**********************************************" echo "Type to proceed, 0 to to exit " read RESP if [ "$RESP" != "" ]; then echo "xop_unpack aborted." exit 1 fi echo "Changing directory to $DIR_TO" cd $DIR_TO # # step 2 decrypt and unpack crypted files # FILES=`echo $DIR_FROM/*.encrypted` if [ "$FILES" != '$DIR_FOM/*.encrypted' ]; then echo " encripted files: $FILES" for ifile in $FILES; do echo "decrypting file $ifile using command \ crypt $CRYPT_KEY < $ifile > tmp.tar.Z " /bin/rm -f tmp.tar.Z crypt $CRYPT_KEY < $ifile > tmp.tar.Z if [ $? != 0 ]; then echo "error decrypting." exit 1 fi echo "unpacking file $ifile" zcat tmp.tar.Z | tar xvf - if [ $? != 0 ]; then echo "error unpacking." exit 1 fi echo "done for $ifile (`date`)." done fi # # step 3 unpack tar files # FILES=`echo $DIR_FROM/*.Z` if [ "$FILES" != '$DIR_FOM/*.Z' ]; then echo " encripted files: $FILES" for ifile in $FILES; do echo "unpacking file $ifile (`date`)..." zcat $ifile | tar xvf - if [ $? != 0 ]; then echo "error unpacking." exit 1 fi echo "done for $ifile (`date`)." done fi # # step 4 Edit the xop file and place the right dir in $XOP_HOME # echo "**********************************************" echo "Unpacking finished." echo " Now the file xop will be changed to reflect the installation" echo " directory. The original xop file will be copied to xop-orig." echo "**********************************************" echo "Type to proceed, 0 to to exit " read RESP if [ "$RESP" != "" ]; then echo "xop_unpack exited without changing xop." exit 1 fi /bin/rm -f tmp.tmp tmp.tmp2 echo $DIR_TO > tmp.tmp sed 's/\//\\\//g' tmp.tmp > tmp.tmp2 DIR_TO2=`cat tmp.tmp2` echo "original xop file copied to xop-orig" cp xop xop-orig /bin/rm -f xop SUBSTITUTE="s/\/pgexp\/applications1\/XRayOptics\/xop/$DIR_TO2/" sed $SUBSTITUTE xop-orig > xop chmod 755 xop /bin/rm -f tmp.tmp tmp.tmp2 tmp.tar.Z # # step 5 Exit # echo "Procedute completed. You may start xop by typing $DIR_TO/xop" exit 0;