@@ -123,50 +123,39 @@ else
123123 collection=' puppet'
124124fi
125125
126+ if [[ " $collection " == " puppetcore" * && -z " $password " ]]; then
127+ echo " A password parameter is required to install from puppetcore"
128+ exit 1
129+ fi
130+
126131if [ -n " $PT_yum_source " ]; then
127132 yum_source=$PT_yum_source
133+ elif [[ " $collection " == " puppetcore" * ]]; then
134+ yum_source=' https://yum-puppetcore.puppet.com/public'
135+ elif [ " $nightly " = true ]; then
136+ yum_source=' http://nightlies.puppet.com/yum'
128137else
129- if [[ " $collection " == " puppetcore" * ]]; then
130- yum_source=' https://yum-puppetcore.puppet.com/public'
131- if [ -z " $password " ]; then
132- echo " A password parameter is required to install from ${yum_source} "
133- exit 1
134- fi
135- else
136- if [ " $nightly " = true ]; then
137- yum_source=' http://nightlies.puppet.com/yum'
138- else
139- yum_source=' http://yum.puppet.com'
140- fi
141- fi
138+ yum_source=' http://yum.puppet.com'
142139fi
143140
144141if [ -n " $PT_apt_source " ]; then
145142 apt_source=$PT_apt_source
143+ elif [[ " $collection " == " puppetcore" * ]]; then
144+ apt_source=' https://apt-puppetcore.puppet.com/public'
145+ elif [ " $nightly " = true ]; then
146+ apt_source=' http://nightlies.puppet.com/apt'
146147else
147- if [[ " $collection " == " puppetcore" * ]]; then
148- apt_source=' https://apt-puppetcore.puppet.com/public'
149- if [ -z " $password " ]; then
150- echo " A password parameter is required to install from ${apt_source} "
151- exit 1
152- fi
153- else
154- if [ " $nightly " = true ]; then
155- apt_source=' http://nightlies.puppet.com/apt'
156- else
157- apt_source=' http://apt.puppet.com'
158- fi
159- fi
148+ apt_source=' http://apt.puppet.com'
160149fi
161150
162151if [ -n " $PT_mac_source " ]; then
163152 mac_source=$PT_mac_source
153+ elif [[ " $collection " == " puppetcore" * ]]; then
154+ mac_source=' https://artifacts-puppetcore.puppet.com/v1/download'
155+ elif [ " $nightly " = true ]; then
156+ mac_source=' http://nightlies.puppet.com/downloads'
164157else
165- if [ " $nightly " = true ]; then
166- mac_source=' http://nightlies.puppet.com/downloads'
167- else
168- mac_source=' http://downloads.puppet.com'
169- fi
158+ mac_source=' http://downloads.puppet.com'
170159fi
171160
172161if [ -n " $PT_retry " ]; then
@@ -396,10 +385,14 @@ run_cmd() {
396385 return $rc
397386}
398387
399- # do_wget URL FILENAME
388+ # do_wget URL FILENAME [USERNAME] [PASSWORD]
400389do_wget () {
401390 info " Trying wget..."
402- run_cmd " wget -O '$2 ' '$1 ' 2>$tmp_stderr "
391+ if [[ -n " $3 " && -n " $4 " ]]; then
392+ run_cmd " wget -O '$2 ' --user '$3 ' --password '$4 ' '$1 ' 2>$tmp_stderr "
393+ else
394+ run_cmd " wget -O '$2 ' '$1 ' 2>$tmp_stderr "
395+ fi
403396 rc=$?
404397
405398 # check for 404
@@ -409,6 +402,13 @@ do_wget() {
409402 unable_to_retrieve_package
410403 fi
411404
405+ # check for 401
406+ grep " ERROR 401" $tmp_stderr 2>&1 > /dev/null
407+ if test $? -eq 0; then
408+ critical " ERROR 401"
409+ unable_to_retrieve_package
410+ fi
411+
412412 # check for bad return status or empty output
413413 if test $rc -ne 0 || test ! -s " $2 " ; then
414414 capture_tmp_stderr " wget"
@@ -418,19 +418,30 @@ do_wget() {
418418 return 0
419419}
420420
421- # do_curl URL FILENAME
421+ # do_curl URL FILENAME [USERNAME] [PASSWORD]
422422do_curl () {
423423 info " Trying curl..."
424- run_cmd " curl -1 -sL -D $tmp_stderr '$1 ' > '$2 '"
424+ if [[ -n " $3 " && -n " $4 " ]]; then
425+ run_cmd " curl -1 -sL -u'$3 :$4 ' -D $tmp_stderr '$1 ' > '$2 '"
426+ else
427+ run_cmd " curl -1 -sL -D $tmp_stderr '$1 ' > '$2 '"
428+ fi
425429 rc=$?
426430
427431 # check for 404
428- grep " 404 Not Found " $tmp_stderr 2>&1 > /dev/null
432+ grep " HTTP/.* 404 " $tmp_stderr 2>&1 > /dev/null
429433 if test $? -eq 0; then
430434 critical " ERROR 404"
431435 unable_to_retrieve_package
432436 fi
433437
438+ # check for 401
439+ grep " HTTP/.* 401" $tmp_stderr 2>&1 > /dev/null
440+ if test $? -eq 0; then
441+ critical " ERROR 401"
442+ unable_to_retrieve_package
443+ fi
444+
434445 # check for bad return status or empty output
435446 if test $rc -ne 0 || test ! -s " $2 " ; then
436447 capture_tmp_stderr " curl"
@@ -544,7 +555,7 @@ do_perl_ff() {
544555 return 1
545556}
546557
547- # do_download URL FILENAME
558+ # do_download URL FILENAME [USERNAME] [PASSWORD]
548559do_download () {
549560 info " Downloading $1 "
550561 info " to file $2 "
@@ -553,11 +564,11 @@ do_download() {
553564 # perl, in particular may be present but LWP::Simple may not be installed
554565
555566 if exists wget; then
556- do_wget $1 $2 && return 0
567+ do_wget $1 $2 $3 $4 && return 0
557568 fi
558569
559570 if exists curl; then
560- do_curl $1 $2 && return 0
571+ do_curl $1 $2 $3 $4 && return 0
561572 fi
562573
563574 if exists fetch; then
@@ -822,7 +833,16 @@ case $platform in
822833 if [[ $( uname -p) == " arm" ]]; then
823834 arch=" arm64"
824835 fi
825- download_url=" ${mac_source} /mac/${collection} /${platform_version} /${arch} /${filename} "
836+ if [[ " $collection " =~ " puppetcore" ]]; then
837+ dots=$( echo " ${version} " | grep -o ' \.' | wc -l)
838+ if (( dots >= 3 )) ; then
839+ download_url=" ${mac_source} ?version=${version} &os_name=osx&os_version=${platform_version} &os_arch=${arch} &dev=true"
840+ else
841+ download_url=" ${mac_source} ?version=${version} &os_name=osx&os_version=${platform_version} &os_arch=${arch} "
842+ fi
843+ else
844+ download_url=" ${mac_source} /mac/${collection} /${platform_version} /${arch} /${filename} "
845+ fi
826846 ;;
827847 * )
828848 critical " Sorry $platform is not supported yet!"
837857if [[ $PT__noop != true ]]; then
838858 download_filename=" ${tmp_dir} /${filename} "
839859
840- do_download " $download_url " " $download_filename "
860+ do_download " $download_url " " $download_filename " " $username " " $password "
841861
842862 install_file $filetype " $download_filename "
843863
0 commit comments