Skip to content

Update install.sh script and the puppet_agent and facts submodules #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ ID="$(munge_name "$ID")"
family="$(munge_name "$family")"

#!/usr/bin/env bash

set -e

# Install puppet-agent as a task
#
# From https://github.com/petems/puppet-install-shell/blob/master/install_puppet_5_agent.sh
Expand Down Expand Up @@ -301,6 +304,11 @@ assert_unmodified_apt_config() {
fi
}

# Check whether apt-helper is available
exists_apt_helper() {
test -x /usr/lib/apt/apt-helper
}

# Check whether python3 and urllib.request are available
exists_python3_urllib() {
python3 -c 'import urllib.request' >/dev/null 2>&1
Expand Down Expand Up @@ -662,6 +670,27 @@ do_fetch() {
return 0
}

do_apt_helper() {
info "Trying apt-helper..."
run_cmd "/usr/lib/apt/apt-helper download-file '$1' '$2'" 2>$tmp_stderr
rc=$?

# check for 404
grep "E: Failed to fetch .* 404 " $tmp_stderr 2>&1 >/dev/null
if test $? -eq 0; then
critical "ERROR 404"
unable_to_retrieve_package
fi

# check for bad return status or empty output
if test $rc -ne 0 && test ! -s "$2" ; then
capture_tmp_stderr "apthelper"
return 1
fi

return 0
}

do_python3_urllib() {
info "Trying python3 (urllib.request)..."
run_cmd "python3 -c 'import urllib.request ; urllib.request.urlretrieve(\"$1\", \"$2\")'" 2>$tmp_stderr
Expand Down Expand Up @@ -755,7 +784,11 @@ do_download() {
do_python3_urllib $1 $2 && return 0
fi

critical "Cannot download package as none of wget/curl/fetch/perl-LWP-Simple/perl-File-Fetch/python3 is found"
if exists_apt_helper; then
do_apt_helper $1 $2 && return 0
fi

critical "Cannot download package as none of wget/curl/fetch/perl-LWP-Simple/perl-File-Fetch/python3/apt-helper is found"
unable_to_retrieve_package
}

Expand Down
2 changes: 1 addition & 1 deletion modules/facts
Submodule facts updated 2 files
+4 −0 CHANGELOG.md
+2 −2 metadata.json