@@ -26,6 +26,14 @@ warn () {
2626 log " WARN: ${1} "
2727}
2828
29+ url_parameters () {
30+ if [[ " $version " =~ ^([0-9]+)\. ([0-9]+)\. ([0-9]+)\. ([0-9]+)\. g([a-f0-9]+)$ ]]; then
31+ echo " &dev=true"
32+ else
33+ echo " "
34+ fi
35+ }
36+
2937critical () {
3038 log " CRIT: ${1} "
3139}
162170if [ -n " $PT_mac_source " ]; then
163171 mac_source=$PT_mac_source
164172else
165- if [ " $nightly " = true ]; then
166- mac_source=' http://nightlies.puppet.com/downloads'
167- else
168- mac_source=' http://downloads.puppet.com'
173+ if [[ " $PT_collection " =~ core ]]; then
174+ if [ -z " $password " ]; then
175+ echo " A password parameter is required to install with puppetcore"
176+ exit 1
177+ fi
178+ mac_source=' https://artifacts-puppetcore.puppet.com/v1/download'
179+ else
180+ if [ " $nightly " = true ]; then
181+ mac_source=' http://nightlies.puppet.com/downloads'
182+ else
183+ mac_source=' http://downloads.puppet.com'
184+ fi
169185 fi
170186fi
171187
@@ -421,7 +437,11 @@ do_wget() {
421437# do_curl URL FILENAME
422438do_curl () {
423439 info " Trying curl..."
424- run_cmd " curl -1 -sL -D $tmp_stderr '$1 ' > '$2 '"
440+ if [[ -n " $3 " && -n " $4 " ]]; then
441+ run_cmd " curl -1 -sL -u '$3 :$4 ' -D $tmp_stderr '$1 ' > '$2 '"
442+ else
443+ run_cmd " curl -1 -sL -D $tmp_stderr '$1 ' > '$2 '"
444+ fi
425445 rc=$?
426446
427447 # check for 404
@@ -431,6 +451,12 @@ do_curl() {
431451 unable_to_retrieve_package
432452 fi
433453
454+ grep " HTTP/2 401" $tmp_stderr 2>&1 > /dev/null
455+ if test $? -eq 0; then
456+ critical " ERROR 401: Unauthorized access"
457+ unable_to_retrieve_package
458+ fi
459+
434460 # check for bad return status or empty output
435461 if test $rc -ne 0 || test ! -s " $2 " ; then
436462 capture_tmp_stderr " curl"
@@ -557,7 +583,11 @@ do_download() {
557583 fi
558584
559585 if exists curl; then
560- do_curl $1 $2 && return 0
586+ if [[ " $collection " =~ core ]]; then
587+ do_curl $1 $2 " $username " " $password " && return 0
588+ else
589+ do_curl $1 $2 && return 0
590+ fi
561591 fi
562592
563593 if exists fetch; then
@@ -810,19 +840,29 @@ case $platform in
810840 download_url=" ${apt_source} /${filename} "
811841 ;;
812842 " mac_os_x" )
813- info " Mac platform! Lets get you a DMG..."
814- filetype=" dmg"
843+ arch=" x86_64"
844+ if [[ $( uname -p) == " arm" ]]; then
845+ arch=" arm64"
846+ fi
815847 if test " $version " = " latest" ; then
816848 filename=" puppet-agent-latest.dmg"
817849 else
818850 filename=" puppet-agent-${version} -1.osx${platform_version} .dmg"
819851 fi
852+ info " Mac platform! Lets get you a DMG...!!"
853+ if [[ " $collection " =~ core ]]; then
854+ if [ -z " $password " ]; then
855+ echo " A password parameter is required to install"
856+ exit 1
857+ fi
820858
821- arch=" x86_64"
822- if [[ $( uname -p) == " arm" ]]; then
823- arch=" arm64"
859+ # Call the url_parameters function to append to the download_url
860+ download_url=" ${mac_source} /?version=${version} &os_name=osx&os_version=${platform_version} &os_arch=${arch} &fips=false$( url_parameters) "
861+ else
862+ download_url=" ${mac_source} /mac/${collection} /${platform_version} /${arch} /${filename} "
824863 fi
825- download_url=" ${mac_source} /mac/${collection} /${platform_version} /${arch} /${filename} "
864+ filetype=" dmg"
865+
826866 ;;
827867 * )
828868 critical " Sorry $platform is not supported yet!"
0 commit comments