process_id=$(echo $$);
clear
echo ""
echo ""
echo ""
deploy_pum_image()
{
# Clone Container
# MODULE="CRM"
# bugid="31046243"
# NUMBER=3
# Prepare the container
echo "Destroying the existing ${MODULE}${bugid} container, if it exists \n"
lxc-ls --active
lxc-stop -k -n ${MODULE}${bugid}
lxc-destroy -n ${MODULE}${bugid}
echo "Cloning and Creating ${MODULE}${bugid} container"
lxc-clone oraclepumtemplate ${MODULE}${bugid}
echo "Preparing ${MODULE}${bugid} container"
mkdir -p /container/${MODULE}${bugid}/rootfs/pumdownload
unalias cp;cp -rf /container/templates/config_template /container/${MODULE}${bugid}/config
sed -i "s/"__HOSTNAME__"/"${MODULE}${bugid}"/g" /container/${MODULE}${bugid}/config
cat /container/${MODULE}${bugid}/config
# Start the container
lxc-start -n ${MODULE}${bugid} -d -o /container/${MODULE}${bugid}.log -l DEBUG
# Deploy PUM IMAGE
lxc-attach -e -n "${MODULE}${bugid}" -o /tmp/${MODULE}${bugid}_$$.log -- chmod +x /root/scripts/pum_deploy.sh
lxc-attach -e -n "${MODULE}${bugid}" -o /tmp/${MODULE}${bugid}_$$.log -- /root/scripts/pum_deploy.sh ${NUMBER} ${bugid}
}
echo "==========================================="
echo "Welcome to PUMMER - PUM Deployment Manager"
echo "==========================================="
read -p 'Please Enter your Oracle ID: ' uservar
read -sp 'Password: ' passvar
echo ""
echo ""
echo -n "Validating your Credentials: "
if [ $(/usr/bin/java -jar /root/pumdump/getMOSPatch.jar MOSUser=$uservar MOSPass=$passvar platform=226P download=all patch=32356044|grep "ERROR: Invalid credentials"|wc -l) -eq 1 ]; then
echo -n "Invalid Credentials"
else
echo -n " All Good"
echo ""
echo ""
#read -p 'Application Module Number? 1-FSCM, 2-HCM, 3-CRM, 4-PORTAL: ' module
while true
do
read -p "Module Number? 1-FSCM, 2-HCM, 3-CRM, 4-PORTAL, 5-ELM, 6-CampusSolutions: " NUMBER
case $NUMBER in
1) MODULE="FSCM"; break;;
2) MODULE="HCM"; break;;
3) MODULE="CRM"; break;;
4) MODULE="PORTAL"; break;;
5) MODULE="ELM"; break;;
5) MODULE="CS"; break;;
*) echo "Not a valid option" ; continue ;;
esac
done
echo ""
while true
do
read -p 'Please Enter PUM / Bug ID: ' bugid
/usr/bin/java -jar /root/pumdump/getMOSPatch.jar MOSUser=$uservar MOSPass=$passvar platform=226P patch=$bugid > /tmp/${bugid}_${process_id}.txt 2>/dev/null
if [ $(cat /tmp/${bugid}_${process_id}.txt|grep zip|wc -l) -gt 5 ];
then
break;
else
continue
fi
done
fi
cat /tmp/${bugid}_${process_id}.txt
echo "Please confirm if you want to move forward with the download of the BUG ID : $bugid and create a PUM instance ?"
read -r -p "Are you sure? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
mkdir -p /pumdownloads/${MODULE}/${bugid} && cd /pumdownloads/${MODULE}/${bugid}
if [ -f /pumdownloads/${MODULE}/${bugid}/ALL_GOOD_FILES.txt ]
then
echo ""
echo ""
echo "Good News: PUM Image ${MODULE} has been already downloaded no need to download once again. :)"
echo "Thanks, PUMMER will sent email notification along with the URL to your oracle $uservar once the PUM image is successfully deployed"
deploy_pum_image
echo ""
echo ""
else
cd /pumdownloads/${MODULE}/${bugid}
nohup /container/scripts/download_deploy_pum_image.ksh uservar passvar bugid MODULE NUMBER > /pumdownloads/download_deploy_pum_image_${bugid}_${process_id}.log 2>&1 &
# deploy_pum_image
touch /pumdownloads/${MODULE}/${bugid}/ALL_GOOD_FILES.txt
echo ""
echo ""
echo "Thanks, PUMMER will sent email notification along with the URL to your oracle $uservar once the PUM image is successfully deployed"
echo ""
echo ""
fi
else
echo "Ok, your request is cancelled!"
fi
[root@localhost scripts]# cat download_deploy_pum_image.ksh
uservar=$1
passvar=$2
bugid=$3
MODULE=$4
NUMBER=$5
deploy_pum_image()
{
# Clone Container
# MODULE="CRM"
# bugid="31046243"
# NUMBER=3
# Prepare the container
echo "Destroying the existing ${MODULE}${bugid} container, if it exists \n"
lxc-ls --active
lxc-stop -k -n ${MODULE}${bugid}
lxc-destroy -n ${MODULE}${bugid}
echo "Cloning and Creating ${MODULE}${bugid} container"
lxc-clone oraclepumtemplate ${MODULE}${bugid}
echo "Preparing ${MODULE}${bugid} container"
mkdir -p /container/${MODULE}${bugid}/rootfs/pumdownload
unalias cp;cp -rf /container/templates/config_template /container/${MODULE}${bugid}/config
sed -i "s/"__HOSTNAME__"/"${MODULE}${bugid}"/g" /container/${MODULE}${bugid}/config
cat /container/${MODULE}${bugid}/config
# Start the container
lxc-start -n ${MODULE}${bugid} -d -o /container/${MODULE}${bugid}.log -l DEBUG
# Deploy PUM IMAGE
lxc-attach -e -n "${MODULE}${bugid}" -o /tmp/${MODULE}${bugid}_$$.log -- chmod +x /root/scripts/pum_deploy.sh
lxc-attach -e -n "${MODULE}${bugid}" -o /tmp/${MODULE}${bugid}_$$.log -- /root/scripts/pum_deploy.sh ${NUMBER} ${bugid}
}
/usr/bin/java -jar /root/pumdump/getMOSPatch.jar MOSUser=$uservar MOSPass=$passvar download=all platform=226P patch=$bugid; > /pumdownloads/${bugid}_${process_id}.log
touch /pumdownloads/${MODULE}/${bugid}/ALL_GOOD_FILES.txt
deploy_pum_image