#!/bin/sh
#
# uninstall_CIAO_scripts
#
# Version 3.2 (09 December 2004)
#
# Usage:
# unix% cp uninstall_CIAO_scripts $ASCDS_INSTALL/contrib
# unix% cd $ASCDS_INSTALL/contrib
# unix% ./uninstall_CIAO_scripts
#
# Description:
#
# This script removes any files installed in
# $ASCDS_INSTALL/contrib via a CIAO_scripts.tar tar file released
# for CIAO 3.0.2 or later.  (If you want to uninstall a script
# package released prior to CIAO 3.0.2, use the script
# "uninstall_CIAO_scripts_pre_3.0.2".)  It is designed for users
# who wish to remove old or unnecessary files and directories from
# $ASCDS_INSTALL/contrib (presumably just before unpacking a new
# CIAO_scripts.tar).
#
# The script removes individual files by name.  After removing
# files, the script removes any directories that have been left
# empty.
#
# This script should be completely safe for the vast majority of
# users.  However, DO NOT RUN THIS SCRIPT if any of the following
# are true:
#   - You do not own the files in $ASCDS_INSTALL/contrib (not
#     dangerous, but will produce many error messages about rm and
#     rmdir failures)
#   - You have made custom modifications to any of the files from
#     CIAO_scripts.tar and have installed these (under their
#     original names) in $ASCDS_INSTALL/contrib
#   - For whatever reason, you wish to continue using older
#     versions of the CIAO scripts
#
# For more information on available CIAO scripts or to download
# the latest versions, see
# http://cxc.harvard.edu/ciao/download/scripts/
#

old_files='
bin/acis_bkgrnd_lookup
bin/acis_expmap
bin/acis_fef_lookup
bin/acis_set_ardlib
bin/acisspec
bin/add_grating_orders
bin/add_grating_spectra
bin/apply_acisabs
bin/check_rmf.pl
bin/color_image
bin/fullgarf
bin/get_sky_limits
bin/getcounts.sl
bin/merge_all
bin/mk_tggrid
bin/mkBgReg.pl
bin/mkSubBgReg.pl
bin/monitor_photom
bin/psextract
bin/query_heg_grid
bin/show_tgain_corr
bin/simspec
bin/tg_bkg
bin/tg_osort_img
bin/tg_scale_reg
bin/interpreted/acisabs.sl
bin/interpreted/analyze_ltcrv.sl
bin/interpreted/chart_spectrum.sl
bin/interpreted/chips_tgscript.ch
bin/interpreted/cxchistory.sl
bin/interpreted/example1.chp
bin/interpreted/example1.sl
bin/interpreted/example10.chp
bin/interpreted/example10.sl
bin/interpreted/example11.chp
bin/interpreted/example11.sl
bin/interpreted/example12.chp
bin/interpreted/example12.sl
bin/interpreted/example2.chp
bin/interpreted/example2.sl
bin/interpreted/example3.sl
bin/interpreted/example4-fast.chp
bin/interpreted/example4-fast.sl
bin/interpreted/example4.chp
bin/interpreted/example4.sl
bin/interpreted/example5-fast.chp
bin/interpreted/example5-fast.sl
bin/interpreted/example5-varmm.chp
bin/interpreted/example5-varmm.sl
bin/interpreted/example5.chp
bin/interpreted/example5.sl
bin/interpreted/example6.chp
bin/interpreted/example6.sl
bin/interpreted/example7.chp
bin/interpreted/example7.sl
bin/interpreted/example8.chp
bin/interpreted/example8.sl
bin/interpreted/example9.chp
bin/interpreted/example9.sl
bin/interpreted/get_evt_data.sl
bin/interpreted/lc.fits
bin/interpreted/lc_clean.sl
bin/interpreted/paramest.sl
bin/interpreted/regions.sl
bin/interpreted/setplot.sl
bin/interpreted/sherpa_paramset.sl
bin/interpreted/sherpa_plotfns.sl
bin/interpreted/sherpa_simspec.sl
bin/interpreted/sherpa_utils.sl
bin/interpreted/show_tgain_corr.sl
bin/interpreted/show_wgt.sl
bin/interpreted/spectrum.sl
bin/interpreted/sstats.sl
bin/interpreted/tg_scale_reg.sl
doc/txt/README_acis_expmap
doc/txt/README_acisabs
doc/txt/README_acisspec
doc/txt/README_check_rmf
doc/txt/README_chips_tgscript
doc/txt/README_mk_tggrid
doc/txt/README_query_heg_grid
doc/txt/README_slang-tips
doc/xml/acis_bkgrnd_lookup.xml
doc/xml/acis_expmap.xml
doc/xml/acis_fef_lookup.xml
doc/xml/acis_set_ardlib.xml
doc/xml/acisspec.xml
doc/xml/add_grating_orders.xml
doc/xml/add_grating_spectra.xml
doc/xml/analyze_ltcrv.xml
doc/xml/calc_kcorr.xml
doc/xml/chart_spectrum.xml
doc/xml/color_image.xml
doc/xml/fullgarf.xml
doc/xml/get_sky_limits.xml
doc/xml/get_source_components.xml
doc/xml/groupbycounts.xml
doc/xml/lc_clean.xml
doc/xml/merge_all.xml
doc/xml/mkbgreg.xml
doc/xml/mksubbgreg.xml
doc/xml/monitor_photom.xml
doc/xml/paramest.xml
doc/xml/plot_eprof.xml
doc/xml/plot_rprof.xml
doc/xml/psextract.xml
doc/xml/regions.xml
doc/xml/set_dataspace.xml
doc/xml/setplot.xml
doc/xml/sherpa_plotfns.xml
doc/xml/sherpa_utils.xml
doc/xml/show_tgain_corr.xml
doc/xml/show_wgt.xml
doc/xml/simspec.xml
doc/xml/slang-math.xml
doc/xml/slang-overview.xml
doc/xml/slang-tips.xml
doc/xml/slang-variables.xml
doc/xml/slang.xml
doc/xml/spectrum.xml
doc/xml/sstats.xml
doc/xml/tg_bkg.xml
doc/xml/tg_osort_img.xml
doc/xml/tg_scale_reg.xml
param/acis_bkgrnd_lookup.par
param/acis_fef_lookup.par
param/acis_set_ardlib.par
param/acisspec.par
param/add_grating_orders.par
param/add_grating_spectra.par
param/apply_acisabs.par
param/fullgarf.par
param/get_sky_limits.par
param/merge_all.par
param/monitor_photom.par
param/paramest.par
param/psextract.par
param/setplot.par
param/show_tgain_corr.par
param/simspec.par
param/tg_scale_reg.par
share/slsh/local-packages/analyze_ltcrv.sl
share/slsh/local-packages/chart_spectrum.sl
share/slsh/local-packages/chips_tgscript.ch
share/slsh/local-packages/cxchistory.sl
share/slsh/local-packages/example1.chp
share/slsh/local-packages/example1.sl
share/slsh/local-packages/example10.chp
share/slsh/local-packages/example10.sl
share/slsh/local-packages/example11.chp
share/slsh/local-packages/example11.sl
share/slsh/local-packages/example12.chp
share/slsh/local-packages/example12.sl
share/slsh/local-packages/example2.chp
share/slsh/local-packages/example2.sl
share/slsh/local-packages/example3.sl
share/slsh/local-packages/example4-fast.chp
share/slsh/local-packages/example4-fast.sl
share/slsh/local-packages/example4.chp
share/slsh/local-packages/example4.sl
share/slsh/local-packages/example5-fast.chp
share/slsh/local-packages/example5-fast.sl
share/slsh/local-packages/example5-varmm.chp
share/slsh/local-packages/example5-varmm.sl
share/slsh/local-packages/example5.chp
share/slsh/local-packages/example5.sl
share/slsh/local-packages/example6.chp
share/slsh/local-packages/example6.sl
share/slsh/local-packages/example7.chp
share/slsh/local-packages/example7.sl
share/slsh/local-packages/example8.chp
share/slsh/local-packages/example8.sl
share/slsh/local-packages/example9.chp
share/slsh/local-packages/example9.sl
share/slsh/local-packages/get_evt_data.sl
share/slsh/local-packages/lc.fits
share/slsh/local-packages/lc_clean.sl
share/slsh/local-packages/paramest.sl
share/slsh/local-packages/regions.sl
share/slsh/local-packages/setplot.sl
share/slsh/local-packages/sherpa_paramset.sl
share/slsh/local-packages/sherpa_plotfns.sl
share/slsh/local-packages/sherpa_simspec.sl
share/slsh/local-packages/sherpa_utils.sl
share/slsh/local-packages/show_tgain_corr.sl
share/slsh/local-packages/show_wgt.sl
share/slsh/local-packages/spectrum.sl
share/slsh/local-packages/sstats.sl
share/slsh/local-packages/tg_scale_reg.sl
README_CIAO_scripts
VERSION.CIAO_scripts
Changes.CIAO_scripts
'

old_dirs='
bin/interpreted
bin
doc/txt
doc/xml
doc
param
share/slsh/local-packages
share/slsh
share
'

for file in $old_files
do
  if [ -f $file ]; then
    echo "Removing file $file"
    rm $file
  fi
done

for dir in $old_dirs
do
  if [ -d $dir ]; then
    if [ -z "`ls $dir`" ]; then
      echo "Removing empty directory $dir"
      rmdir $dir
    fi
  fi
done

echo "Done!"

