1111set -o errexit
1212set -o pipefail
1313if [[ ${OS_DEBUG:- false} == " true" ]]; then
14- set -o xtrace
14+ set -o xtrace
1515fi
1616
1717PROVIDER=${PROVIDER:- virtualbox}
1818msg=" "
1919
2020function _get_box_current_version {
21- version=" "
22- attempt_counter=0
23- max_attempts=5
24- name=" $1 "
21+ version=" "
22+ attempt_counter=0
23+ max_attempts=5
24+ name=" $1 "
2525
26- if [ -f ./ci/pinned_vagrant_boxes.txt ] && grep -q " ^${name} .*$PROVIDER " ./ci/pinned_vagrant_boxes.txt; then
27- version=$( grep " ^${name} .*$PROVIDER " ./ci/pinned_vagrant_boxes.txt | awk ' { print $2 }' )
28- else
29- until [ " $version " ]; do
30- metadata=" $( curl -s " https://app.vagrantup.com/api/v1/box/$name " ) "
31- if [ " $metadata " ]; then
32- version=" $( echo " $metadata " | python -c ' import json,sys;print(json.load(sys.stdin)["current_version"]["version"])' ) "
33- break
34- elif [ ${attempt_counter} -eq ${max_attempts} ]; then
35- echo " Max attempts reached"
36- exit 1
37- fi
38- attempt_counter=$(( attempt_counter + 1 ))
39- sleep $(( attempt_counter * 2 ))
40- done
41- fi
26+ if [ -f ./ci/pinned_vagrant_boxes.txt ] && grep -q " ^${name} .*$PROVIDER " ./ci/pinned_vagrant_boxes.txt; then
27+ version=$( grep " ^${name} .*$PROVIDER " ./ci/pinned_vagrant_boxes.txt | awk ' { print $2 }' )
28+ else
29+ until [ " $version " ]; do
30+ metadata=" $( curl -s " https://app.vagrantup.com/api/v1/box/$name " ) "
31+ if [ " $metadata " ]; then
32+ version=" $( echo " $metadata " | python -c ' import json,sys;print(json.load(sys.stdin)["current_version"]["version"])' ) "
33+ break
34+ elif [ ${attempt_counter} -eq ${max_attempts} ]; then
35+ echo " Max attempts reached"
36+ exit 1
37+ fi
38+ attempt_counter=$(( attempt_counter + 1 ))
39+ sleep $(( attempt_counter * 2 ))
40+ done
41+ fi
4242
43- echo " ${version#* v} "
43+ echo " ${version#* v} "
4444}
4545
4646function _vagrant_pull {
47- local alias=" $1 "
48- local name=" $2 "
49- local project_id=" $3 "
50- local family=" $4 "
51- local vb_controller=" ${5:- IDE Controller} "
47+ local alias=" $1 "
48+ local name=" $2 "
49+ local project_id=" $3 "
50+ local family=" $4 "
51+ local vb_controller=" ${5:- IDE Controller} "
5252
53- version=$( _get_box_current_version " $name " )
53+ version=$( _get_box_current_version " $name " )
5454
55- if [ " $( curl " https://app.vagrantup.com/${name%/* } /boxes/${name#*/ } /versions/$version /providers/$PROVIDER .box" -o /dev/null -w ' %{http_code}\n' -s) " == " 302" ] && [ " $( vagrant box list | grep -c " $name .*$PROVIDER , $version " ) " != " 1" ]; then
56- vagrant box remove --provider " $PROVIDER " --all --force " $name " || :
57- vagrant box add --provider " $PROVIDER " --box-version " $version " " $name "
58- elif [ " $( vagrant box list | grep -c " $name .*$PROVIDER , $version " ) " == " 1" ]; then
59- echo " $name ($version , $PROVIDER ) box is already present in the host"
60- else
61- msg+=" $name ($version , $PROVIDER ) box doesn't exist\n"
62- return
63- fi
64- # editorconfig-checker-disable
65- # prettier-ignore-start
66- cat << EOT >>.distros_supported.yml
55+ if [ " $( curl " https://app.vagrantup.com/${name%/* } /boxes/${name#*/ } /versions/$version /providers/$PROVIDER .box" -o /dev/null -w ' %{http_code}\n' -s) " == " 302" ] && [ " $( vagrant box list | grep -c " $name .*$PROVIDER , $version " ) " != " 1" ]; then
56+ vagrant box remove --provider " $PROVIDER " --all --force " $name " || :
57+ vagrant box add --provider " $PROVIDER " --box-version " $version " " $name "
58+ elif [ " $( vagrant box list | grep -c " $name .*$PROVIDER , $version " ) " == " 1" ]; then
59+ echo " $name ($version , $PROVIDER ) box is already present in the host"
60+ else
61+ msg+=" $name ($version , $PROVIDER ) box doesn't exist\n"
62+ return
63+ fi
64+ # editorconfig-checker-disable
65+ # prettier-ignore-start
66+ cat << EOT >>.distros_supported.yml
6767$alias :
6868 name: $name
6969 vb_controller: $vb_controller
7070 version: "$version "
7171 project_id: $project_id
7272 family: $family
7373EOT
74- # prettier-ignore-end
75- # editorconfig-checker-enable
74+ # prettier-ignore-end
75+ # editorconfig-checker-enable
7676}
7777
7878if ! command -v vagrant > /dev/null; then
79- # NOTE: Shorten link -> https://raw.githubusercontent.com/electrocucaracha/pkg-mgr_scripts/master/install.sh
80- curl -fsSL http://bit.ly/install_pkg | PKG=vagrant bash
79+ # NOTE: Shorten link -> https://raw.githubusercontent.com/electrocucaracha/pkg-mgr_scripts/master/install.sh
80+ curl -fsSL http://bit.ly/install_pkg | PKG=vagrant bash
8181fi
8282
8383cat << EOT >.distros_supported.yml
@@ -98,8 +98,8 @@ _vagrant_pull "debian_11" "debian/bullseye64" "debian-cloud" "debian-11" "SATA C
9898_vagrant_pull " debian_12" " debian/bookworm64" " debian-cloud" " debian-12" " SATA Controller"
9999
100100if [ " $msg " ]; then
101- echo -e " $msg "
102- rm .distros_supported.yml
101+ echo -e " $msg "
102+ rm .distros_supported.yml
103103else
104- mv .distros_supported.yml distros_supported.yml
104+ mv .distros_supported.yml distros_supported.yml
105105fi
0 commit comments