From 8b6356035171c529c78e3d192ba99d13dae9cdde Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Thu, 13 Apr 2006 09:23:52 +0000 Subject: [PATCH] Added switch to install.sh to enable non-interactive (batch) installs. --- releasetools/install.sh | 128 ++++++++++++++++++++++++++-------------- 1 file changed, 83 insertions(+), 45 deletions(-) diff --git a/releasetools/install.sh b/releasetools/install.sh index 8a81e9739..5a1c80dac 100755 --- a/releasetools/install.sh +++ b/releasetools/install.sh @@ -40,6 +40,13 @@ thisUriList=$mydir/.urilist 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 @@ -63,9 +70,9 @@ main() { } 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() { @@ -155,10 +162,13 @@ EOF 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 @@ -167,7 +177,7 @@ EOF 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 ;; @@ -196,8 +206,11 @@ WARNING: /etc/xml/catalog exists but was not found in the 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 @@ -215,10 +228,13 @@ EOF 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 @@ -226,7 +242,8 @@ EOF *) 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 \ @@ -257,7 +274,7 @@ EOF writeDotFiles() { while read; do - echo "$REPLY" >> .profile.incl + echo "$REPLY" >> $mydir/.profile.incl done <> .cshrc.incl + echo "$REPLY" >> $mydir/.cshrc.incl done <> .profile.incl + echo "$REPLY" >> $mydir/.profile.incl done <> .cshrc.incl + echo "$REPLY" >> $mydir/.cshrc.incl done <> .emacs.el + echo "$REPLY" >> $mydir/.emacs.el done < $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 } @@ -737,7 +775,7 @@ EOF } testCatalogs() { - readlinkResponse="$(readlink -f ./ 2>/dev/null)" + readlinkResponse="$(readlink -f . 2>/dev/null)" if [ -z "$readlinkResponse" ]; then cat <