Download and upload aem packages using shell script

Using shell script you can download packages from source instance and upload into destination instance

# packages.txt 
service pack: aem-service-pkg-6.5.4.zip 
AEM forms: AEM-Forms-6.5.4.0-OSX-6.0.138.zip
#!/bin/bash
FILE="/home/prahlad/packages.txt"
TEMP="/home/prahlad/temp"
crx_packmgr_path="/etc/packages/adobe/cq650/servicepack"
source="localhost:4502"
dest="localhost:4503"
# create temp folder.
mkdir $TEMP
# start loop to read file and execute command for each line .
while IFS= read -r line
do
package_name=`echo "$line" | awk '{split( $0,array, ":"); print array[2]}'`
# download packages from source server.
echo $source $crx_packmgr_path $package_name $TEMP | awk '{print("curl -u admin:admin http://"$1 "" $2 "/" $3 " > " $4 "/" $3)}' | sh
wait $!
# upload and install package into destination server.
echo $package_name $dest $TEMP | awk '{print("curl -u admin:admin -F file=@" $3 "/" $1 " -F name="$1" -F force=true -F install=true http://"$2"/crx/packmgr/service.jsp")}' | sh
wait $!
done <"$FILE"