Fixed indentation

This commit is contained in:
Luca Frosini 2022-07-08 14:30:53 +02:00
parent 814f57d6b1
commit c6ca91c877
1 changed files with 135 additions and 106 deletions

View File

@ -34,7 +34,7 @@ while getopts ":d:s:g:a:xh" opt; do
a) apps=$OPTARG;;
x) dryrun="true";;
h) showhelp
exit 0 ;;
exit 0 ;;
:) echo -e "\nERROR:option -$OPTARG requires an argument." >&2 ;
showhelp;
echo -e "\naborting.\n"
@ -46,8 +46,10 @@ exit 0 ;;
esac
done
if [ -z "$ghnhome" ]; then
if [ -z "$GHN_HOME" ]; then
if [ -z "$ghnhome" ]
then
if [ -z "$GHN_HOME" ]
then
echo -e "\nERROR:please specify the gHN directory (-g) or define the GHN_HOME env var." >&2
showhelp
echo -e "\naborting.\n"
@ -56,17 +58,22 @@ if [ -z "$ghnhome" ]; then
ghnhome=$GHN_HOME
fi
fi
if [ ! -d "$ghnhome" ]; then
if [ -z "$dryrun" ]; then
if [ ! -d "$ghnhome" ]
then
if [ -z "$dryrun" ]
then
mkdir $ghnhome
fi
fi
#tomcat target
if [ "$shared" = "tomcat" ]; then
if [ -z "$CATALINA_HOME" ]; then
if [ -z "$WEB_CONTAINER_HOME" ] ; then
if [ "$shared" = "tomcat" ]
then
if [ -z "$CATALINA_HOME" ]
then
if [ -z "$WEB_CONTAINER_HOME" ]
then
echo -e "\nERROR: both CATALINA_HOME and WEB_CONTAINER_HOME are undefined." >&2
showhelp
echo -e "\naborting.\n"
@ -80,7 +87,8 @@ if [ "$shared" = "tomcat" ]; then
fi
#shared is set
if [ -z "$shared" ]; then
if [ -z "$shared" ]
then
echo -e "\nERROR: shared directory is undefined (-s)." >&2
showhelp
echo -e "\naborting.\n"
@ -88,25 +96,29 @@ if [ -z "$shared" ]; then
fi
#shared exists and is a directory
if [ ! -d "$shared" ]; then
if [ ! -d "$shared" ]
then
echo -e "\nERROR: shared folder does not exist or is not a directory, aborting." >&2
exit 1;
fi
#shared exists and is a directory
if [ ! -d "$apps" ]; then
if [ ! -d "$apps" ]
then
echo -e "\nERROR: apps folder does not exist or is not a directory, aborting." >&2
exit 1;
fi
#distrolibs exists and is a directory
if [ ! -d "$distrolibs" ]; then
if [ ! -d "$distrolibs" ]
then
echo -e "\nERROR: distro libs does not exist or is not a directory, aborting."
exit 1;
fi
#distroapps exists and is a directory
if [ ! -d "$distroapps" ]; then
if [ ! -d "$distroapps" ]
then
echo -e "\nERROR: distro apps does not exist or is not a directory, aborting."
exit 1;
fi
@ -119,89 +131,99 @@ echo -e " target app directory = $(cd $(dirname $apps); pwd)/$(basename $apps
shopt -s nullglob
#uninstall libraries
if [ -f $shared/$liblist ]; then
if [ -f $shared/$liblist ]
then
echo -e "\nuninstalling existing libraries \c"
while read line; do
if [ -z "$dryrun" ]; then
while read line
do
if [ -z "$dryrun" ]
then
rm $shared/$line
fi
echo -n "."
sleep .01
done < $shared/$liblist
if [ -z "$dryrun" ]; then
if [ -z "$dryrun" ]
then
rm $shared/$liblist
fi
fi
#uninstall apps
if [ -f $shared/$applist ]; then
if [ -f $shared/$applist ]
then
echo -e "\nuninstalling existing apps \c"
while read line; do
if [ -z "$dryrun" ]; then
while read line
do
if [ -z "$dryrun" ]
then
rm $apps/$line
folder=${line:0:-4}
if [ ! -z "$folder" ]; then
if [ ! -z "$folder" ]
then
rm -rf $apps/$folder
fi
fi
echo -n "."
sleep .01
done < $shared/$applist
if [ -z "$dryrun" ]; then
if [ -z "$dryrun" ]
then
rm $shared/$applist
fi
fi
#install libraries
echo -e "\ninstalling components \c"
for f in $distrolibs/*.*;
do
if [ -z "$dryrun" ]; then
do
if [ -z "$dryrun" ]
then
cp $f $shared/
basename $f | sed -r 's/[0-9]{1,2}.[0-9]{1,2}(.[0-9]{1,2})?(-SNAPSHOT)?(-[0-9]{1,2}.[0-9]{1,2}(.[0-9]{1,2})?-[0-9]{4,8})?/*/' >> $shared/$liblist
fi
echo -n "."
sleep .01
done
done
#install apps
echo -e "\ninstalling applications \c"
for f in $distroapps/*;
do
if [ -z "$dryrun" ]; then
do
if [ -z "$dryrun" ]
then
cp $f $apps/
basename $f >> $shared/$applist
fi
echo -n "."
sleep .01
done
done
#install scripts
echo -e "\ninstalling scripts \c"
if [ ! -d "$ghnhome/scripts" ]; then
if [ -z "$dryrun" ]; then
if [ ! -d "$ghnhome/scripts" ]
then
if [ -z "$dryrun" ]
then
mkdir $ghnhome/scripts
fi
fi
for f in $distroscripts/*;
do
if [ -z "$dryrun" ]; then
do
if [ -z "$dryrun" ]
then
cp $f $ghnhome/scripts/
fi
echo -n "."
sleep .01
done
done
#install config
function escape_slashes {
@ -225,8 +247,10 @@ function replace_property {
}
echo -e "\ninstalling configuration \c"
if [ ! -s "$ghnhome/container.ini" ]; then
if [ -z "$dryrun" ]; then
if [ ! -s "$ghnhome/container.ini" ]
then
if [ -z "$dryrun" ]
then
cp $distro/container.ini $ghnhome/
fi
echo -n "."
@ -244,10 +268,13 @@ else
replace_property $property
done
fi
echo -n "."
sleep .01
fi
if [ -z "$dryrun" ]; then
if [ -z "$dryrun" ]
then
cat $distro/logback.xml | sed "s|\${LOGFILE}|$ghnhome|" > $shared/logback.xml
echo -n "."
sleep .01
@ -255,11 +282,13 @@ fi
#creating the symlink to shared and apps folder
if [ -z "$dryrun" ]; then
if [ -z "$dryrun" ]
then
ln -s $shared $ghnhome/lib
fi
if [ -z "$dryrun" ]; then
if [ -z "$dryrun" ]
then
ln -s $apps $ghnhome/apps
fi