forked from lavabit/robox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
robox.sh
executable file
·2411 lines (1958 loc) · 111 KB
/
robox.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Name: robox.sh
# Author: Ladar Levison
#
# Description: Used to build various virtual machines using packer.
# Handle self referencing, sourcing etc.
if [[ $0 != $BASH_SOURCE ]]; then
export CMD=$BASH_SOURCE
else
export CMD=$0
fi
# Ensure a consistent working directory so relative paths work.
pushd `dirname $CMD` > /dev/null
BASE=`pwd -P`
popd > /dev/null
cd $BASE
# Credentials and tokens.
if [ ! -f $BASE/.credentialsrc ]; then
cat << EOF > $BASE/.credentialsrc
#!/bin/bash
# Overrides the repo version string with a default value.
[ ! -n "\$VERSION" ] && VERSION="1.0.0"
# Set the following to override default values.
# [ ! -n "\$GOMAXPROCS" ] && export GOMAXPROCS="2"
# [ ! -n "\$PACKER_ON_ERROR" ] && export PACKER_ON_ERROR="cleanup"
# [ ! -n "\$PACKER_MAX_PROCS" ] && export PACKER_MAX_PROCS="2"
[ ! -n "\$PACKER_CACHE_DIR" ] && export PACKER_CACHE_DIR="$BASE/packer_cache/"
#
# [ ! -n "\$QUAY_USER" ] && export QUAY_USER="LOGIN"
# [ ! -n "\$QUAY_PASSWORD" ] && export QUAY_PASSWORD="PASSWORD"
# [ ! -n "\$DOCKER_USER" ] && export DOCKER_USER="LOGIN"
# [ ! -n "\$DOCKER_PASSWORD" ] && export DOCKER_PASSWORD="PASSWORD"
# [ ! -n "\$VAGRANT_CLOUD_TOKEN" ] && export VAGRANT_CLOUD_TOKEN="TOKEN"
# Update the following if using provider.sh to install VMWare Workstation.
# [ ! -n "\$VMWARE_WORKSTATION" ] && export VMWARE_WORKSTATION="SERIAL"
EOF
tput setaf 1; printf "\n\nCredentials file was missing. Stub file created.\n\n\n"; tput sgr0
sleep 5
fi
# Import the credentials.
source $BASE/.credentialsrc
# Version Information
[ ! -n "$VERSION" ] && export VERSION="4.2.18"
export AGENT="Vagrant/2.3.4 (+https://www.vagrantup.com; ruby2.7.6)"
# Limit the number of cpus packer will use and control how errors are handled.
[ ! -n "$GOMAXPROCS" ] && export GOMAXPROCS="2"
[ ! -n "$PACKER_ON_ERROR" ] && export PACKER_ON_ERROR="cleanup"
[ ! -n "$PACKER_MAX_PROCS" ] && export PACKER_MAX_PROCS="1"
[ ! -n "$PACKER_CACHE_DIR" ] && export PACKER_CACHE_DIR="$BASE/packer_cache/"
# The provider platforms.
ROBOX_PROVIDERS="docker hyperv libvirt parallels virtualbox vmware"
# The namespaces.
ROBOX_NAMESPACES="generic magma developer lineage"
# The iso update functions.
ROBOX_ISOS="all arch centos centos8s centos9s gentoo hardenedbsd"
# The list of packer config files.
ROBOX_FILES="packer-cache.json "\
"magma-docker.json magma-hyperv.json magma-vmware.json magma-libvirt.json magma-virtualbox.json "\
"generic-docker.json generic-hyperv.json generic-vmware.json generic-libvirt.json generic-libvirt-x32.json generic-parallels.json generic-virtualbox.json generic-virtualbox-x32.json "\
"lineage-hyperv.json lineage-vmware.json lineage-libvirt.json lineage-virtualbox.json "\
"developer-ova.json developer-hyperv.json developer-vmware.json developer-libvirt.json developer-virtualbox.json"
# Collect the list of ISO urls.
ISOURLS=(`grep -E "iso_url|guest_additions_url" $ROBOX_FILES | awk -F'"' '{print $4}'`)
ISOSUMS=(`grep -E "iso_checksum|guest_additions_sha256" $ROBOX_FILES | awk -F'"' '{print $4}' | sed "s/^sha256://g"`)
UNIQURLS=(`grep -E "iso_url|guest_additions_url" $ROBOX_FILES | awk -F'"' '{print $4}' | sort | uniq`)
# Collect the list of box names.
MAGMA_BOXES=`grep -E '"name":' $ROBOX_FILES | awk -F'"' '{print $4}' | grep "magma-" | sort --field-separator=- -k 3i -k 2.1,2.0`
MAGMA_SPECIAL_BOXES="magma-hyperv magma-vmware magma-libvirt magma-virtualbox magma-docker "\
"magma-centos-hyperv magma-centos-vmware magma-centos-libvirt magma-centos-virtualbox magma-centos-docker "\
"magma-debian-hyperv magma-debian-vmware magma-debian-libvirt magma-debian-virtualbox "\
"magma-fedora-hyperv magma-fedora-vmware magma-fedora-libvirt magma-fedora-virtualbox "\
"magma-ubuntu-hyperv magma-ubuntu-vmware magma-ubuntu-libvirt magma-ubuntu-virtualbox "
GENERIC_BOXES=`grep -E '"name":' $ROBOX_FILES | awk -F'"' '{print $4}' | grep "generic-" | sort --field-separator=- -k 3i -k 2.1,2.0`
ROBOX_BOXES=`grep -E '"name":' $ROBOX_FILES | awk -F'"' '{print $4}' | grep "generic-" | sed "s/generic-/roboxes-/g"| sort --field-separator=- -k 3i -k 2.1,2.0`
LINEAGE_BOXES=`grep -E '"name":' $ROBOX_FILES | awk -F'"' '{print $4}' | grep -E "lineage-" | sort --field-separator=- -k 1i,1.8 -k 3i -k 2i,2.4`
LINEAGEOS_BOXES=`grep -E '"name":' $ROBOX_FILES | awk -F'"' '{print $4}' | grep -E "lineage-" | sed "s/lineage-/lineageos-/g"| sort --field-separator=- -k 1i,1.8 -k 3i -k 2i,2.4`
MAGMA_BOXES=`echo $MAGMA_SPECIAL_BOXES $MAGMA_BOXES | sed 's/ /\n/g' | sort -u --field-separator=- -k 3i -k 2.1,2.0`
BOXES="$GENERIC_BOXES $ROBOX_BOXES $MAGMA_BOXES $LINEAGE_BOXES $LINEAGEOS_BOXES"
# Collect the list of box tags.
MAGMA_TAGS=`grep -E '"name":' $ROBOX_FILES | awk -F'"' '{print $4}' | grep "magma" | grep -v "magma-developer-ova" | sed "s/magma-/lavabit\/magma-/g" | sed "s/alpine36/alpine/g" | sed "s/freebsd11/freebsd/g" | sed "s/openbsd6/openbsd/g" | sed "s/\(-hyperv\|-vmware\|-libvirt\|-parallels\|-virtualbox\|-docker\)\$//g" | sort -u --field-separator=-`
MAGMA_SPECIAL_TAGS="lavabit/magma lavabit/magma-centos lavabit/magma-debian lavabit/magma-fedora lavabit/magma-ubuntu"
ROBOX_TAGS=`grep -E '"name":' $ROBOX_FILES | awk -F'"' '{print $4}' | grep "generic" | sed "s/generic-/roboxes\//g" | sed "s/roboxes\(.*\)-x32/roboxes-x32\1/g" | sed "s/\(-hyperv\|-vmware\|-libvirt\|-parallels\|-virtualbox\|-docker\)\$//g" | grep -v "roboxes-x32" |sort -u --field-separator=-`
ROBOX_X32_TAGS=`grep -E '"name":' $ROBOX_FILES | awk -F'"' '{print $4}' | grep "generic" | sed "s/generic-/roboxes\//g" | sed "s/roboxes\(.*\)-x32/roboxes-x32\1/g" | sed "s/\(-hyperv\|-vmware\|-libvirt\|-parallels\|-virtualbox\|-docker\)\$//g" | grep "roboxes-x32" |sort -u --field-separator=-`
GENERIC_TAGS=`grep -E '"name":' $ROBOX_FILES | awk -F'"' '{print $4}' | grep "generic" | sed "s/generic-/generic\//g" | sed "s/generic\(.*\)-x32/generic-x32\1/g" | sed "s/\(-hyperv\|-vmware\|-libvirt\|-parallels\|-virtualbox\|-docker\)//g" | grep -v "generic-x32" | sort -u --field-separator=-`
GENERIC_X32_TAGS=`grep -E '"name":' $ROBOX_FILES | awk -F'"' '{print $4}' | grep "generic" | sed "s/generic-/generic\//g" | sed "s/generic\(.*\)-x32/generic-x32\1/g" | sed "s/\(-hyperv\|-vmware\|-libvirt\|-parallels\|-virtualbox\|-docker\)//g" | grep "generic-x32" | sort -u --field-separator=-`
LINEAGE_TAGS=`grep -E '"name":' $ROBOX_FILES | awk -F'"' '{print $4}' | grep "lineage" | sed "s/lineage-/lineage\/lineage-/g" | sed "s/\(-hyperv\|-vmware\|-libvirt\|-parallels\|-virtualbox\|-docker\)\$//g" | sort -u --field-separator=-`
LINEAGEOS_TAGS=`grep -E '"name":' $ROBOX_FILES | awk -F'"' '{print $4}' | grep "lineage" | sed "s/lineage-/lineageos\/lineage-/g" | sed "s/\(-hyperv\|-vmware\|-libvirt\|-parallels\|-virtualbox\|-docker\)\$//g" | sort -u --field-separator=-`
MAGMA_TAGS=`echo $MAGMA_SPECIAL_TAGS $MAGMA_TAGS | sed 's/ /\n/g' | sort -u --field-separator=-`
TAGS="$GENERIC_TAGS $GENERIC_X32_TAGS $ROBOX_TAGS $ROBOX_X32_TAGS $MAGMA_TAGS $LINEAGE_TAGS $LINEAGEOS_TAGS"
# These boxes aren't publicly available yet, so we filter them out of available test.
FILTERED_TAGS="lavabit/magma-alpine lavabit/magma-arch lavabit/magma-freebsd lavabit/magma-gentoo lavabit/magma-openbsd"
# A list of configs to skip during complete build operations.
export EXCEPTIONS=""
# The repository URLs, so we can catch any which might disappeared since the last build.
# Alma 8
REPOS+=( "https://dfw.mirror.rackspace.com/almalinux/8.7/BaseOS/x86_64/os/repodata/repomd.xml" )
REPOS+=( "https://dfw.mirror.rackspace.com/almalinux/8.7/BaseOS/x86_64/os/repodata/repomd.xml.asc" )
REPOS+=( "https://dfw.mirror.rackspace.com/almalinux/8.7/AppStream/x86_64/os/repodata/repomd.xml" )
REPOS+=( "https://dfw.mirror.rackspace.com/almalinux/8.7/AppStream/x86_64/os/repodata/repomd.xml.asc" )
# When this link becomes available, update the JSON files and remove it from here.
FUTURE+=( "https://dfw.mirror.rackspace.com/almalinux/8.8/isos/x86_64/AlmaLinux-8.8-x86_64-boot.iso" )
# Alma 9
REPOS+=( "https://dfw.mirror.rackspace.com/almalinux/9.1/BaseOS/x86_64/os/repodata/repomd.xml" )
REPOS+=( "https://dfw.mirror.rackspace.com/almalinux/9.1/BaseOS/x86_64/os/repodata/repomd.xml.asc" )
REPOS+=( "https://dfw.mirror.rackspace.com/almalinux/9.1/AppStream/x86_64/os/repodata/repomd.xml" )
REPOS+=( "https://dfw.mirror.rackspace.com/almalinux/9.1/AppStream/x86_64/os/repodata/repomd.xml.asc" )
# When this link becomes available, update the JSON files and remove it from here.
FUTURE+=( "https://dfw.mirror.rackspace.com/almalinux/9.2/isos/x86_64/AlmaLinux-9.2-x86_64-boot.iso" )
# Alpine Edge
REPOS+=( "https://mirrors.edge.kernel.org/alpine/edge/main/x86_64/APKINDEX.tar.gz" )
REPOS+=( "https://mirrors.edge.kernel.org/alpine/edge/community/x86_64/APKINDEX.tar.gz" )
# Alpine 3.5
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz" )
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz" )
# Alpine 3.6
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz" )
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz" )
# Alpine 3.7
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz" )
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz" )
# Alpine 3.8
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz" )
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz" )
# Alpine 3.9
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz" )
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz" )
# Alpine 3.10
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz" )
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz" )
# Alpine 3.11
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz" )
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz" )
# Alpine 3.12
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz" )
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz" )
# Alpine 3.13
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz" )
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz" )
# Alpine 3.14
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz" )
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz" )
# Alpine 3.15
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz" )
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz" )
# Alpine 3.16
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz" )
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.16/community/x86_64/APKINDEX.tar.gz" )
# Alpine 3.17
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.17/main/x86_64/APKINDEX.tar.gz" )
REPOS+=( "https://mirrors.edge.kernel.org/alpine/v3.17/community/x86_64/APKINDEX.tar.gz" )
# Alpine 3.18
FUTURE+=( "https://mirrors.edge.kernel.org/alpine/v3.18/main/x86_64/APKINDEX.tar.gz" )
FUTURE+=( "https://mirrors.edge.kernel.org/alpine/v3.18/community/x86_64/APKINDEX.tar.gz" )
# When the release ISO becomes available, update the JSON files, and remove this URL.
FUTURE+=( "https://mirrors.edge.kernel.org/alpine/v3.18/releases/x86_64/alpine-virt-3.18.0-x86_64.iso" )
# CentOS 6
REPOS+=( "https://vault.centos.org/6.10/os/x86_64/repodata/repomd.xml" )
REPOS+=( "https://vault.centos.org/6.10/os/x86_64/repodata/repomd.xml.asc" )
REPOS+=( "https://vault.centos.org/6.10/updates/x86_64/repodata/repomd.xml" )
REPOS+=( "https://vault.centos.org/6.10/updates/x86_64/repodata/repomd.xml.asc" )
# CentOS 7
REPOS+=( "http://mirrors.edge.kernel.org/centos/7.9.2009/os/x86_64/repodata/repomd.xml" )
REPOS+=( "http://mirrors.edge.kernel.org/centos/7.9.2009/os/x86_64/repodata/repomd.xml.asc" )
REPOS+=( "http://mirrors.edge.kernel.org/centos/7.9.2009/updates/x86_64/repodata/repomd.xml" )
REPOS+=( "http://mirrors.edge.kernel.org/centos/7.9.2009/updates/x86_64/repodata/repomd.xml.asc" )
# CentOS 8
REPOS+=( "https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/repodata/repomd.xml" )
REPOS+=( "https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/repodata/repomd.xml.asc" )
REPOS+=( "https://vault.centos.org/8.5.2111/AppStream/x86_64/os/repodata/repomd.xml" )
REPOS+=( "https://vault.centos.org/8.5.2111/AppStream/x86_64/os/repodata/repomd.xml.asc" )
# CentOS 8 Stream
REPOS+=( "https://mirrors.edge.kernel.org/centos/8-stream/BaseOS/x86_64/os/repodata/repomd.xml" )
REPOS+=( "https://mirrors.edge.kernel.org/centos/8-stream/BaseOS/x86_64/os/repodata/repomd.xml.asc" )
REPOS+=( "https://mirrors.edge.kernel.org/centos/8-stream/AppStream/x86_64/os/repodata/repomd.xml" )
REPOS+=( "https://mirrors.edge.kernel.org/centos/8-stream/AppStream/x86_64/os/repodata/repomd.xml.asc" )
# CentOS 9 Stream
REPOS+=( "https://dfw.mirror.rackspace.com/centos-stream/9-stream/BaseOS/x86_64/os/repodata/repomd.xml" )
REPOS+=( "https://dfw.mirror.rackspace.com/centos-stream/9-stream/BaseOS/x86_64/os/repodata/repomd.xml.asc" )
REPOS+=( "https://dfw.mirror.rackspace.com/centos-stream/9-stream/AppStream/x86_64/os/repodata/repomd.xml" )
REPOS+=( "https://dfw.mirror.rackspace.com/centos-stream/9-stream/AppStream/x86_64/os/repodata/repomd.xml.asc" )
# Devuan 1
REPOS+=( "https://pkgmaster.devuan.org/devuan/dists/jessie/InRelease" )
# Devuan 2
REPOS+=( "https://pkgmaster.devuan.org/devuan/dists/ascii/InRelease" )
# Devuan 3
REPOS+=( "https://pkgmaster.devuan.org/devuan/dists/beowulf/InRelease" )
# Devuan 4
REPOS+=( "https://pkgmaster.devuan.org/devuan/dists/ceres/InRelease" )
# Devuan 5
REPOS+=( "https://pkgmaster.devuan.org/devuan/dists/daedalus/InRelease" )
# Debian 8
REPOS+=( "http://archive.debian.org/debian/dists/jessie/Release" )
REPOS+=( "http://archive.debian.org/debian-security/dists/jessie/updates/Release" )
# Debian 9
REPOS+=( "https://ftp.debian.org/debian/dists/stretch/Release" )
REPOS+=( "https://security.debian.org/debian-security/dists/stretch/updates/Release" )
# Debian 10
REPOS+=( "https://ftp.debian.org/debian/dists/buster/InRelease" )
REPOS+=( "https://security.debian.org/debian-security/dists/buster/updates/Release" )
# Debian 11
REPOS+=( "https://ftp.debian.org/debian/dists/bullseye/InRelease" )
REPOS+=( "https://security.debian.org/debian-security/dists/bullseye-security/updates/InRelease" )
# Debian 12
REPOS+=( "https://ftp.debian.org/debian/dists/bookworm/InRelease" )
REPOS+=( "https://security.debian.org/debian-security/dists/bookworm-security/updates/InRelease" )
# Debian 13
FUTURE+=( "https://ftp.debian.org/debian/dists/trixie/InRelease" )
FUTURE+=( "https://security.debian.org/debian-security/dists/trixie/updates/Release" )
# FreeBSD 11
REPOS+=( "https://mirrors.xtom.com/freebsd-pkg/FreeBSD:11:amd64/latest/packagesite.txz" )
# FreeBSD 12
REPOS+=( "https://pkg.freebsd.org/FreeBSD:12:amd64/latest/packagesite.txz" )
# FreeBSD 13
REPOS+=( "https://pkg.freebsd.org/FreeBSD:13:amd64/latest/packagesite.txz" )
# FreeBSD 14
REPOS+=( "https://pkg.freebsd.org/FreeBSD:14:amd64/latest/packagesite.txz" )
# Fedora 27
REPOS+=( "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/27/Everything/x86_64/os/repodata/repomd.xml" )
# Fedora 28
REPOS+=( "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/28/Everything/x86_64/os/repodata/repomd.xml" )
# Fedora 29
REPOS+=( "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/29/Everything/x86_64/os/repodata/repomd.xml" )
# Fedora 30
REPOS+=( "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/30/Everything/x86_64/os/repodata/repomd.xml" )
# Fedora 31
REPOS+=( "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/31/Everything/x86_64/os/repodata/repomd.xml" )
# Fedora 32
REPOS+=( "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/32/Everything/x86_64/os/repodata/repomd.xml" )
# Fedora 33
REPOS+=( "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/33/Everything/x86_64/os/repodata/repomd.xml" )
# Fedora 34
REPOS+=( "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/34/Server/x86_64/os/repodata/repomd.xml" )
# Fedora 35
REPOS+=( "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/35/Server/x86_64/os/repodata/repomd.xml" )
# Fedora 36
REPOS+=( "https://dl.fedoraproject.org/pub/fedora/linux/releases/36/Server/x86_64/os/repodata/repomd.xml" )
# Fedora 37
REPOS+=( "https://dl.fedoraproject.org/pub/fedora/linux/releases/37/Server/x86_64/os/repodata/repomd.xml" )
# Fedora 38
FUTURE+=( "https://dl.fedoraproject.org/pub/fedora/linux/releases/38/Server/x86_64/os/repodata/repomd.xml" )
# Fedora 39
FUTURE+=( "https://dl.fedoraproject.org/pub/fedora/linux/releases/39/Server/x86_64/os/repodata/repomd.xml" )
# Fedora 40
FUTURE+=( "https://dl.fedoraproject.org/pub/fedora/linux/releases/40/Server/x86_64/os/repodata/repomd.xml" )
# FreeBSD 11
REPOS+=( "https://mirrors.xtom.com/freebsd-pkg/FreeBSD:11:amd64/latest/packagesite.txz" )
# FreeBSD 12
REPOS+=( "https://pkg.freebsd.org/FreeBSD:12:amd64/latest/packagesite.txz" )
# FreeBSD 13
REPOS+=( "https://pkg.freebsd.org/FreeBSD:13:amd64/latest/packagesite.txz" )
# FreeBSD 14
REPOS+=( "https://pkg.freebsd.org/FreeBSD:14:amd64/latest/packagesite.txz" )
# Gentoo
REPOS+=( "https://mirrors.kernel.org/gentoo/snapshots/portage-latest.tar.bz2" )
REPOS+=( "https://mirrors.kernel.org/gentoo/snapshots/portage-latest.tar.bz2.gpgsig" )
REPOS+=( "https://mirrors.kernel.org/gentoo/snapshots/portage-latest.tar.bz2.md5sum" )
REPOS+=( "https://mirrors.kernel.org/gentoo/snapshots/portage-latest.tar.xz" )
REPOS+=( "https://mirrors.kernel.org/gentoo/snapshots/portage-latest.tar.xz.gpgsig" )
REPOS+=( "https://mirrors.kernel.org/gentoo/snapshots/portage-latest.tar.xz.md5sum" )
# HardenedBSD 12
REPOS+=( "https://pkg.hardenedbsd.org/HardenedBSD/pkg/FreeBSD:12:amd64/packagesite.txz" )
# HardenedBSD 13
REPOS+=( "https://pkg.hardenedbsd.org/HardenedBSD/pkg/FreeBSD:13:amd64/packagesite.txz" )
# HardenedBSD 14
REPOS+=( "https://pkg.hardenedbsd.org/HardenedBSD/pkg/FreeBSD:14:amd64/packagesite.txz" )
# NetBSD 8.2
REPOS+=( "https://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/8.2/SHA512.bz2" )
# NetBSD 9.3
REPOS+=( "https://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/9.3/SHA512.bz2" )
# OpenBSD 6.9
REPOS+=( "https://mirrors.lavabit.com/openbsd/6.9/amd64/index.txt" )
REPOS+=( "https://mirrors.lavabit.com/openbsd/6.9/amd64/SHA256" )
REPOS+=( "https://mirrors.lavabit.com/openbsd/6.9/amd64/SHA256.sig" )
REPOS+=( "https://mirrors.lavabit.com/openbsd/6.9/amd64/man69.tgz" )
REPOS+=( "https://mirrors.lavabit.com/openbsd/6.9/amd64/base69.tgz" )
REPOS+=( "https://mirrors.lavabit.com/openbsd/6.9/amd64/comp69.tgz" )
REPOS+=( "https://mirrors.lavabit.com/openbsd/6.9/packages/amd64/index.txt" )
REPOS+=( "https://mirrors.lavabit.com/openbsd/6.9/packages/amd64/SHA256" )
REPOS+=( "https://mirrors.lavabit.com/openbsd/6.9/packages/amd64/SHA256.sig" )
# OpenBSD 7.2
REPOS+=( "https://ftp.usa.openbsd.org/pub/OpenBSD/7.2/amd64/index.txt" )
REPOS+=( "https://ftp.usa.openbsd.org/pub/OpenBSD/7.2/amd64/SHA256" )
REPOS+=( "https://ftp.usa.openbsd.org/pub/OpenBSD/7.2/amd64/SHA256.sig" )
REPOS+=( "https://ftp.usa.openbsd.org/pub/OpenBSD/7.2/amd64/man72.tgz" )
REPOS+=( "https://ftp.usa.openbsd.org/pub/OpenBSD/7.2/amd64/base72.tgz" )
REPOS+=( "https://ftp.usa.openbsd.org/pub/OpenBSD/7.2/amd64/comp72.tgz" )
REPOS+=( "https://ftp.usa.openbsd.org/pub/OpenBSD/7.2/packages/amd64/index.txt" )
REPOS+=( "https://ftp.usa.openbsd.org/pub/OpenBSD/7.2/packages/amd64/SHA256" )
REPOS+=( "https://ftp.usa.openbsd.org/pub/OpenBSD/7.2/packages/amd64/SHA256.sig" )
# Oracle 6
REPOS+=( "https://yum.oracle.com/repo/OracleLinux/OL6/latest/x86_64/repodata/repomd.xml" )
REPOS+=( "https://yum.oracle.com/repo/OracleLinux/OL6/UEKR4/x86_64/repodata/repomd.xml" )
# Oracle 7
REPOS+=( "https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/repodata/repomd.xml" )
REPOS+=( "https://yum.oracle.com/repo/OracleLinux/OL7/UEKR6/x86_64/repodata/repomd.xml" )
# Oracle 8
REPOS+=( "https://yum.oracle.com/repo/OracleLinux/OL8/baseos/latest/x86_64/repodata/repomd.xml" )
REPOS+=( "https://yum.oracle.com/repo/OracleLinux/OL8/appstream/x86_64/repodata/repomd.xml" )
REPOS+=( "https://yum.oracle.com/repo/OracleLinux/OL8/UEKR6/x86_64/repodata/repomd.xml" )
# When Oracle 8.8 is available this URL will become active. Update the JSON files and remove from here.
FUTURE+=( "https://yum.oracle.com/ISOS/OracleLinux/OL8/u8/x86_64/x86_64-boot-uek.iso" )
# Oracle 9
REPOS+=( "https://yum.oracle.com/repo/OracleLinux/OL9/baseos/latest/x86_64/repodata/repomd.xml" )
REPOS+=( "https://yum.oracle.com/repo/OracleLinux/OL9/appstream/x86_64/repodata/repomd.xml" )
# When Oracle 9.2 is available this URL will become active. Update the JSON files and start looking for the 9,3 update.
FUTURE+=( "https://yum.oracle.com/ISOS/OracleLinux/OL9/u2/x86_64/OracleLinux-R9-U2-x86_64-boot.iso" )
# OpenSUSE 42.3
REPOS+=( "https://ftp5.gwdg.de/pub/opensuse/discontinued/distribution/leap/42.3/repo/oss/INDEX.gz" )
# OpenSUSE 15.4
REPOS+=( "https://download.opensuse.org/distribution/leap/15.4/repo/oss/INDEX.gz" )
# Rocky 8
REPOS+=( "https://ftp5.gwdg.de/pub/linux/rocky/8.7/BaseOS/x86_64/os/repodata/repomd.xml" )
REPOS+=( "https://ftp5.gwdg.de/pub/linux/rocky/8.7/BaseOS/x86_64/os/repodata/repomd.xml.asc" )
REPOS+=( "https://ftp5.gwdg.de/pub/linux/rocky/8.7/AppStream/x86_64/os/repodata/repomd.xml" )
REPOS+=( "https://ftp5.gwdg.de/pub/linux/rocky/8.7/AppStream/x86_64/os/repodata/repomd.xml.asc" )
# When this link becomes available, update the JSON files and remove it from here.
FUTURE+=( "https://ftp5.gwdg.de/pub/linux/rocky/8.8/isos/x86_64/Rocky-8.8-x86_64-boot.iso" )
# When 8.8 is released, these will replace the 8.7 URLs above.
FUTURE+=( "https://ftp5.gwdg.de/pub/linux/rocky/8.8/BaseOS/x86_64/os/repodata/repomd.xml" )
FUTURE+=( "https://ftp5.gwdg.de/pub/linux/rocky/8.8/BaseOS/x86_64/os/repodata/repomd.xml.asc" )
FUTURE+=( "https://ftp5.gwdg.de/pub/linux/rocky/8.8/AppStream/x86_64/os/repodata/repomd.xml" )
FUTURE+=( "https://ftp5.gwdg.de/pub/linux/rocky/8.8/AppStream/x86_64/os/repodata/repomd.xml.asc" )
# Rocky 9
REPOS+=( "https://ftp5.gwdg.de/pub/linux/rocky/9.1/BaseOS/x86_64/os/repodata/repomd.xml" )
REPOS+=( "https://ftp5.gwdg.de/pub/linux/rocky/9.1/BaseOS/x86_64/os/repodata/repomd.xml.asc" )
REPOS+=( "https://ftp5.gwdg.de/pub/linux/rocky/9.1/AppStream/x86_64/os/repodata/repomd.xml" )
REPOS+=( "https://ftp5.gwdg.de/pub/linux/rocky/9.1/AppStream/x86_64/os/repodata/repomd.xml.asc" )
# When this link becomes available, update the JSON files and remove it from here.
FUTURE+=( "https://ftp5.gwdg.de/pub/linux/rocky/9.2/isos/x86_64/Rocky-9.2-x86_64-boot.iso" )
# When 9.2 is released, these will replace the 9.1 URLs above.
FUTURE+=( "https://ftp5.gwdg.de/pub/linux/rocky/9.2/BaseOS/x86_64/os/repodata/repomd.xml" )
FUTURE+=( "https://ftp5.gwdg.de/pub/linux/rocky/9.2/BaseOS/x86_64/os/repodata/repomd.xml.asc" )
FUTURE+=( "https://ftp5.gwdg.de/pub/linux/rocky/9.2/AppStream/x86_64/os/repodata/repomd.xml" )
FUTURE+=( "https://ftp5.gwdg.de/pub/linux/rocky/9.2/AppStream/x86_64/os/repodata/repomd.xml.asc" )
# Ubuntu 16.04
REPOS+=( "https://mirrors.edge.kernel.org/ubuntu/dists/xenial/InRelease" )
# Ubuntu 16.10
REPOS+=( "https://old-releases.ubuntu.com/ubuntu/dists/yakkety/InRelease" )
# Ubuntu 17.04
REPOS+=( "https://old-releases.ubuntu.com/ubuntu/dists/zesty/InRelease" )
# Ubuntu 17.10
REPOS+=( "https://old-releases.ubuntu.com/ubuntu/dists/artful/InRelease" )
# Ubuntu 18.04
REPOS+=( "https://mirrors.edge.kernel.org/ubuntu/dists/bionic/InRelease" )
# Ubuntu 18.10
REPOS+=( "https://old-releases.ubuntu.com/ubuntu/dists/cosmic/InRelease" )
# Ubuntu 19.04
REPOS+=( "https://old-releases.ubuntu.com/ubuntu/dists/disco/InRelease" )
# Ubuntu 19.10
REPOS+=( "https://old-releases.ubuntu.com/ubuntu/dists/eoan/InRelease" )
# Ubuntu 20.04
REPOS+=( "https://mirrors.edge.kernel.org/ubuntu/dists/focal/InRelease" )
# Ubuntu 20.10
REPOS+=( "https://old-releases.ubuntu.com/ubuntu/dists/groovy/InRelease" )
# Ubuntu 21.04
REPOS+=( "https://old-releases.ubuntu.com/ubuntu/dists/hirsute/InRelease" )
# Ubuntu 21.10
REPOS+=( "https://old-releases.ubuntu.com/ubuntu/dists/impish/InRelease" )
# Ubuntu 22.04
REPOS+=( "https://mirrors.edge.kernel.org/ubuntu/dists/jammy/InRelease" )
# Ubuntu 22.10
REPOS+=( "https://mirrors.edge.kernel.org/ubuntu/dists/kinetic/InRelease" )
# Ubuntu 23.04
REPOS+=( "https://mirrors.edge.kernel.org/ubuntu/dists/lunar/InRelease" )
# When this link becomes available, update the JSON files and remove it from here.
FUTURE+=( "https://releases.ubuntu.com/23.04/ubuntu-23.04-live-server-amd64.iso" )
# Ubuntu 23.10
# This means the 23.10 repository is available.
# REPOS+=( "https://mirrors.edge.kernel.org/ubuntu/dists/UNKNOWN/InRelease" )
# When this link becomes available, update the JSON files and remove it from here.
FUTURE+=( "https://releases.ubuntu.com/23.10/ubuntu-23.10-live-server-amd64.iso" )
# EPEL
REPOS+=( "https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/repodata/repomd.xml" )
REPOS+=( "https://mirrors.edge.kernel.org/fedora-epel/7/x86_64/repodata/repomd.xml" )
REPOS+=( "https://mirrors.edge.kernel.org/fedora-epel/8/Everything/x86_64/repodata/repomd.xml" )
REPOS+=( "https://mirrors.edge.kernel.org/fedora-epel/8/Modular/x86_64/repodata/repomd.xml" )
REPOS+=( "https://mirrors.edge.kernel.org/fedora-epel/9/Everything/x86_64/repodata/repomd.xml" )
# Other URls Embedded inside configuration modules
RESOURCES+=( "https://archive.org/download/xenial_python3.6_deb/libpython3.6-minimal_3.6.13-1%2Bxenial2_amd64.deb" )
RESOURCES+=( "https://archive.org/download/xenial_python3.6_deb/libpython3.6-stdlib_3.6.13-1%2Bxenial2_amd64.deb" )
RESOURCES+=( "https://archive.org/download/xenial_python3.6_deb/python3.6_3.6.13-1%2Bxenial2_amd64.deb" )
RESOURCES+=( "https://archive.org/download/xenial_python3.6_deb/python3.6-minimal_3.6.13-1%2Bxenial2_amd64.deb" )
RESOURCES+=( "https://dl.google.com/android/repository/platform-tools-latest-linux.zip" )
RESOURCES+=( "https://files.pythonhosted.org/packages/03/1a/60984cb85cc38c4ebdfca27b32a6df6f1914959d8790f5a349608c78be61/cryptography-1.5.2.tar.gz" )
RESOURCES+=( "https://files.pythonhosted.org/packages/10/46/059775dc8e50f722d205452bced4b3cc965d27e8c3389156acd3b1123ae3/pyasn1-0.4.4.tar.gz" )
RESOURCES+=( "https://files.pythonhosted.org/packages/16/d8/bc6316cf98419719bd59c91742194c111b6f2e85abac88e496adefaf7afe/six-1.11.0.tar.gz" )
RESOURCES+=( "https://files.pythonhosted.org/packages/34/a9/65ef401499e6878b3c67c473ecfd8803eacf274b03316ec8f2e86116708d/setuptools-11.3.tar.gz" )
RESOURCES+=( "https://files.pythonhosted.org/packages/65/c4/80f97e9c9628f3cac9b98bfca0402ede54e0563b56482e3e6e45c43c4935/idna-2.7.tar.gz" )
RESOURCES+=( "https://files.pythonhosted.org/packages/97/8d/77b8cedcfbf93676148518036c6b1ce7f8e14bf07e95d7fd4ddcb8cc052f/ipaddress-1.0.22.tar.gz" )
RESOURCES+=( "https://files.pythonhosted.org/packages/bf/3e/31d502c25302814a7c2f1d3959d2a3b3f78e509002ba91aea64993936876/enum34-1.1.6.tar.gz" )
RESOURCES+=( "https://files.pythonhosted.org/packages/e7/a7/4cd50e57cc6f436f1cc3a7e8fa700ff9b8b4d471620629074913e3735fb2/cffi-1.11.5.tar.gz" )
RESOURCES+=( "https://mirrors.edge.kernel.org/debian/pool/main/libj/libjpeg-turbo/libjpeg62-turbo_1.5.1-2_amd64.deb" )
RESOURCES+=( "https://mirrors.xtom.com/freebsd-pkg/FreeBSD:11:amd64/latest/All/open-vm-tools-nox11-11.3.0,2.pkg" )
RESOURCES+=( "https://raw.githubusercontent.com/curl/curl/85f91248cffb22d151d5983c32f0dbf6b1de572a/lib/mk-ca-bundle.pl" )
RESOURCES+=( "https://sourceware.org/pub/valgrind/valgrind-3.15.0.tar.bz2" )
RESOURCES+=( "https://storage.googleapis.com/git-repo-downloads/repo" )
# This server doesn't have a properly configured HTTPS certificate, so we use HTTP
RESOURCES+=( "http://archive.debian.org/debian/pool/main/o/openjdk-7/openjdk-7-jdk_7u181-2.6.14-1~deb8u1_amd64.deb" )
RESOURCES+=( "http://archive.debian.org/debian/pool/main/o/openjdk-7/openjdk-7-jre_7u181-2.6.14-1~deb8u1_amd64.deb" )
RESOURCES+=( "http://archive.debian.org/debian/pool/main/o/openjdk-7/openjdk-7-jre-headless_7u181-2.6.14-1~deb8u1_amd64.deb" )
# These files are used by the providers install script.
RESOURCES+=( "https://archive.org/download/vmwaretools10.1.15other6677369.tar/VMware-Tools-10.1.15-other-6677369.tar.gz" )
RESOURCES+=( "https://archive.org/download/vmware-workstation-17.0.0/VMware-Workstation-Full-15.5.7-17171714.x86_64.bundle" )
RESOURCES+=( "https://archive.org/download/vmware-workstation-17.0.0/VMware-Workstation-Full-16.2.5-20904516.x86_64.bundle" )
RESOURCES+=( "https://archive.org/download/vmware-workstation-17.0.0/VMware-Workstation-Full-17.0.0-20800274.x86_64.bundle" )
# Detect Windows subsystem for Linux.
if [ -z $OS ]; then
if [[ "`uname -r`" =~ -Microsoft$ ]]; then
export OS="Windows_NT"
fi
fi
# If Vagrant is installed, use the newer version of curl.
if [ -f /opt/vagrant/embedded/bin/curl ]; then
export CURL="/opt/vagrant/embedded/bin/curl"
if [ -f /opt/vagrant/embedded/lib64/libssl.so ] && [ -z LD_PRELOAD ]; then
export LD_PRELOAD="/opt/vagrant/embedded/lib64/libssl.so"
elif [ -f /opt/vagrant/embedded/lib64/libssl.so ]; then
export LD_PRELOAD="/opt/vagrant/embedded/lib64/libssl.so:$LD_PRELOAD"
fi
if [ -f /opt/vagrant/embedded/lib64/libcrypto.so ] && [ -z LD_PRELOAD ]; then
export LD_PRELOAD="/opt/vagrant/embedded/lib64/libcrypto.so"
elif [ -f /opt/vagrant/embedded/lib64/libcrypto.so ]; then
export LD_PRELOAD="/opt/vagrant/embedded/lib64/libcrypto.so:$LD_PRELOAD"
fi
export LD_LIBRARY_PATH="/opt/vagrant/embedded/bin/lib/:/opt/vagrant/embedded/lib64/"
else
export CURL="curl"
fi
function retry() {
local COUNT=1
local DELAY=1
local RESULT=0
while [[ "${COUNT}" -le 10 ]]; do
[[ "${RESULT}" -ne 0 ]] && {
tput setaf 1; printf "\n${*} failed... retrying ${COUNT} of 10.\n" >&2; tput sgr0
}
"${@}" && { RESULT=0 && break; } || RESULT="${?}"
COUNT="$((COUNT + 1))"
# Increase the delay with each iteration.
DELAY="$((DELAY + 10))"
sleep $DELAY
done
[[ "${COUNT}" -gt 10 ]] && {
tput setaf 1; printf "\nThe command failed 10 times.\n" >&2; tput sgr0
}
return "${RESULT}"
}
function curltry() {
local COUNT=1
local DELAY=1
local RESULT=0
while [[ "${COUNT}" -le 100 ]]; do
RESULT=0 ; OUTPUT=`"${@}"` || RESULT="${?}"
if [[ $RESULT == 0 ]] || [[ `echo "$OUTPUT" | grep --count --extended-regexp --max-count=1 "^404$|^HTTP/1.1 404|^HTTP/2 404"` == 1 ]]; then
break
fi
COUNT="$((COUNT + 1))"
DELAY="$((DELAY + 1))"
sleep $DELAY
done
echo "$OUTPUT"
return "${RESULT}"
}
function start() {
# Disable IPv6 or the VMware builder won't be able to load the Kick Start configuration.
sudo sysctl net.ipv6.conf.all.disable_ipv6=1
unset LD_PRELOAD
unset LD_LIBRARY_PATH
# Start the required services.
# sudo systemctl restart vmtoolsd.service
if [ -f /usr/lib/systemd/system/vboxdrv.service ]; then sudo systemctl restart vboxdrv.service ; fi
if [ -f /usr/lib/systemd/system/libvirtd.service ]; then sudo systemctl restart libvirtd.service ; fi
if [ -f /usr/lib/systemd/system/podman.service ]; then
sudo systemctl restart podman.service ;
elif [ -f /usr/lib/systemd/system/io.podman.service ]; then
sudo systemctl restart io.podman.service ;
elif [ -f /usr/lib/systemd/system/docker-storage-setup.service ] && [ -f /usr/lib/systemd/system/docker.service ]; then
sudo systemctl restart docker-storage-setup.service
sudo systemctl restart docker.service
elif [ -f /usr/lib/systemd/system/docker.service ]; then
sudo systemctl restart docker.service
fi
# Confirm the VirtualBox kernel modules loaded.
if [ -f /usr/lib/virtualbox/vboxdrv.sh ]; then
/usr/lib/virtualbox/vboxdrv.sh status | grep --color=none "VirtualBox kernel modules \(.*\) are loaded."
if [ $? != 0 ]; then
sudo /usr/lib/virtualbox/vboxdrv.sh setup
if [ $? != 0 ]; then
tput setaf 1; tput bold; printf "\n\nThe virtualbox kernel modules failed to load properly...\n\n"; tput sgr0
for i in 1 2 3; do printf "\a"; sleep 1; done
exit 1
fi
fi
fi
# # Set the tuning profile to virtual-host.
# if [ -f /usr/sbin/tuned-adm ]; then
# sudo /usr/sbin/tuned-adm profile virtual-host
# sudo /usr/sbin/tuned-adm active
# fi
# # Set the CPU performance level to maximum.
# if [ -f /usr/bin/cpupower ]; then
# sudo /usr/bin/cpupower set -b 0
# sudo /usr/bin/cpupower info
# fi
# if [ -f /sys/kernel/mm/ksm/run ]; then
# echo 1 | sudo tee /sys/kernel/mm/ksm/run > /dev/null
# fi
# # Confirm the VMware modules loaded.
if [ -f /usr/bin/vmware-modconfig ]; then
MODS=`sudo /etc/init.d/vmware status | grep --color=none --extended-regexp "Module vmmon loaded|Module vmnet loaded" | wc -l`
if [ "$MODS" != "2" ]; then
printf "Compiling the VMWare kernel modules.\n";
sudo vmware-modconfig --console --install-all &> /dev/null
if [ $? != 0 ]; then
tput setaf 1; tput bold; printf "\n\nThe vmware kernel modules failed to load properly...\n\n"; tput sgr0
for i in 1 2 3; do printf "\a"; sleep 1; done
exit 1
fi
else
if [ -f /etc/init.d/vmware ]; then sudo /etc/init.d/vmware start ; fi
if [ -f /etc/init.d/vmware-USBArbitrator ]; then sudo /etc/init.d/vmware-USBArbitrator start ; fi
fi
fi
}
function print_iso() {
SHA=`${CURL} --silent --location "${2}" | sha256sum | awk -F' ' '{print $1}'`
if [ $? != 0 ]; then
tput setaf 1; printf "\n$1 failed.\n\n"; tput sgr0; printf "${2}\n\n"
return 1
fi
tput setaf 2; printf "\n$1\n\n"; tput sgr0; printf "${2}\n${SHA}\n\n"
}
function iso() {
if [ "$1" == "gentoo" ]; then
# Find the existing Gentoo URL and hash values.
ISO_URL=`cat "$BASE/packer-cache.json" | jq -r -c ".builders[] | select( .name | contains(\"gentoo\")) | .iso_url" 2>/dev/null`
ISO_CHECKSUM=`cat "$BASE/packer-cache.json" | jq -r -c ".builders[] | select( .name | contains(\"gentoo\")) | .iso_checksum" 2>/dev/null`
# Find the Gentoo URL.
URL="https://mirrors.edge.kernel.org/gentoo/releases/amd64/autobuilds/current-install-amd64-minimal/"
ISO=`${CURL} --fail --silent "${URL}" | grep --invert-match sha256 | grep --extended-regexp --only-matching --max-count=1 "install\-amd64\-minimal\-[0-9]{8}T[0-9]{6}Z\.iso" | uniq`
if [ $? != 0 ] || [ "$ISO" == "" ]; then
tput setaf 1; printf "\nThe Gentoo ISO update failed.\n\n"; tput sgr0
return 1
fi
# Calculate the new URL.
URL="${URL}${ISO}"
# Download the ISO file and calculate the new hash value.
set -o pipefail
SHA=`${CURL} --fail --speed-time 60 --speed-limit 1024 --silent --location "${URL}" | sha256sum | awk -F' ' '{print $1}'`
if [ $? != 0 ] || [ "$SHA" == "" ]; then
tput setaf 1; printf "\nThe Gentoo ISO update failed.\n\n"; tput sgr0
return 1
fi
set +o pipefail
# Escape the URL strings.
URL=`echo $URL | sed "s/\//\\\\\\\\\//g"`
ISO_URL=`echo $ISO_URL | sed "s/\//\\\\\\\\\//g"`
# Replace the existing ISO and hash values with the update values.
sed --in-place "s/$ISO_URL/$URL/g" $ROBOX_FILES
sed --in-place "s/$ISO_CHECKSUM/sha256:$SHA/g" $ROBOX_FILES
elif [ "$1" == "arch" ]; then
# Find the existing Arch URL and hash values.
ISO_URL=`cat "$BASE/packer-cache.json" | jq -r -c ".builders[] | select( .name | contains(\"arch\")) | .iso_url" 2>/dev/null`
ISO_CHECKSUM=`cat "$BASE/packer-cache.json" | jq -r -c ".builders[] | select( .name | contains(\"arch\")) | .iso_checksum" 2>/dev/null`
# Find the Arch URL.
URL="https://mirrors.edge.kernel.org/archlinux/iso/latest/"
ISO=`${CURL} --fail --silent "${URL}" | grep --invert-match sha256 | grep --extended-regexp --only-matching --max-count=1 "archlinux\-[0-9]{4}\.[0-9]{2}\.[0-9]{2}\-x86\_64\.iso" | uniq`
if [ $? != 0 ] || [ "$ISO" == "" ]; then
tput setaf 1; printf "\nThe Arch ISO update failed.\n\n"; tput sgr0
return 1
fi
# Calculate the new URL.
URL="${URL}${ISO}"
# Download the ISO file and calculate the new hash value.
set -o pipefail
SHA=`${CURL} --fail --speed-time 60 --speed-limit 1024 --silent --location "${URL}" | sha256sum | awk -F' ' '{print $1}'`
if [ $? != 0 ] || [ "$SHA" == "" ]; then
tput setaf 1; printf "\nThe Arch ISO update failed.\n\n"; tput sgr0
return 1
fi
set +o pipefail
# Escape the URL strings.
URL=`echo $URL | sed "s/\//\\\\\\\\\//g"`
ISO_URL=`echo $ISO_URL | sed "s/\//\\\\\\\\\//g"`
# Replace the existing ISO and hash values with the update values.
sed --in-place "s/$ISO_URL/$URL/g" $ROBOX_FILES
sed --in-place "s/$ISO_CHECKSUM/sha256:$SHA/g" $ROBOX_FILES
elif [ "$1" == "centos8s" ]; then
# Find the existing CentOS 8 stream URL and hash values.
ISO_URL=`cat "$BASE/packer-cache.json" | jq -r -c ".builders[] | select( .name | contains(\"centos8s\")) | .iso_url" 2>/dev/null`
ISO_CHECKSUM=`cat "$BASE/packer-cache.json" | jq -r -c ".builders[] | select( .name | contains(\"centos8s\")) | .iso_checksum" 2>/dev/null`
# Find the CentOS 8 stream URL.
URL="https://mirrors.edge.kernel.org/centos/8-stream/isos/x86_64/"
ISO=`${CURL} --fail --silent "${URL}" | grep --invert-match sha256 | grep --extended-regexp --only-matching --max-count=1 "CentOS\-Stream\-8\-[0-9\.]*\-x86\_64\-boot\.iso" | uniq`
if [ $? != 0 ] || [ "$ISO" == "" ]; then
tput setaf 1; printf "\nThe CentOS 8 stream ISO update failed.\n\n"; tput sgr0
return 1
fi
# Calculate the new URL.
URL="${URL}${ISO}"
# Download the ISO file and calculate the new hash value.
set -o pipefail
SHA=`${CURL} --fail --speed-time 60 --speed-limit 1024 --silent --location "${URL}" | sha256sum | awk -F' ' '{print $1}'`
if [ $? != 0 ] || [ "$SHA" == "" ]; then
tput setaf 1; printf "\nThe CentOS 8 stream ISO update failed.\n\n"; tput sgr0
return 1
fi
set +o pipefail
# Escape the URL strings.
URL=`echo $URL | sed "s/\//\\\\\\\\\//g"`
ISO_URL=`echo $ISO_URL | sed "s/\//\\\\\\\\\//g"`
# Replace the existing ISO and hash values with the update values.
sed --in-place "s/$ISO_URL/$URL/g" $ROBOX_FILES
sed --in-place "s/$ISO_CHECKSUM/sha256:$SHA/g" $ROBOX_FILES
elif [ "$1" == "centos9s" ]; then
# Find the existing CentOS 9 stream URL and hash values.
ISO_URL=`cat "$BASE/packer-cache.json" | jq -r -c ".builders[] | select( .name | contains(\"centos9s\")) | .iso_url" 2>/dev/null`
ISO_CHECKSUM=`cat "$BASE/packer-cache.json" | jq -r -c ".builders[] | select( .name | contains(\"centos9s\")) | .iso_checksum" 2>/dev/null`
# Find the CentOS 9 stream URL.
URL="https://dfw.mirror.rackspace.com/centos-stream/9-stream/BaseOS/x86_64/iso/"
ISO=`${CURL} --fail --silent "${URL}" | grep --invert-match sha256 | grep --extended-regexp --only-matching --max-count=1 "CentOS\-Stream\-9\-[0-9]{8}\.[0-9]\-x86\_64\-boot\.iso" | uniq`
if [ $? != 0 ] || [ "$ISO" == "" ]; then
tput setaf 1; printf "\nThe CentOS 9 stream ISO update failed.\n\n"; tput sgr0
return 1
fi
# Calculate the new URL.
URL="${URL}${ISO}"
# Download the ISO file and calculate the new hash value.
set -o pipefail
SHA=`${CURL} --fail --speed-time 60 --speed-limit 1024 --silent --location "${URL}" | sha256sum | awk -F' ' '{print $1}'`
if [ $? != 0 ] || [ "$SHA" == "" ]; then
tput setaf 1; printf "\nThe CentOS 9 stream ISO update failed.\n\n"; tput sgr0
return 1
fi
set +o pipefail
# Escape the URL strings.
URL=`echo $URL | sed "s/\//\\\\\\\\\//g"`
ISO_URL=`echo $ISO_URL | sed "s/\//\\\\\\\\\//g"`
# Replace the existing ISO and hash values with the update values.
sed --in-place "s/$ISO_URL/$URL/g" $ROBOX_FILES
sed --in-place "s/$ISO_CHECKSUM/sha256:$SHA/g" $ROBOX_FILES
elif [ "$1" == "hardened" ] || [ "$1" == "hardenedbsd" ]; then
# Find the existing HardenedBSD URL and hash values.
ISO_URL=`cat "$BASE/packer-cache.json" | jq -r -c ".builders[] | select( .name | contains(\"hardenedbsd13\")) | .iso_url" 2>/dev/null`
ISO_CHECKSUM=`cat "$BASE/packer-cache.json" | jq -r -c ".builders[] | select( .name | contains(\"hardenedbsd13\")) | .iso_checksum" 2>/dev/null`
# Find the HardenedBSD URL.
# URL="https://installers.hardenedbsd.org/pub/13-stable/amd64/amd64/installer/"
# Alternate server (update in two places).
URL="https://mirror.laylo.io/pub/hardenedbsd/13-stable/amd64/amd64/installer/"
BUILD=`${CURL} --fail --silent "${URL}" | grep --extended-regexp --only-matching "\"build\-[0-9]*/\"" | grep --extended-regexp --only-matching "build\-[0-9]*" | sort -r | uniq | head -1`
if [ $? != 0 ] || [ "$BUILD" == "" ]; then
tput setaf 1; printf "\nThe HardenedBSD ISO update failed.\n\n"; tput sgr0
return 1
fi
# Calculate the new URL.
# URL="https://installers.hardenedbsd.org/pub/13-stable/amd64/amd64/installer/${BUILD}/disc1.iso"
# Alternate server (update in two places).
URL="https://mirror.laylo.io/pub/hardenedbsd/13-stable/amd64/amd64/installer/${BUILD}/disc1.iso"
# Download the ISO file and calculate the new hash value.
set -o pipefail
SHA=`${CURL} --fail --speed-time 60 --speed-limit 1024 --silent --location "${URL}" | sha256sum | awk -F' ' '{print $1}'`
if [ $? != 0 ] || [ "$SHA" == "" ]; then
tput setaf 1; printf "\nThe HardenedBSD ISO update failed.\n\n"; tput sgr0
return 1
fi
set +o pipefail
# Escape the URL strings.
URL=`echo $URL | sed "s/\//\\\\\\\\\//g"`
ISO_URL=`echo $ISO_URL | sed "s/\//\\\\\\\\\//g"`
# Replace the existing ISO and hash values with the update values.
sed --in-place "s/$ISO_URL/$URL/g" $ROBOX_FILES
sed --in-place "s/$ISO_CHECKSUM/sha256:$SHA/g" $ROBOX_FILES
elif [ "$1" == "stream" ] || [ "$1" == "streams" ]; then
iso centos8s
iso centos9s
elif [ "$1" == "all" ]; then
iso arch
iso centos8s
iso centos9s
iso gentoo
iso hardenedbsd
fi
}
function cache {
unset PACKER_LOG ; unset LD_PRELOAD ; unset LD_LIBRARY_PATH ;
if [[ $OS == "Windows_NT" ]]; then
packer.exe build -on-error=cleanup -color=false -parallel-builds=$PACKER_MAX_PROCS -except= packer-cache.json 2>&1 | tr -cs [:print:] [\\n*] | grep --line-buffered --color=none -E "Download progress|Downloading or copying|Found already downloaded|Transferred:|[0-9]*[[:space:]]*items:"
else
packer build -on-error=cleanup -color=false -parallel-builds=$PACKER_MAX_PROCS -except= packer-cache.json 2>&1 | tr -cs [:print:] [\\n*] | grep --line-buffered --color=none -E "Download progress|Downloading or copying|Found already downloaded|Transferred:|[0-9]*[[:space:]]*items:"
fi
if [[ $? != 0 ]]; then
tput setaf 1; tput bold; printf "\n\nDistro disc image download aborted...\n\n"; tput sgr0
else
tput setaf 2; tput bold; printf "\n\nDistro disc images have finished downloading...\n\n"; tput sgr0
fi
}
# Let us know when URLs become valid.
function ready_url {
# Check whether a particular URL has become valid.
${CURL} --fail --silent --location --retry 3 --retry-delay 4 --connect-timeout 60 --max-time 120 --write-out "%{http_code}\n" --output /dev/null "$1" | grep --silent --extended-regexp "200"
if [ $? == 0 ]; then
printf "Link Ready: $1\n"
return 1
fi
}
# Verify all of the URLs are still valid.
function verify_url {
# Grab just the response header and look for the 200 response code to indicate the link is valid.
${CURL} --head --silent --location --retry 3 --retry-delay 4 --connect-timeout 60 --max-time 120 "$1" | grep --extended-regexp "HTTP/1\.1 [0-9]*|HTTP/2\.0 [0-9]*|HTTP/2 [0-9]*" | tail -1 | grep --silent --extended-regexp "HTTP/1\.1 200 OK|HTTP/2\.0 200 OK|HTTP/2 200"
# The grep return code tells us whether it found a match in the header or not.
if [ $? != 0 ]; then
# Wait a minute, and then try again. Many of the failures are transient network errors.
sleep 10; ${CURL} --fail --silent --location --retry 3 --retry-delay 4 --connect-timeout 60 --max-time 120 --write-out "%{http_code}\n" --output /dev/null "$1" | grep --silent --extended-regexp "200"
if [ $? != 0 ]; then
printf "Link Failure: $1\n"
return 1
fi
fi
}
# Verify all of the ISO locations are valid and then download the ISO and verify the hash.
function verify_sum {
# Grab just the response header and look for the 200 response code to indicate the link is valid.
${CURL} --silent --location --head --connect-timeout 60 --max-time 120 "$1" | grep --extended-regexp "HTTP/1\.1 200 OK|HTTP/2\.0 200 OK|HTTP/2 200" | tail -1 | grep --silent --extended-regexp "HTTP/1\.1 200 OK|HTTP/2\.0 200 OK|HTTP/2 200"
# The grep return code tells us whether it found a match in the header or not.
if [ $? != 0 ]; then
printf "Link Failure: $1\n\n"
exit 1
fi
# Grab the ISO and pipe the data through sha256sum, then compare the checksum value.
SUM=`${CURL} --silent --location "$1" | sha256sum | tr -d ' -'`
echo $SUM | grep --silent "$2"
# The grep return code tells us whether we found a checksum match.
if [ $? != 0 ]; then
# Wait a minute, and then try again. Many of the failures are transient network errors.
SUM=`sleep 60; ${CURL} --silent --location "$1" | sha256sum | tr -d ' -'`
echo $SUM | grep --silent "$2"
if [ $? != 0 ]; then
printf "Hash Failure: $1\n"
printf "Found - $SUM\n"
printf "Expected - $2\n\n"
exit 1
fi
fi
printf "Validated : $1\n"
return 0
}
# Validate the templates before building.
function verify_json() {
RESULT=0
unset LD_PRELOAD ; unset LD_LIBRARY_PATH ;
if [[ $OS == "Windows_NT" ]]; then
PACKER="packer.exe"
else
PACKER="packer"
fi
${PACKER} validate $1.json &>/dev/null || \
{ tput setaf 1 ; tput bold ; printf "The $1.json file failed to validate.\n" ; tput sgr0 ; exit 1 ; }
}
# Make sure the logging directory is available. If it isn't, then create it.
function verify_logdir {
if [ ! -d "$BASE/logs/" ]; then
mkdir -p "$BASE/logs/" || mkdir "$BASE/logs"
fi
}
# Check whether a box has been uploaded to the cloud.
function verify_availability() {
local RESULT=0
if [ ! -z ${CURLOPTS+x} ]; then export CURL="${CURL} $(eval echo $CURLOPTS)" ; fi
curltry ${CURL} --head --fail --silent --location --user-agent "${AGENT}" --output /dev/null --max-time 300 --write-out "%{http_code}" "https://vagrantcloud.com/$1/boxes/$2/versions/$4/providers/$3.box" | grep --silent "200"
if [ $? != 0 ]; then
printf "%sBox - %s${1}/${2} ${3}%s \n%s" "`tput sgr0`" "`tput setaf 1`" "`tput sgr0`" "`tput sgr0`"
let RESULT=1
else
STATUS="`curltry ${CURL} --fail --silent --location --user-agent \"${AGENT}\" \"https://app.vagrantup.com/api/v1/box/$1/$2/version/$4\" | jq -r '.status' 2>/dev/null`"
LENGTH="`curltry ${CURL} --head --request GET --fail --silent --location --user-agent \"${AGENT}\" \"https://app.vagrantup.com/$1/boxes/$2/versions/$4/providers/$3.box\" 2>&1 | grep -a 'Content-Length' | awk -F': ' '{print \$2}' | tail -1`"
if [ "$LENGTH" == "0" ]; then
printf "%sBox * %s${1}/${2} ${3}%s \n%s" "`tput sgr0`" "`tput setaf 5`" "`tput sgr0`" "`tput sgr0`"
elif [ "$STATUS" != "active" ]; then