2011-09-23 14:56:22 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This script runs the eclipse can do the following:
|
|
|
|
# - backup configuration files
|
|
|
|
# - restore configuration files from backup loation
|
|
|
|
# - run the eclipse reconciler
|
|
|
|
# - delete the backup files.
|
|
|
|
|
|
|
|
# A list of the files of directory that are to be backed up
|
|
|
|
config_files=("artifacts.xml" "eclipse.ini" "p2" "configuration")
|
|
|
|
|
|
|
|
if [ $# -ge 2 ]
|
|
|
|
then
|
|
|
|
echo "backing up configuration files"
|
|
|
|
for file in ${config_files[@]}
|
|
|
|
do
|
|
|
|
echo $file
|
|
|
|
cp -r $1/$file $2/$file
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Running eclipse reconciler"
|
|
|
|
pushd $1
|
|
|
|
./eclipse --launcher.suppressErrors -nosplash -consolelog -application org.eclipse.equinox.p2.reconciler.application ${@:3}
|
2011-10-03 18:45:32 +00:00
|
|
|
r_exit_value=$?
|
|
|
|
|
|
|
|
if [ $# -ge 3 ] && [ $3 == "-clean" ]
|
|
|
|
then
|
|
|
|
echo "Running the initializer"
|
|
|
|
./eclipse --launcher.suppressErrors -cosolelog -nosplash -application org.eclipse.equinox.initializer.configInitializer -fileInitializer extract_patterns.txt
|
|
|
|
i_exit_value=$?
|
|
|
|
else
|
|
|
|
i_exit_value=0
|
|
|
|
fi
|
2011-09-23 14:56:22 +00:00
|
|
|
|
|
|
|
# Check exit value
|
2011-10-03 18:45:32 +00:00
|
|
|
if [ ! $i_exit_value -eq 0 ] || [ ! $r_exit_value -eq 0 ]
|
2011-09-23 14:56:22 +00:00
|
|
|
then
|
|
|
|
# Restore files
|
|
|
|
echo "Reconciler failed. Restoring files"
|
|
|
|
for file in ${config_files[@]}
|
|
|
|
do
|
|
|
|
echo $file
|
|
|
|
cp --remove-destination -Tr $2/$file $1/$file
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
popd
|
|
|
|
|
|
|
|
#delete the backup files
|
|
|
|
for file in ${config_files[@]}
|
|
|
|
do
|
|
|
|
rm -rf $2/$file
|
|
|
|
done
|
|
|
|
|
|
|
|
exit $exit_value
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Invalid options"
|
|
|
|
echo ""
|
|
|
|
echo "Usage:"
|
|
|
|
echo ""
|
2011-10-03 18:45:32 +00:00
|
|
|
echo " eclipse-reconciler <eclipse dir> <backup location> [-clean] [reconciler parameters]"
|
2011-09-23 14:56:22 +00:00
|
|
|
echo " Backsup configuration files in the given location, run the reconciler"
|
|
|
|
echo " and restore the files if there is a problem at the end delete backup files."
|
2011-10-03 18:45:32 +00:00
|
|
|
echo " If the -clean option is specified -clean is passed to the reoconciler, and the"
|
|
|
|
echo " And the initializer is rerun after reconcilation. Any parameters given after"
|
|
|
|
echo " the first three are passed directly to the reconciler"
|
2011-09-23 14:56:22 +00:00
|
|
|
|
|
|
|
exit 1;
|