## This Instillation File Assumes the Following:
# 1.  You have Spun up a Linux Server with appropriate Disks allocated and all Disks are Mounted and persistent across Reboots
# 2.  You have identified what partition you wish Data/Installation for AppD.
# 3.  You are running this script from the Root of the Desired Installation/Data Partition
##Step 1 Create Directory for AppD to live in
#!/bin/bash
_now=$(date +"%m_%d_%Y")
_file="/AppD/$_now.log"
echo "Starting logging to "$_file" ..." > $_file
cp response.varfile AppD
cd /AppD
wget https://e3c31c64b1ee4df697a9-044f20cf8d1b96386385a874a2d50313.ssl.cf2.rackcdn.com/controller_64bit_linux.sh
# Install Dependency Libaio package
yum -y install libaio >> $_file
#Make Installer eXecutable
chmontroller_64bit_linux.sh >> $_file
#Execute Installation using the latest installation Media downloaded from Above in Step 2 - Silently
./controller_64bit_linux.sh -q -varfile response.varfile >> $_file
##Update IPTables to Allow Communication for AppDynamics
iptables -A INPUT -p tcp --dport 8090 -j ACCEPT >> $_file
iptables -A INPUT -p tcp --dport 4848 -j ACCEPT >> $_file
iptables -A INPUT -p tcp --dport 8181 -j ACCEPT >> $_file
iptables save
#Steps to Add License file to controller installation and restart all controller services to ensure it reads the updated license.
cd Controller/
wget https://e3c31c64b1ee4df697a9-044f20cf8d1b96386385a874a2d50313.ssl.cf2.rackcdn.com/license.lic
cd bin/
./controller.sh stop-appserver>> $_file
./controller.sh stop-db>> $_file
./controller.sh start-db>> $_file
./controller.sh start-appserver>> $_file
echo "The Automated Installation of AppD Has Completed!" >> $_file

