exampleCatalogManager=$mydir/.CatalogManager.properties.example
thisCatalogManager=$HOME/.resolver/CatalogManager.properties
+if [ ! "${*#--batch}" = "$*" ]; then
+ batchmode="Yes";
+ echo "Using batch mode."
+else
+ batchmode="No";
+fi
+
osName=$(uname -o)
classPathSeparator=":"
if [ "$osName" = "Cygwin" ]; then
}
removeOldFiles() {
- rm -f ./.profile.incl
- rm -f ./.cshrc.incl
- rm -f ./.emacs.el
+ rm -f $mydir/.profile.incl
+ rm -f $mydir/.cshrc.incl
+ rm -f $mydir/.emacs.el
}
checkRoot() {
if [ -f $thisCatalogManager ]; then
myCatalogManager=$thisCatalogManager
else
- echo
- read -s -n1 -p "Create $thisCatalogManager file? [Yes] "
- echo "$REPLY"
- echo
+ REPLY=""
+ if [ ! "$batchmode" = "Yes" ]; then
+ echo
+ read -s -n1 -p "Create $thisCatalogManager file? [Yes] "
+ echo "$REPLY"
+ echo
+ fi
case $REPLY in
[nNqQ])
emitNoChangeMsg
if [ ! -d "${thisCatalogManager%/*}" ]; then
mkdir -p ${thisCatalogManager%/*}
fi
- cp ./.CatalogManager.properties.example $thisCatalogManager || exit 1
+ cp $mydir/.CatalogManager.properties.example $thisCatalogManager || exit 1
echo "NOTE: $thisCatalogManager file created"
myCatalogManager=$thisCatalogManager
;;
will need to remove it manually.
EOF
- read -s -n1 -p "Add /etc/xml/catalog to $myCatalogManager? [Yes] "
- echo "$REPLY"
+ REPLY=""
+ if [ ! "$batchmode" = "Yes" ]; then
+ read -s -n1 -p "Add /etc/xml/catalog to $myCatalogManager? [Yes] "
+ echo "$REPLY"
+ fi
case $REPLY in
[nNqQ])
echo
echo
emitNoChangeMsg
else
- echo
- read -s -n1 -p "Add $thisJavaXmlCatalog to $myCatalogManager file? [Yes] "
- echo "$REPLY"
- echo
+ REPLY=""
+ if [ ! "$batchmode" = "Yes" ]; then
+ echo
+ read -s -n1 -p "Add $thisJavaXmlCatalog to $myCatalogManager file? [Yes] "
+ echo "$REPLY"
+ echo
+ fi
case $REPLY in
[nNqQ])
emitNoChangeMsg
*)
if [ "$catalogsLine" ] ; then
if [ "${catalogsLine#*$thisJavaXmlCatalog*}" != "$catalogsLine" ]; then
- echo "NOTE: $thisJavaXmlCatalog already in $myCatalogManager"
+ echo "NOTE: $thisJavaXmlCatalog already"
+ echo " in $myCatalogManager"
else
mv $myCatalogManager $catalogBackup || exit 1
sed "s#^catalogs=\(.*\)\$#catalogs=$thisJavaXmlCatalog;\1;$etcXmlCatalog#" $catalogBackup \
writeDotFiles() {
while read; do
- echo "$REPLY" >> .profile.incl
+ echo "$REPLY" >> $mydir/.profile.incl
done <<EOF
if [ -z "\$XML_CATALOG_FILES" ]; then
XML_CATALOG_FILES="$thisXmlCatalog"
EOF
while read; do
- echo "$REPLY" >> .cshrc.incl
+ echo "$REPLY" >> $mydir/.cshrc.incl
done <<EOF
if ( ! $\?XML_CATALOG_FILES ) then
setenv XML_CATALOG_FILES "$thisXmlCatalog"
if [ -n "$myCatalogManager" ]; then
myCatalogManagerDir=${myCatalogManager%/*}
while read; do
- echo "$REPLY" >> .profile.incl
+ echo "$REPLY" >> $mydir/.profile.incl
done <<EOF
EOF
while read; do
- echo "$REPLY" >> .cshrc.incl
+ echo "$REPLY" >> $mydir/.cshrc.incl
done <<EOF
fi
while read; do
- echo "$REPLY" >> .emacs.el
+ echo "$REPLY" >> $mydir/.emacs.el
done <<EOF
(add-hook
'nxml-mode-hook
for file in $myStartupFiles; do
if [ -f "$HOME/$file" ]; then
dotFileBackup=$HOME/$file.$$.bak
- read -s -n1 -p "Update $HOME/$file? [Yes] "
- echo "$REPLY"
+ REPLY=""
+ if [ ! "$batchmode" = "Yes" ]; then
+ read -s -n1 -p "Update $HOME/$file? [Yes] "
+ echo "$REPLY"
+ fi
case $REPLY in
[nNqQ])
cat <<EOF
fi
done
if [ ! -f "$myEmacsFile" ]; then
- read -s -n1 -p "No .emacs or .emacs.el file. Create one? [No] "
- echo "$REPLY"
- echo
+ REPLY=""
+ if [ ! "$batchmode" = "Yes" ]; then
+ read -s -n1 -p "No .emacs or .emacs.el file. Create one? [No] "
+ echo "$REPLY"
+ echo
+ fi
case $REPLY in
[yY])
myEmacsFile=$HOME/.emacs
esac
fi
if [ -n "$myEmacsFile" ]; then
- read -s -n1 -p "Update $myEmacsFile? [Yes] "
- echo "$REPLY"
- echo
+ REPLY=""
+ if [ ! "$batchmode" = "Yes" ]; then
+ read -s -n1 -p "Update $myEmacsFile? [Yes] "
+ echo "$REPLY"
+ echo
+ fi
case $REPLY in
[nNqQ])
cat <<EOF
catalogsLine=$(grep "^catalogs=" $myCatalogManager)
if [ "$catalogsLine" ] ; then
if [ "${catalogsLine#*$thisXmlCatalog*}" != "$catalogsLine" ]; then
- read -s -n1 -p "Revert $myCatalogManager? [Yes] "
- echo "$REPLY"
+ REPLY=""
+ if [ ! "$batchmode" = "Yes" ]; then
+ read -s -n1 -p "Revert $myCatalogManager? [Yes] "
+ echo "$REPLY"
+ fi
case $REPLY in
[nNqQ]*)
cat <<EOF
loadLine="$(grep "$revertLine" "$myEmacsFile")"
if [ -n "$loadLine" ]; then
echo
- read -s -n1 -p "Revert $myEmacsFile? [Yes] "
- echo "$REPLY"
+ REPLY=""
+ if [ ! "$batchmode" = "Yes" ]; then
+ read -s -n1 -p "Revert $myEmacsFile? [Yes] "
+ echo "$REPLY"
+ fi
case $REPLY in
[nNqQ]*)
cat <<EOF
esac
lineExists="$(grep "$revertLineEsc" $HOME/$file )"
if [ "$lineExists" ]; then
- read -s -n1 -p "Update $HOME/$file? [Yes] "
- echo "$REPLY"
+ REPLY=""
+ if [ ! "$batchmode" = "Yes" ]; then
+ read -s -n1 -p "Update $HOME/$file? [Yes] "
+ echo "$REPLY"
+ fi
case $REPLY in
[nNqQ]*)
cat <<EOF
done
removeOldFiles
echo "Done. Deleted uninstall.sh file."
- rm -f ./test.sh || exit 1
- rm -f ./uninstall.sh || exit 1
+ rm -f $mydir/test.sh || exit 1
+ rm -f $mydir/uninstall.sh || exit 1
}
writeUninstallFile() {
- uninstallFile=./uninstall.sh
- echo "#!/bin/sh" > $uninstallFile || exit 1
- echo "$mydir/install.sh --uninstall \\" >> $uninstallFile || exit 1
- echo " --catalogManager=$myCatalogManager \\" >> $uninstallFile || exit 1
- echo " --dotEmacs=$myEmacsFile" >> $uninstallFile || exit 1
+ uninstallFile=$mydir/uninstall.sh
+ echo "#!/bin/bash" > $uninstallFile || exit 1
+ echo "mydir=\$(readlink -f \$(dirname \$0))" >> $uninstallFile || exit 1
+ echo "\$mydir/install.sh \\" >> $uninstallFile || exit 1
+ echo " --uninstall \\" >> $uninstallFile || exit 1
+ echo " --catalogManager=$myCatalogManager \\" >> $uninstallFile || exit 1
+ echo " --dotEmacs=$myEmacsFile \\" >> $uninstallFile || exit 1
+ echo " \$@" >> $uninstallFile || exit 1
chmod 755 $uninstallFile || exit 1
}
writeTestFile() {
- testFile=./test.sh
- echo "#!/bin/sh" > $testFile || exit 1
- echo "$mydir/install.sh --test" >> $testFile || exit 1
+ testFile=$mydir/test.sh
+ echo "#!/bin/bash" > $testFile || exit 1
+ echo "./install.sh --test" >> $testFile || exit 1
chmod 755 $testFile || exit 1
}
}
testCatalogs() {
- readlinkResponse="$(readlink -f ./ 2>/dev/null)"
+ readlinkResponse="$(readlink -f . 2>/dev/null)"
if [ -z "$readlinkResponse" ]; then
cat <<EOF