@@ -12,58 +12,8 @@ yum_source=${PT_yum_source:-'https://yum.overlookinfratech.com'}
1212# shellcheck disable=SC2154
1313apt_source=${PT_apt_source:- ' https://apt.overlookinfratech.com' }
1414
15- tempdir=$( mktemp -d)
16- trap ' rm -rf $tempdir' EXIT
17-
18- log () {
19- local _level=" $1 "
20- shift
21-
22- local ts
23- ts=$( date ' +%Y-%m-%dT%H:%M:%S' )
24-
25- echo " ${ts} [${_level} ]: $* "
26- }
27-
28- info () {
29- log ' INFO' " $* "
30- }
31-
32- err () {
33- log ' ERROR' " $* "
34- }
35-
36- fail () {
37- err " $* "
38- exit 1
39- }
40-
41- # Log the value of a variable.
42- assigned () {
43- local _var=" $1 "
44-
45- info " Assigned ${_var} =${! _var} "
46- }
47-
48- # Check if a command exists.
49- exists () {
50- command -v " $1 " > /dev/null 2>&1
51- }
52-
53- # Set platform and full_version variables by reaching out to the
54- # puppetlabs-facts bash task as an executable.
55- set_platform () {
56- # PT__installdir is set by Bolt.
57- local facts=" ${installdir} /facts/tasks/bash.sh"
58- if [ -e " ${facts} " ]; then
59- platform=$( bash " ${facts} " platform)
60- assigned ' platform'
61- full_version=$( bash " ${facts} " release)
62- assigned ' full_version'
63- else
64- fail " Unable to find the puppetlabs-facts bash task to determine platform at '${facts} '."
65- fi
66- }
15+ # shellcheck source=files/common.sh
16+ source " ${installdir} /openvox_bootstrap/files/common.sh"
6717
6818# Based on platform family set:
6919# repository - the package repository to download from
@@ -81,59 +31,15 @@ set_repository() {
8131 assigned ' repository'
8232}
8333
84- # Based on platform family set:
85- # package_type - rpm or deb or...
86- # package_file_suffix - the file extension for the release package name
87- set_package_type () {
88- local _family=" $1 "
89-
90- case $_family in
91- amazon|fedora|el|sles)
92- package_type=' rpm'
93- package_file_suffix=' noarch.rpm'
94- ;;
95- debian|ubuntu)
96- package_type=' deb'
97- package_file_suffix=' deb'
98- ;;
99- esac
100- assigned ' package_type'
101- assigned ' package_file_suffix'
102- }
103-
10434# Based on the platform set:
10535# package_name - the name of the release package
10636# package_url - the url to download the release package
10737set_collection_url () {
10838 local _platform=" $1 "
10939
110- case $_platform in
111- Amazon)
112- family=' amazon'
113- ;;
114- RHEL|RedHat|CentOS|Scientific|OracleLinux|Rocky|AlmaLinux)
115- family=' el'
116- ;;
117- Fedora)
118- family=' fedora'
119- ;;
120- SLES|Suse)
121- family=' sles'
122- ;;
123- Debian)
124- family=' debian'
125- ;;
126- Ubuntu)
127- family=' ubuntu'
128- ;;
129- * )
130- fail " Unhandled platform: '${platform} '"
131- ;;
132- esac
133- assigned ' family'
134-
135- set_repository $family
136- set_package_type $family
40+ set_family " ${_platform} "
41+ set_repository " ${family} "
42+ set_package_type " ${family} "
13743
13844 if [ " ${package_type} " == ' rpm' ]; then
13945 major_version=${full_version%% .* }
@@ -148,36 +54,6 @@ set_collection_url() {
14854 assigned ' package_url'
14955}
15056
151- exec_and_capture () {
152- local _cmd=" $* "
153-
154- info " Executing: ${_cmd} "
155- local _result
156-
157- set +e
158- result=$( ${_cmd} 2>&1 )
159- local _status=$?
160- set -e
161-
162- echo " ${result} "
163- info " Status: ${_status} "
164- return $_status
165- }
166-
167- # Download the given url to the given local file path.
168- download () {
169- local _url=" $1 "
170- local _file=" $2 "
171-
172- if exists ' wget' ; then
173- exec_and_capture wget -O " ${_file} " " ${_url} "
174- elif exists ' curl' ; then
175- exec_and_capture curl -sSL -o " ${_file} " " ${_url} "
176- else
177- fail " Unable to download ${_url} . Neither wget nor curl are installed."
178- fi
179- }
180-
18157# Download the release package to the tempdir.
18258# Sets:
18359# local_release_package - the path to the downloaded release package.
0 commit comments