@@ -13,6 +13,7 @@ OPT_UNATTENDED=false
13
13
DEVELOPMENT=false
14
14
DEFAULT_VERSION=" latest"
15
15
DEFAULT_BRANCH=" main"
16
+ ARCH=amd64
16
17
17
18
# paths to be set later, put here to be explicit
18
19
CONTAINERD_CONFIG_PATH=" "
@@ -26,7 +27,6 @@ DEVPOOL_DATA=""
26
27
# firecracker
27
28
FIRECRACKER_VERSION=" ${FIRECRACKER:= $DEFAULT_VERSION } "
28
29
FIRECRACKER_BIN=" firecracker"
29
- FIRECRACKER_RELEASE_BIN=" firecracker"
30
30
FIRECRACKER_REPO=" weaveworks/firecracker"
31
31
32
32
# containerd
@@ -38,7 +38,6 @@ CONTAINERD_REPO="containerd/containerd"
38
38
FLINTLOCK_VERSION=" ${FLINTLOCK:= $DEFAULT_VERSION } "
39
39
FLINTLOCK_BIN=" flintlockd"
40
40
FLINTLOCK_REPO=" weaveworks/flintlock"
41
- FLINTLOCK_RELEASE_BIN=" flintlockd_amd64"
42
41
FLINTLOCKD_SERVICE_FILE=" /etc/systemd/system/flintlockd.service"
43
42
FLINTLOCKD_CONFIG_PATH=" /etc/opt/flintlockd/config.yaml"
44
43
@@ -150,7 +149,9 @@ build_release_url() {
150
149
# If/when we need to support others, we can ammend
151
150
build_containerd_release_bin_name () {
152
151
local tag=${1// v/ } # remove the 'v' from arg $1
153
- echo " containerd-$tag -linux-amd64.tar.gz"
152
+ local arch=" $2 "
153
+
154
+ echo " containerd-$tag -linux-$arch .tar.gz"
154
155
}
155
156
156
157
# Returns the desired binary download url for a repo, tag and binary
@@ -188,6 +189,19 @@ build_containerd_paths() {
188
189
# # DOER FUNCS
189
190
#
190
191
#
192
+ # Checks user input for valid architecture and sets the global value for pulling
193
+ # correct binaries.
194
+ set_arch () {
195
+ local input=" $1 "
196
+
197
+ if [[ " $input " == * " arm" * ]]; then
198
+ ARCH=arm64
199
+ elif [[ " $input " == * " amd" * ]]; then
200
+ ARCH=amd64
201
+ else
202
+ die " Unknown arch: $1 . Choose either 'arm' or 'amd'"
203
+ fi
204
+ }
191
205
# Returns the tag associated with a "latest" release
192
206
latest_release_tag () {
193
207
# shellcheck disable=SC2155
@@ -243,13 +257,21 @@ start_service() {
243
257
# Fetch and install the firecracker binary
244
258
install_firecracker () {
245
259
local tag=" $1 "
260
+
246
261
say " Installing firecracker version $tag to $INSTALL_PATH "
247
262
248
263
if [[ " $tag " == " $DEFAULT_VERSION " ]]; then
249
264
tag=$( latest_release_tag " $FIRECRACKER_REPO " )
250
265
fi
251
266
252
- url=$( build_download_url " $FIRECRACKER_REPO " " $tag " " $FIRECRACKER_RELEASE_BIN " )
267
+ bin_name=" ${FIRECRACKER_BIN} _${ARCH} "
268
+
269
+ # older firecracker macvtap releases had binaries with different names
270
+ if is_older_version " $tag " ; then
271
+ bin_name=" $FIRECRACKER_BIN "
272
+ fi
273
+
274
+ url=$( build_download_url " $FIRECRACKER_REPO " " $tag " " $bin_name " )
253
275
install_release_bin " $url " " $FIRECRACKER_BIN " || die " could not install firecracker"
254
276
255
277
" $FIRECRACKER_BIN " --version & > /dev/null
@@ -258,6 +280,13 @@ install_firecracker() {
258
280
say " Firecracker version $tag successfully installed"
259
281
}
260
282
283
+ is_older_version () {
284
+ local tag=" $1 "
285
+ local cutoff=" v1.1.1-macvtap"
286
+
287
+ [[ " $tag " == $( printf " $tag \n$cutoff " | sort -V | head -n 1) && " $tag " != " $cutoff " ]]
288
+ }
289
+
261
290
# # FLINTLOCK
262
291
#
263
292
#
@@ -285,13 +314,14 @@ do_all_flintlock() {
285
314
# Fetch and install the flintlockd binary at the specified version
286
315
install_flintlockd () {
287
316
local tag=" $1 "
317
+
288
318
say " Installing flintlockd version $tag to $INSTALL_PATH "
289
319
290
320
if [[ " $tag " == " $DEFAULT_VERSION " ]]; then
291
321
tag=$( latest_release_tag " $FLINTLOCK_REPO " )
292
322
fi
293
323
294
- url=$( build_download_url " $FLINTLOCK_REPO " " $tag " " $FLINTLOCK_RELEASE_BIN " )
324
+ url=$( build_download_url " $FLINTLOCK_REPO " " $tag " " ${FLINTLOCK_BIN} _ ${ARCH} " )
295
325
install_release_bin " $url " " $FLINTLOCK_BIN "
296
326
297
327
" $FLINTLOCK_BIN " version & > /dev/null
@@ -359,6 +389,7 @@ lookup_address() {
359
389
do_all_containerd () {
360
390
local version=" $1 "
361
391
local thinpool=" $2 "
392
+
362
393
install_containerd " $version "
363
394
write_containerd_config " $thinpool "
364
395
start_containerd_service
@@ -367,13 +398,14 @@ do_all_containerd() {
367
398
# Fetch and install the containerd binary
368
399
install_containerd () {
369
400
local tag=" $1 "
401
+
370
402
say " Installing containerd version $tag to $INSTALL_PATH "
371
403
372
404
if [[ " $version " == " $DEFAULT_VERSION " ]]; then
373
405
tag=$( latest_release_tag " $CONTAINERD_REPO " )
374
406
fi
375
407
376
- bin=$( build_containerd_release_bin_name " $tag " )
408
+ bin=$( build_containerd_release_bin_name " $tag " " $ARCH " )
377
409
url=$( build_download_url " $CONTAINERD_REPO " " $tag " " $bin " )
378
410
install_release_tar " $url " " $( dirname $INSTALL_PATH ) " || die " could not install containerd"
379
411
@@ -678,6 +710,7 @@ cmd_all() {
678
710
local fc_version=" $FIRECRACKER_VERSION "
679
711
local fl_version=" $FLINTLOCK_VERSION "
680
712
local ctrd_version=" $CONTAINERD_VERSION "
713
+ local arch=amd64
681
714
682
715
while [ $# -gt 0 ]; do
683
716
case " $1 " in
@@ -717,6 +750,10 @@ cmd_all() {
717
750
" --dev" )
718
751
DEVELOPMENT=true
719
752
;;
753
+ " --arch" )
754
+ shift
755
+ arch=" $1 "
756
+ ;;
720
757
* )
721
758
die " Unknown argument: $1 . Please use --help for help."
722
759
;;
@@ -728,6 +765,9 @@ cmd_all() {
728
765
say " The following subcommands will be performed:" \
729
766
" apt, firecracker, containerd, flintlock, direct_lvm|devpool"
730
767
768
+ set_arch " $arch "
769
+ say " Will install binarys for architecture: $ARCH "
770
+
731
771
ensure_kvm
732
772
733
773
if [[ " $skip_apt " == false ]]; then
@@ -767,6 +807,7 @@ cmd_apt() {
767
807
768
808
cmd_firecracker () {
769
809
local version=" $FIRECRACKER_VERSION "
810
+ local arch=" amd64"
770
811
771
812
while [ $# -gt 0 ]; do
772
813
case " $1 " in
@@ -778,19 +819,25 @@ cmd_firecracker() {
778
819
shift
779
820
version=" $1 "
780
821
;;
822
+ " --arch" )
823
+ shift
824
+ arch=" $1 "
825
+ ;;
781
826
* )
782
827
die " Unknown argument: $1 . Please use --help for help."
783
828
;;
784
829
esac
785
830
shift
786
831
done
787
832
833
+ set_arch " $arch "
788
834
install_firecracker " $version "
789
835
}
790
836
791
837
cmd_containerd () {
792
838
local version=" $CONTAINERD_VERSION "
793
839
local thinpool=" $DEFAULT_THINPOOL "
840
+ local arch=amd64
794
841
795
842
while [ $# -gt 0 ]; do
796
843
case " $1 " in
@@ -810,13 +857,18 @@ cmd_containerd() {
810
857
DEVELOPMENT=true
811
858
thinpool=" $DEFAULT_DEV_THINPOOL "
812
859
;;
860
+ " --arch" )
861
+ shift
862
+ arch=" $1 "
863
+ ;;
813
864
* )
814
865
die " Unknown argument: $1 . Please use --help for help."
815
866
;;
816
867
esac
817
868
shift
818
869
done
819
870
871
+ set_arch " $arch "
820
872
prepare_dirs
821
873
do_all_containerd " $version " " $thinpool "
822
874
}
@@ -827,6 +879,7 @@ cmd_flintlock() {
827
879
local parent_iface=" "
828
880
local bridge_name=" "
829
881
local insecure=false
882
+ local arch=amd64
830
883
831
884
while [ $# -gt 0 ]; do
832
885
case " $1 " in
@@ -856,13 +909,18 @@ cmd_flintlock() {
856
909
" --dev" )
857
910
DEVELOPMENT=true
858
911
;;
912
+ " --arch" )
913
+ shift
914
+ arch=" $1 "
915
+ ;;
859
916
* )
860
917
die " Unknown argument: $1 . Please use --help for help."
861
918
;;
862
919
esac
863
920
shift
864
921
done
865
922
923
+ set_arch " $arch "
866
924
prepare_dirs
867
925
do_all_flintlock " $version " " $address " " $parent_iface " " $bridge_name " " $insecure "
868
926
}
0 commit comments