Skip to content

Instantly share code, notes, and snippets.

@fiskr
Created March 23, 2015 13:35
Show Gist options
  • Save fiskr/ef886a62eb3135cc13d5 to your computer and use it in GitHub Desktop.
Save fiskr/ef886a62eb3135cc13d5 to your computer and use it in GitHub Desktop.
Deletes, uploads, and then installs a package. You have to specify the name, it does the rest with CURL.
#!/bin/bash
# Install zip package through curl
groupName="Brandon"
packageName="20150319_show.zip"
package="./packages/$packageName"
username="162084"
#get password from user
echo -n "Enter password. >"
read -s answer
pass="$answer"
function specifyEnvironment() {
#check to see if input was provided
if [ $# -eq 0 ]
then
echo "No arguments supplied."
else
env=$1
fi
if [[ $env =~ dev3 ]]
then
echo "Environment is dev3: $env"
#dev hostname
hostname="author.hgtv-dev3.sni.hgtv.com"
else
if [[ $env =~ qa3 ]]
then
echo "Environment is QA3: $env"
#qa3 hostname
hostname="author.hgtv-qa3.sni.hgtv.com"
else
if [[ $env =~ prod ]]
then
echo "Environment is production: $env"
#production hostname
hostname="author.hgtv-prod2.sni.hgtv.com"
else
if [[ $env =~ local ]]
then
echo "Environment is local: $env"
#local hostname
hostname="localhost:4502"
username="admin"
pass="admin"
else
#echo "Environment is neither dev nor prod, please specify."
read -p "Environment is neither dev nor prod, please specify. > " answer
specifyEnvironment $answer
fi
fi
fi
fi
}
specifyEnvironment
echo "Deleting package $packageName: "
echo "$(curl -w 'Response Code: %{http_code} | Connect: %{time_connect} | TTFB: %{time_starttransfer} | Total time: %{time_total} \n' -o /dev/null -u $username:$pass -F package=@$package http://$hostname/crx/packmgr/service/.json/?cmd=delete)"
echo "Uploading package $packageName: "
echo "$(curl -w 'Response Code: %{http_code} | Connect: %{time_connect} | TTFB: %{time_starttransfer} | Total time: %{time_total} \n' -o /dev/null -u $username:$pass -F package=@$package http://$hostname/crx/packmgr/service/.json/?cmd=upload)"
echo "Installing Package $packageName:"
echo "$(curl --connect-timeout 3600 -u $username:$pass -X POST http://$hostname/crx/packmgr/service/.json/etc/packages/$groupName/$packageName?cmd=install)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment