162162if [ -n " $PT_mac_source " ]; then
163163 mac_source=$PT_mac_source
164164else
165- if [ " $nightly " = true ]; then
166- mac_source=' http://nightlies.puppet.com/downloads'
167- else
168- mac_source=' http://downloads.puppet.com'
165+ if [[ " $PT_collection " =~ core ]]; then
166+ if [ -z " $password " ]; then
167+ echo " A password parameter is required to install with puppetcore"
168+ exit 1
169+ fi
170+ mac_source=' https://artifacts-puppetcore.puppet.com/v1/download'
171+ else
172+ if [ " $nightly " = true ]; then
173+ mac_source=' http://nightlies.puppet.com/downloads'
174+ else
175+ mac_source=' http://downloads.puppet.com'
176+ fi
169177 fi
170178fi
171179
@@ -421,7 +429,11 @@ do_wget() {
421429# do_curl URL FILENAME
422430do_curl () {
423431 info " Trying curl..."
424- run_cmd " curl -1 -sL -D $tmp_stderr '$1 ' > '$2 '"
432+ if [[ -n " $3 " && -n " $4 " ]]; then
433+ run_cmd " curl -1 -sL -u '$3 :$4 ' -D $tmp_stderr '$1 ' > '$2 '"
434+ else
435+ run_cmd " curl -1 -sL -D $tmp_stderr '$1 ' > '$2 '"
436+ fi
425437 rc=$?
426438
427439 # check for 404
@@ -431,6 +443,12 @@ do_curl() {
431443 unable_to_retrieve_package
432444 fi
433445
446+ grep " HTTP/2 401" $tmp_stderr 2>&1 > /dev/null
447+ if test $? -eq 0; then
448+ critical " ERROR 401: Unauthorized access"
449+ unable_to_retrieve_package
450+ fi
451+
434452 # check for bad return status or empty output
435453 if test $rc -ne 0 || test ! -s " $2 " ; then
436454 capture_tmp_stderr " curl"
@@ -557,7 +575,11 @@ do_download() {
557575 fi
558576
559577 if exists curl; then
560- do_curl $1 $2 && return 0
578+ if [[ " $collection " =~ core ]]; then
579+ do_curl $1 $2 " $username " " $password " && return 0
580+ else
581+ do_curl $1 $2 && return 0
582+ fi
561583 fi
562584
563585 if exists fetch; then
@@ -810,19 +832,31 @@ case $platform in
810832 download_url=" ${apt_source} /${filename} "
811833 ;;
812834 " mac_os_x" )
813- info " Mac platform! Lets get you a DMG..."
814- filetype=" dmg"
835+ arch=" x86_64"
836+ if [[ $( uname -p) == " arm" ]]; then
837+ arch=" arm64"
838+ fi
815839 if test " $version " = " latest" ; then
816840 filename=" puppet-agent-latest.dmg"
817841 else
818842 filename=" puppet-agent-${version} -1.osx${platform_version} .dmg"
819843 fi
820-
821- arch=" x86_64"
822- if [[ $( uname -p) == " arm" ]]; then
823- arch=" arm64"
844+ info " Mac platform! Lets get you a DMG...!!"
845+ if [[ " $collection " =~ core ]]; then
846+ if [ -z " $password " ]; then
847+ echo " A password parameter is required to install"
848+ exit 1
849+ fi
850+ if [[ " $version " =~ ^([0-9]+)\. ([0-9]+)\. ([0-9]+)\. ([0-9]+)\. g([a-f0-9]+)$ ]]; then
851+ download_url=" ${mac_source} /?version=${version} &os_name=osx&os_version=${platform_version} &os_arch=${arch} &fips=false&dev=true"
852+ else
853+ download_url=" ${mac_source} /?version=${version} &os_name=osx&os_version=${platform_version} &os_arch=${arch} &fips=false"
854+ fi
855+ else
856+ download_url=" ${mac_source} /mac/${collection} /${platform_version} /${arch} /${filename} "
824857 fi
825- download_url=" ${mac_source} /mac/${collection} /${platform_version} /${arch} /${filename} "
858+ filetype=" dmg"
859+
826860 ;;
827861 * )
828862 critical " Sorry $platform is not supported yet!"
0 commit comments