Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
4.4 kB
2
Indexable
Never
#!/bin/bash

#set -vx


usage () {
    cat <<HELP_USAGE

   `basename $0` -s <site> -e <env>

   -s  the site name (ncom, wcom, rcom, intl, spt, bham, hg)
   -e  the environment name (prod, qa1, stg1)

Display a listing of the GF domain 'application' directories of the app instances on each server.
This allows a developer to see if the instance has the latest version of the deployed code.

Note that an instance must be restarted in order for it to get the latest code
from the domain admin server.

The listings are sorted in reverse time - recently updated files will be listed last. 

HELP_USAGE
}


me=`basename $0`

while getopts s:e: opt; do
  case $opt in
  s)
      site=$OPTARG
      ;;
  e)
      theenv=$OPTARG
      ;;
  esac
done

tier="app";

declare -A appMap
appMap[ncom-app-prod]='atl4sfapp,06';
appMap[ncom-app-qa1]='qa1sfapp,03';
appMap[ncom-app-stg1]='stg1sfapp,03';

appMap[wcom-app-prod]='atl4wcomapp,03';
appMap[wcom-app-qa1]='qa1wcomapp,04';
appMap[wcom-app-stg1]='stg1wcomapp,03';

appMap[rcom-app-prod]='atl4rcomapp,03';
appMap[rcom-app-qa1]='qa1rcomapp,04';
appMap[rcom-app-stg1]='stg1rcomapp,03';

appMap[intl-app-prod]='atl4intlapp,03';
appMap[intl-app-qa1]='qa1intlapp,04';
appMap[intl-app-stg1]='stg1intlapp,03';

appMap[spt-app-prod]='atl4wcomapp,03';
appMap[spt-app-qa1]='qa1wcomapp,03';
appMap[spt-app-stg1]='stg1wcomapp,03';

appMap[bham-app-prod]='atl4bhamapp,06';
appMap[bham-app-qa1]='qa1bhamapp,03';
appMap[bham-app-stg1]='stg1bhamapp,03';

appMap[hg-app-prod]='atl4hgapp,03';
appMap[hg-app-qa1]='qa1hgapp,03';
appMap[hg-app-stg1]='stg1hgapp,03';

appMap[dcom-app-prod]='atl4dcomapp,03';
appMap[dcom-app-qa1]='qa1dcomapp,03';
appMap[dcom-app-stg1]='stg1dcomapp,03';


#echo
#echo "App map:"
#for K in "${!appMap[@]}"; do echo $K --- ${appMap[$K]}; done

appPrefix=${theenv};

if [[ ${theenv} == 'prod' ]]; then
    appPrefix='atl4';
fi

declare -A dirMap
dirMap[ncom-app]="/opt/web/www.networksolutions.com/domains/nodes/${appPrefix}sfapp0?/sf-${appPrefix}sfapp0?-instance-?/applications/sf";
dirMap[wcom-app]="/opt/web/checkout.web.com/domains/nodes/${appPrefix}wcomapp0?/sfwcom-${appPrefix}wcomapp0?-instance-?/applications/sfwcom";
dirMap[rcom-app]="/opt/web/www.register.com/domains/nodes/${appPrefix}rcomapp0?/sfrcom-${appPrefix}rcomapp0?-instance-?/applications/sfrcom";
dirMap[intl-app]="/opt/web/uk.web.com/domains/nodes/${appPrefix}intlapp0?/sfuk-${appPrefix}intlapp0?-instance-?/applications/sfuk";
dirMap[spt-app]="/opt/web/spt.web.com/domains/nodes/${appPrefix}wcomapp0?/spt-${appPrefix}wcomapp0?-instance-?/applications/spt";
dirMap[bham-app]="/opt/web/use.bluehost.com/domains/nodes/${appPrefix}bhamapp0?/sfbluehost-${appPrefix}bhamapp0?-instance-?/applications/sfbluehost";
dirMap[hg-app]="/opt/web/www.hostgator.com/domains/nodes/${appPrefix}hgapp0?/sfhostgator-${appPrefix}hgapp0?-instance-?/applications/sfhostgator";
dirMap[dcom-app]="/opt/web/www.domain.com/domains/nodes/${appPrefix}dcomapp0?/sfdcom-${appPrefix}dcomapp0?-instance-?/applications/sfdcom";

#echo
#echo "Dir map:"
#for K in "${!dirMap[@]}"; do echo $K --- ${dirMap[$K]}; done

if [ $# == 0 ]; then
 	usage
	exit
fi

if [ -z ${site} ]; then
        echo "${me}: No site provided!";
        exit
fi

if [ -z "${tier}" ]; then
        echo "${me}: No tier provided!";
        exit
fi

if [ -z ${theenv} ]; then
        echo "${me}: No env provided!";
        exit
fi

echo "site = ${site}; tier = ${tier}; env = ${theenv}"

jump="/usr/local/scripts/jump"

if [ "$theenv" == "prod" ]; then
        jump="/usr/local/scripts/devlogs"
fi

app=${appMap[${site}-${tier}-${theenv}]}

echo "app = ${app}"

IFS=',' read -ra appinfo <<< "${app}"
server=${appinfo[0]}
index=${appinfo[1]}
echo "server prefix = ${server}"
echo "number of servers  = ${index}"

dir=${dirMap[${site}-${tier}]}

echo "dir = ${dir}"

echo
echo "** Note that files in the deploy area are not updated until an instance is restarted! **"
echo
sleep 3

#seq -w 05

for N in $(seq -w ${index}); do
	serverOutput=$(${jump} ${server}${N} "ls -altr $dir")
	echo 
	echo "Checking ${server}${N} ${dir}..."
               while read -r line; do
                   echo "$line"
               done <<< "$serverOutput"
done