Fixed indentation
This commit is contained in:
parent
814f57d6b1
commit
c6ca91c877
|
@ -27,27 +27,29 @@ function showhelp {
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts ":d:s:g:a:xh" opt; do
|
while getopts ":d:s:g:a:xh" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
d) distro=$OPTARG;;
|
d) distro=$OPTARG;;
|
||||||
s) shared=$OPTARG;;
|
s) shared=$OPTARG;;
|
||||||
g) ghnhome=$OPTARG;;
|
g) ghnhome=$OPTARG;;
|
||||||
a) apps=$OPTARG;;
|
a) apps=$OPTARG;;
|
||||||
x) dryrun="true";;
|
x) dryrun="true";;
|
||||||
h) showhelp
|
h) showhelp
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
:) echo -e "\nERROR:option -$OPTARG requires an argument." >&2 ;
|
:) echo -e "\nERROR:option -$OPTARG requires an argument." >&2 ;
|
||||||
showhelp;
|
showhelp;
|
||||||
echo -e "\naborting.\n"
|
echo -e "\naborting.\n"
|
||||||
exit 1;;
|
exit 1;;
|
||||||
\?) echo -e "\nERROR:invalid option: -$OPTARG";
|
\?) echo -e "\nERROR:invalid option: -$OPTARG";
|
||||||
showhelp;
|
showhelp;
|
||||||
echo -e "\naborting.\n"
|
echo -e "\naborting.\n"
|
||||||
exit 1 >&2 ;;
|
exit 1 >&2 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$ghnhome" ]; then
|
if [ -z "$ghnhome" ]
|
||||||
if [ -z "$GHN_HOME" ]; then
|
then
|
||||||
|
if [ -z "$GHN_HOME" ]
|
||||||
|
then
|
||||||
echo -e "\nERROR:please specify the gHN directory (-g) or define the GHN_HOME env var." >&2
|
echo -e "\nERROR:please specify the gHN directory (-g) or define the GHN_HOME env var." >&2
|
||||||
showhelp
|
showhelp
|
||||||
echo -e "\naborting.\n"
|
echo -e "\naborting.\n"
|
||||||
|
@ -56,31 +58,37 @@ if [ -z "$ghnhome" ]; then
|
||||||
ghnhome=$GHN_HOME
|
ghnhome=$GHN_HOME
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ ! -d "$ghnhome" ]; then
|
if [ ! -d "$ghnhome" ]
|
||||||
if [ -z "$dryrun" ]; then
|
then
|
||||||
mkdir $ghnhome
|
if [ -z "$dryrun" ]
|
||||||
|
then
|
||||||
|
mkdir $ghnhome
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#tomcat target
|
#tomcat target
|
||||||
if [ "$shared" = "tomcat" ]; then
|
if [ "$shared" = "tomcat" ]
|
||||||
if [ -z "$CATALINA_HOME" ]; then
|
then
|
||||||
if [ -z "$WEB_CONTAINER_HOME" ] ; then
|
if [ -z "$CATALINA_HOME" ]
|
||||||
echo -e "\nERROR: both CATALINA_HOME and WEB_CONTAINER_HOME are undefined." >&2
|
then
|
||||||
showhelp
|
if [ -z "$WEB_CONTAINER_HOME" ]
|
||||||
echo -e "\naborting.\n"
|
then
|
||||||
exit 1
|
echo -e "\nERROR: both CATALINA_HOME and WEB_CONTAINER_HOME are undefined." >&2
|
||||||
else
|
showhelp
|
||||||
CATALINA_HOME=$WEB_CONTAINER_HOME
|
echo -e "\naborting.\n"
|
||||||
fi
|
exit 1
|
||||||
fi
|
else
|
||||||
|
CATALINA_HOME=$WEB_CONTAINER_HOME
|
||||||
|
fi
|
||||||
|
fi
|
||||||
shared=$CATALINA_HOME/lib
|
shared=$CATALINA_HOME/lib
|
||||||
apps=$CATALINA_HOME/webapps
|
apps=$CATALINA_HOME/webapps
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#shared is set
|
#shared is set
|
||||||
if [ -z "$shared" ]; then
|
if [ -z "$shared" ]
|
||||||
|
then
|
||||||
echo -e "\nERROR: shared directory is undefined (-s)." >&2
|
echo -e "\nERROR: shared directory is undefined (-s)." >&2
|
||||||
showhelp
|
showhelp
|
||||||
echo -e "\naborting.\n"
|
echo -e "\naborting.\n"
|
||||||
|
@ -88,25 +96,29 @@ if [ -z "$shared" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#shared exists and is a directory
|
#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
|
echo -e "\nERROR: shared folder does not exist or is not a directory, aborting." >&2
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#shared exists and is a directory
|
#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
|
echo -e "\nERROR: apps folder does not exist or is not a directory, aborting." >&2
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#distrolibs exists and is a directory
|
#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."
|
echo -e "\nERROR: distro libs does not exist or is not a directory, aborting."
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#distroapps exists and is a directory
|
#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."
|
echo -e "\nERROR: distro apps does not exist or is not a directory, aborting."
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
@ -119,102 +131,112 @@ echo -e " target app directory = $(cd $(dirname $apps); pwd)/$(basename $apps
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
|
|
||||||
#uninstall libraries
|
#uninstall libraries
|
||||||
if [ -f $shared/$liblist ]; then
|
if [ -f $shared/$liblist ]
|
||||||
|
then
|
||||||
echo -e "\nuninstalling existing libraries \c"
|
echo -e "\nuninstalling existing libraries \c"
|
||||||
while read line; do
|
while read line
|
||||||
if [ -z "$dryrun" ]; then
|
do
|
||||||
rm $shared/$line
|
if [ -z "$dryrun" ]
|
||||||
|
then
|
||||||
|
rm $shared/$line
|
||||||
fi
|
fi
|
||||||
echo -n "."
|
echo -n "."
|
||||||
sleep .01
|
sleep .01
|
||||||
|
done < $shared/$liblist
|
||||||
done < $shared/$liblist
|
|
||||||
if [ -z "$dryrun" ]; then
|
|
||||||
rm $shared/$liblist
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
if [ -z "$dryrun" ]
|
||||||
|
then
|
||||||
|
rm $shared/$liblist
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#uninstall apps
|
#uninstall apps
|
||||||
if [ -f $shared/$applist ]; then
|
if [ -f $shared/$applist ]
|
||||||
|
then
|
||||||
echo -e "\nuninstalling existing apps \c"
|
echo -e "\nuninstalling existing apps \c"
|
||||||
while read line; do
|
while read line
|
||||||
if [ -z "$dryrun" ]; then
|
do
|
||||||
rm $apps/$line
|
if [ -z "$dryrun" ]
|
||||||
folder=${line:0:-4}
|
then
|
||||||
if [ ! -z "$folder" ]; then
|
rm $apps/$line
|
||||||
rm -rf $apps/$folder
|
folder=${line:0:-4}
|
||||||
fi
|
if [ ! -z "$folder" ]
|
||||||
|
then
|
||||||
|
rm -rf $apps/$folder
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
echo -n "."
|
|
||||||
sleep .01
|
echo -n "."
|
||||||
|
sleep .01
|
||||||
done < $shared/$applist
|
done < $shared/$applist
|
||||||
if [ -z "$dryrun" ]; then
|
|
||||||
rm $shared/$applist
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
if [ -z "$dryrun" ]
|
||||||
|
then
|
||||||
|
rm $shared/$applist
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#install libraries
|
#install libraries
|
||||||
echo -e "\ninstalling components \c"
|
echo -e "\ninstalling components \c"
|
||||||
for f in $distrolibs/*.*;
|
for f in $distrolibs/*.*;
|
||||||
do
|
do
|
||||||
if [ -z "$dryrun" ]; then
|
if [ -z "$dryrun" ]
|
||||||
cp $f $shared/
|
then
|
||||||
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
|
cp $f $shared/
|
||||||
fi
|
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
|
||||||
echo -n "."
|
fi
|
||||||
sleep .01
|
|
||||||
done
|
echo -n "."
|
||||||
|
sleep .01
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
#install apps
|
#install apps
|
||||||
echo -e "\ninstalling applications \c"
|
echo -e "\ninstalling applications \c"
|
||||||
for f in $distroapps/*;
|
for f in $distroapps/*;
|
||||||
do
|
do
|
||||||
if [ -z "$dryrun" ]; then
|
if [ -z "$dryrun" ]
|
||||||
cp $f $apps/
|
then
|
||||||
basename $f >> $shared/$applist
|
cp $f $apps/
|
||||||
fi
|
basename $f >> $shared/$applist
|
||||||
echo -n "."
|
fi
|
||||||
sleep .01
|
echo -n "."
|
||||||
done
|
sleep .01
|
||||||
|
done
|
||||||
|
|
||||||
#install scripts
|
#install scripts
|
||||||
echo -e "\ninstalling scripts \c"
|
echo -e "\ninstalling scripts \c"
|
||||||
if [ ! -d "$ghnhome/scripts" ]; then
|
if [ ! -d "$ghnhome/scripts" ]
|
||||||
if [ -z "$dryrun" ]; then
|
then
|
||||||
mkdir $ghnhome/scripts
|
if [ -z "$dryrun" ]
|
||||||
|
then
|
||||||
|
mkdir $ghnhome/scripts
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for f in $distroscripts/*;
|
for f in $distroscripts/*;
|
||||||
do
|
do
|
||||||
if [ -z "$dryrun" ]; then
|
if [ -z "$dryrun" ]
|
||||||
cp $f $ghnhome/scripts/
|
then
|
||||||
fi
|
cp $f $ghnhome/scripts/
|
||||||
|
fi
|
||||||
|
|
||||||
echo -n "."
|
echo -n "."
|
||||||
sleep .01
|
sleep .01
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#install config
|
#install config
|
||||||
function escape_slashes {
|
function escape_slashes {
|
||||||
sed 's/\//\\\//g'
|
sed 's/\//\\\//g'
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_line {
|
function change_line {
|
||||||
local OLD_LINE_PATTERN=$1; shift
|
local OLD_LINE_PATTERN=$1; shift
|
||||||
local NEW_LINE=$1; shift
|
local NEW_LINE=$1; shift
|
||||||
local FILE=$1
|
local FILE=$1
|
||||||
|
|
||||||
local NEW=$(echo "${NEW_LINE}" | escape_slashes)
|
local NEW=$(echo "${NEW_LINE}" | escape_slashes)
|
||||||
sed -i '/'"${OLD_LINE_PATTERN}"'/s/.*/'"${NEW}"'/' "${FILE}"
|
sed -i '/'"${OLD_LINE_PATTERN}"'/s/.*/'"${NEW}"'/' "${FILE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -225,12 +247,14 @@ function replace_property {
|
||||||
}
|
}
|
||||||
|
|
||||||
echo -e "\ninstalling configuration \c"
|
echo -e "\ninstalling configuration \c"
|
||||||
if [ ! -s "$ghnhome/container.ini" ]; then
|
if [ ! -s "$ghnhome/container.ini" ]
|
||||||
if [ -z "$dryrun" ]; then
|
then
|
||||||
|
if [ -z "$dryrun" ]
|
||||||
|
then
|
||||||
cp $distro/container.ini $ghnhome/
|
cp $distro/container.ini $ghnhome/
|
||||||
fi
|
fi
|
||||||
echo -n "."
|
echo -n "."
|
||||||
sleep .01
|
sleep .01
|
||||||
else
|
else
|
||||||
if [ -z "$dryrun" ]; then
|
if [ -z "$dryrun" ]; then
|
||||||
#echo "Creating a backup copy of $ghnhome/container.ini"
|
#echo "Creating a backup copy of $ghnhome/container.ini"
|
||||||
|
@ -244,22 +268,27 @@ else
|
||||||
replace_property $property
|
replace_property $property
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n "."
|
echo -n "."
|
||||||
sleep .01
|
sleep .01
|
||||||
fi
|
fi
|
||||||
if [ -z "$dryrun" ]; then
|
|
||||||
cat $distro/logback.xml | sed "s|\${LOGFILE}|$ghnhome|" > $shared/logback.xml
|
if [ -z "$dryrun" ]
|
||||||
echo -n "."
|
then
|
||||||
sleep .01
|
cat $distro/logback.xml | sed "s|\${LOGFILE}|$ghnhome|" > $shared/logback.xml
|
||||||
|
echo -n "."
|
||||||
|
sleep .01
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#creating the symlink to shared and apps folder
|
#creating the symlink to shared and apps folder
|
||||||
|
|
||||||
if [ -z "$dryrun" ]; then
|
if [ -z "$dryrun" ]
|
||||||
|
then
|
||||||
ln -s $shared $ghnhome/lib
|
ln -s $shared $ghnhome/lib
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$dryrun" ]; then
|
if [ -z "$dryrun" ]
|
||||||
|
then
|
||||||
ln -s $apps $ghnhome/apps
|
ln -s $apps $ghnhome/apps
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue