From 604f564d958391fb242c78e3fab4e519dd309bff Mon Sep 17 00:00:00 2001 From: Ladar Levison Date: Mon, 23 Oct 2023 17:47:59 -0500 Subject: [PATCH] Initial FreeBSD 14 config added. --- check/.gitignore | 10 ++ check/check.sh | 11 ++ check/freebsd14.tpl | 45 ++++++++ generic-hyperv-x64.json | 72 ++++++++++++ generic-libvirt-x64.json | 72 ++++++++++++ generic-parallels-x64.json | 107 ++++++++++++++++++ generic-virtualbox-x64.json | 81 ++++++++++++++ generic-vmware-x64.json | 80 ++++++++++++++ http/generic.freebsd14.vagrant.cfg | 62 +++++++++++ packer-cache.json | 15 +++ scripts/common/lockout.sh | 8 +- scripts/common/zerodisk.sh | 6 +- scripts/freebsd14/cleanup.sh | 8 ++ scripts/freebsd14/firstboot.sh | 18 +++ scripts/freebsd14/hostname.sh | 15 +++ scripts/freebsd14/kernel.sh | 19 ++++ scripts/freebsd14/magma.sh | 170 +++++++++++++++++++++++++++++ scripts/freebsd14/motd.sh | 6 + scripts/freebsd14/parallels.sh | 30 +++++ scripts/freebsd14/pkg.sh | 63 +++++++++++ scripts/freebsd14/qemu.sh | 29 +++++ scripts/freebsd14/vagrant.sh | 29 +++++ scripts/freebsd14/virtualbox.sh | 38 +++++++ scripts/freebsd14/vmware.sh | 35 ++++++ tpl/generic-freebsd14.rb | 63 +++++++++++ tpl/roboxes-freebsd14.rb | 63 +++++++++++ 26 files changed, 1148 insertions(+), 7 deletions(-) create mode 100644 check/freebsd14.tpl create mode 100644 http/generic.freebsd14.vagrant.cfg create mode 100644 scripts/freebsd14/cleanup.sh create mode 100644 scripts/freebsd14/firstboot.sh create mode 100644 scripts/freebsd14/hostname.sh create mode 100644 scripts/freebsd14/kernel.sh create mode 100644 scripts/freebsd14/magma.sh create mode 100644 scripts/freebsd14/motd.sh create mode 100644 scripts/freebsd14/parallels.sh create mode 100644 scripts/freebsd14/pkg.sh create mode 100644 scripts/freebsd14/qemu.sh create mode 100644 scripts/freebsd14/vagrant.sh create mode 100644 scripts/freebsd14/virtualbox.sh create mode 100644 scripts/freebsd14/vmware.sh create mode 100644 tpl/generic-freebsd14.rb create mode 100644 tpl/roboxes-freebsd14.rb diff --git a/check/.gitignore b/check/.gitignore index d73e5a31c..c710997f3 100644 --- a/check/.gitignore +++ b/check/.gitignore @@ -259,6 +259,11 @@ generic-freebsd13-libvirt/ generic-freebsd13-parallels/ generic-freebsd13-virtualbox/ generic-freebsd13-vmware/ +generic-freebsd14-hyperv/ +generic-freebsd14-libvirt/ +generic-freebsd14-parallels/ +generic-freebsd14-virtualbox/ +generic-freebsd14-vmware/ generic-gentoo-hyperv/ generic-gentoo-libvirt/ generic-gentoo-parallels/ @@ -1081,6 +1086,11 @@ roboxes-freebsd13-libvirt/ roboxes-freebsd13-parallels/ roboxes-freebsd13-virtualbox/ roboxes-freebsd13-vmware/ +roboxes-freebsd14-hyperv/ +roboxes-freebsd14-libvirt/ +roboxes-freebsd14-parallels/ +roboxes-freebsd14-virtualbox/ +roboxes-freebsd14-vmware/ roboxes-gentoo-hyperv/ roboxes-gentoo-libvirt/ roboxes-gentoo-parallels/ diff --git a/check/check.sh b/check/check.sh index 31d8cf755..65400b886 100755 --- a/check/check.sh +++ b/check/check.sh @@ -370,6 +370,7 @@ function generic-virtualbox() { O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd11" ); P=( "${P[@]}" "virtualbox" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd12" ); P=( "${P[@]}" "virtualbox" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd13" ); P=( "${P[@]}" "virtualbox" ); + O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd14" ); P=( "${P[@]}" "virtualbox" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "gentoo" ); P=( "${P[@]}" "virtualbox" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "hardenedbsd11" ); P=( "${P[@]}" "virtualbox" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "hardenedbsd12" ); P=( "${P[@]}" "virtualbox" ); @@ -469,6 +470,7 @@ function generic-libvirt() { O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd11" ); P=( "${P[@]}" "libvirt" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd12" ); P=( "${P[@]}" "libvirt" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd13" ); P=( "${P[@]}" "libvirt" ); + O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd14" ); P=( "${P[@]}" "libvirt" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "gentoo" ); P=( "${P[@]}" "libvirt" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "hardenedbsd11" ); P=( "${P[@]}" "libvirt" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "hardenedbsd12" ); P=( "${P[@]}" "libvirt" ); @@ -568,6 +570,7 @@ function generic-vmware() { O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd11" ); P=( "${P[@]}" "vmware" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd12" ); P=( "${P[@]}" "vmware" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd13" ); P=( "${P[@]}" "vmware" ); + O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd14" ); P=( "${P[@]}" "vmware" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "gentoo" ); P=( "${P[@]}" "vmware" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "hardenedbsd11" ); P=( "${P[@]}" "vmware" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "hardenedbsd12" ); P=( "${P[@]}" "vmware" ); @@ -668,6 +671,7 @@ function generic-hyperv() { O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd11" ); P=( "${P[@]}" "hyperv" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd12" ); P=( "${P[@]}" "hyperv" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd13" ); P=( "${P[@]}" "hyperv" ); + O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd14" ); P=( "${P[@]}" "hyperv" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "gentoo" ); P=( "${P[@]}" "hyperv" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "hardenedbsd11" ); P=( "${P[@]}" "hyperv" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "hardenedbsd12" ); P=( "${P[@]}" "hyperv" ); @@ -771,6 +775,7 @@ function generic-parallels() { O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd11" ); P=( "${P[@]}" "parallels" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd12" ); P=( "${P[@]}" "parallels" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd13" ); P=( "${P[@]}" "parallels" ); + O=( "${O[@]}" "generic" ); B=( "${B[@]}" "freebsd14" ); P=( "${P[@]}" "parallels" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "gentoo" ); P=( "${P[@]}" "parallels" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "hardenedbsd11" ); P=( "${P[@]}" "parallels" ); O=( "${O[@]}" "generic" ); B=( "${B[@]}" "hardenedbsd12" ); P=( "${P[@]}" "parallels" ); @@ -873,6 +878,7 @@ function robox-virtualbox() { O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd11" ); P=( "${P[@]}" "virtualbox" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd12" ); P=( "${P[@]}" "virtualbox" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd13" ); P=( "${P[@]}" "virtualbox" ); + O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd14" ); P=( "${P[@]}" "virtualbox" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "gentoo" ); P=( "${P[@]}" "virtualbox" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "hardenedbsd11" ); P=( "${P[@]}" "virtualbox" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "hardenedbsd12" ); P=( "${P[@]}" "virtualbox" ); @@ -972,6 +978,7 @@ function robox-libvirt() { O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd11" ); P=( "${P[@]}" "libvirt" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd12" ); P=( "${P[@]}" "libvirt" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd13" ); P=( "${P[@]}" "libvirt" ); + O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd14" ); P=( "${P[@]}" "libvirt" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "gentoo" ); P=( "${P[@]}" "libvirt" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "hardenedbsd11" ); P=( "${P[@]}" "libvirt" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "hardenedbsd12" ); P=( "${P[@]}" "libvirt" ); @@ -1071,6 +1078,7 @@ function robox-vmware() { O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd11" ); P=( "${P[@]}" "vmware" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd12" ); P=( "${P[@]}" "vmware" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd13" ); P=( "${P[@]}" "vmware" ); + O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd14" ); P=( "${P[@]}" "vmware" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "gentoo" ); P=( "${P[@]}" "vmware" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "hardenedbsd11" ); P=( "${P[@]}" "vmware" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "hardenedbsd12" ); P=( "${P[@]}" "vmware" ); @@ -1171,6 +1179,7 @@ function robox-hyperv() { O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd11" ); P=( "${P[@]}" "hyperv" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd12" ); P=( "${P[@]}" "hyperv" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd13" ); P=( "${P[@]}" "hyperv" ); + O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd14" ); P=( "${P[@]}" "hyperv" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "gentoo" ); P=( "${P[@]}" "hyperv" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "hardenedbsd11" ); P=( "${P[@]}" "hyperv" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "hardenedbsd12" ); P=( "${P[@]}" "hyperv" ); @@ -1274,6 +1283,7 @@ function robox-parallels() { O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd11" ); P=( "${P[@]}" "parallels" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd12" ); P=( "${P[@]}" "parallels" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd13" ); P=( "${P[@]}" "parallels" ); + O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "freebsd14" ); P=( "${P[@]}" "parallels" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "gentoo" ); P=( "${P[@]}" "parallels" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "hardenedbsd11" ); P=( "${P[@]}" "parallels" ); O=( "${O[@]}" "roboxes" ); B=( "${B[@]}" "hardenedbsd12" ); P=( "${P[@]}" "parallels" ); @@ -1733,6 +1743,7 @@ function cleanup() { rm --recursive --force $BASE/{generic,roboxes}-freebsd11-{hyperv,libvirt,parallels,virtualbox,vmware} rm --recursive --force $BASE/{generic,roboxes}-freebsd12-{hyperv,libvirt,parallels,virtualbox,vmware} rm --recursive --force $BASE/{generic,roboxes}-freebsd13-{hyperv,libvirt,parallels,virtualbox,vmware} + rm --recursive --force $BASE/{generic,roboxes}-freebsd14-{hyperv,libvirt,parallels,virtualbox,vmware} rm --recursive --force $BASE/{generic,roboxes}-gentoo-{hyperv,libvirt,parallels,virtualbox,vmware} rm --recursive --force $BASE/{generic,roboxes}-hardenedbsd11-{hyperv,libvirt,parallels,virtualbox,vmware} rm --recursive --force $BASE/{generic,roboxes}-hardenedbsd12-{hyperv,libvirt,parallels,virtualbox,vmware} diff --git a/check/freebsd14.tpl b/check/freebsd14.tpl new file mode 100644 index 000000000..4c6437792 --- /dev/null +++ b/check/freebsd14.tpl @@ -0,0 +1,45 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure(2) do |config| + + config.ssh.shell = 'sh' + config.vm.box = "generic/freebsd14" + config.vm.network :private_network, :auto_config => false, :autostart => false, :libvirt__network_name => "vagrant-libvirt", :libvirt__always_destroy => false + + config.vm.provider :libvirt do |v, override| + v.qemu_use_session = false + v.video_vram = 256 + v.memory = 2048 + v.cpus = 2 + v.management_network_name = "vagrant-libvirt" + v.management_network_keep = true + v.management_network_autostart = false + v.nic_model_type = "e1000" + end + + config.vm.provider :hyperv do |v, override| + v.maxmemory = 2048 + v.memory = 2048 + v.cpus = 2 + end + + config.vm.provider :virtualbox do |v, override| + v.gui = false + v.functional_vboxsf = false + v.check_guest_additions = false + v.customize ["modifyvm", :id, "--memory", 2048] + v.customize ["modifyvm", :id, "--cpus", 2] + end + + ["vmware_fusion", "vmware_workstation", "vmware_desktop"].each do |provider| + config.vm.provider provider do |v, override| + v.gui = false + v.functional_hgfs = false + v.vmx["memsize"] = "2048" + v.vmx["numvcpus"] = "2" + v.vmx["cpuid.coresPerSocket"] = "1" + end + end + +end diff --git a/generic-hyperv-x64.json b/generic-hyperv-x64.json index 9c93dd2cd..1139278c6 100644 --- a/generic-hyperv-x64.json +++ b/generic-hyperv-x64.json @@ -3300,6 +3300,29 @@ "generic-ubuntu2310-hyperv-x64" ] }, + { + "type": "shell", + "timeout": "120m", + "scripts": [ + "scripts/freebsd14/pkg.sh", + "scripts/freebsd14/hostname.sh", + "scripts/freebsd14/kernel.sh", + "scripts/freebsd14/firstboot.sh", + "scripts/freebsd14/motd.sh", + "scripts/freebsd14/vagrant.sh", + "scripts/freebsd14/virtualbox.sh", + "scripts/freebsd14/parallels.sh", + "scripts/freebsd14/vmware.sh", + "scripts/freebsd14/qemu.sh", + "scripts/freebsd14/cleanup.sh" + ], + "start_retry_timeout": "45m", + "expect_disconnect": "true", + "execute_command": "{{.Vars}} /usr/local/bin/bash {{ .Path }}", + "only": [ + "generic-freebsd14-hyperv-x64" + ] + }, { "type": "shell", "timeout": "120m", @@ -7212,6 +7235,55 @@ "enable_dynamic_memory": false, "guest_additions_mode": "disable", "enable_virtualization_extensions": false + }, + { + "type": "hyperv-iso", + "name": "generic-freebsd14-hyperv-x64", + "vm_name": "generic-freebsd14-hyperv-x64", + "temp_path": "output/", + "output_directory": "output/generic-freebsd14-hyperv-x64", + "boot_wait": "1s", + "boot_keygroup_interval": "1s", + "boot_command": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "boot -s", + "", + "/bin/sh", + "mdmfs -s 100m md1 /tmp", + "mdmfs -s 100m md2 /mnt", + "dhclient -l /tmp/dhclient.lease.hn0 hn0", + "fetch -o /tmp/installerconfig http://{{ .HTTPIP }}:{{ .HTTPPort }}/generic.freebsd14.vagrant.cfg", + "bsdinstall script /tmp/installerconfig && reboot" + ], + "disk_size": 131072, + "memory": 2048, + "cpus": 2, + "http_directory": "http", + "iso_url": "http://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/14.0/FreeBSD-14.0-RC2-amd64-disc1.iso", + "iso_checksum": "sha256:743a6015fe1b9525343fb4b9ce1abba8727ca58d230372ce66f8a4b592cfafb4", + "ssh_username": "root", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_handshake_attempts": 1000, + "ssh_timeout": "7200s", + "shutdown_command": "shutdown -p now", + "generation": 1, + "headless": true, + "communicator": "ssh", + "skip_compaction": false, + "enable_secure_boot": false, + "enable_mac_spoofing": false, + "enable_dynamic_memory": false, + "guest_additions_mode": "disable", + "enable_virtualization_extensions": false } ], "post-processors": [ diff --git a/generic-libvirt-x64.json b/generic-libvirt-x64.json index ef4d5fc31..a7ce450d6 100644 --- a/generic-libvirt-x64.json +++ b/generic-libvirt-x64.json @@ -3300,6 +3300,29 @@ "generic-ubuntu2310-libvirt-x64" ] }, + { + "scripts": [ + "scripts/freebsd14/pkg.sh", + "scripts/freebsd14/hostname.sh", + "scripts/freebsd14/kernel.sh", + "scripts/freebsd14/firstboot.sh", + "scripts/freebsd14/motd.sh", + "scripts/freebsd14/vagrant.sh", + "scripts/freebsd14/virtualbox.sh", + "scripts/freebsd14/parallels.sh", + "scripts/freebsd14/vmware.sh", + "scripts/freebsd14/qemu.sh", + "scripts/freebsd14/cleanup.sh" + ], + "type": "shell", + "timeout": "120m", + "start_retry_timeout": "15m", + "expect_disconnect": "true", + "execute_command": "{{.Vars}} /usr/local/bin/bash {{ .Path }}", + "only": [ + "generic-freebsd14-libvirt-x64" + ] + }, { "scripts": [ "scripts/common/motd.sh", @@ -7198,6 +7221,55 @@ "ssh_handshake_attempts": 1000, "ssh_timeout": "3600s", "shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now" + }, + { + "type": "qemu", + "name": "generic-freebsd14-libvirt-x64", + "vm_name": "generic-freebsd14-libvirt-x64", + "output_directory": "output/generic-freebsd14-libvirt-x64", + "qemu_binary": "qemu-system-x86_64", + "boot_wait": "1s", + "boot_keygroup_interval": "1s", + "boot_command": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "boot -s", + "", + "/bin/sh", + "mdmfs -s 100m md1 /tmp", + "mdmfs -s 100m md2 /mnt", + "dhclient -l /tmp/dhclient.lease.vtnet0 vtnet0", + "fetch -o /tmp/installerconfig http://{{ .HTTPIP }}:{{ .HTTPPort }}/generic.freebsd14.vagrant.cfg", + "bsdinstall script /tmp/installerconfig && reboot" + ], + "format": "qcow2", + "disk_size": "131072", + "disk_discard": "unmap", + "disk_detect_zeroes": "on", + "disk_cache": "unsafe", + "disk_image": false, + "disk_compression": true, + "disk_interface": "virtio-scsi", + "net_device": "virtio-net", + "cpus": 2, + "memory": 2048, + "http_directory": "http", + "headless": true, + "iso_url": "http://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/14.0/FreeBSD-14.0-RC2-amd64-disc1.iso", + "iso_checksum": "sha256:743a6015fe1b9525343fb4b9ce1abba8727ca58d230372ce66f8a4b592cfafb4", + "ssh_username": "root", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_handshake_attempts": 1000, + "ssh_timeout": "3600s", + "shutdown_command": "shutdown -p now" } ], "post-processors": [ diff --git a/generic-parallels-x64.json b/generic-parallels-x64.json index 980a2da9c..e6c51e596 100644 --- a/generic-parallels-x64.json +++ b/generic-parallels-x64.json @@ -3242,6 +3242,29 @@ "generic-ubuntu2310-parallels-x64" ] }, + { + "scripts": [ + "scripts/freebsd14/pkg.sh", + "scripts/freebsd14/hostname.sh", + "scripts/freebsd14/kernel.sh", + "scripts/freebsd14/firstboot.sh", + "scripts/freebsd14/motd.sh", + "scripts/freebsd14/vagrant.sh", + "scripts/freebsd14/virtualbox.sh", + "scripts/freebsd14/parallels.sh", + "scripts/freebsd14/vmware.sh", + "scripts/freebsd14/qemu.sh", + "scripts/freebsd14/cleanup.sh" + ], + "type": "shell", + "timeout": "120m", + "start_retry_timeout": "45m", + "expect_disconnect": "true", + "execute_command": "{{.Vars}} /usr/local/bin/bash {{ .Path }}", + "only": [ + "generic-freebsd14-parallels-x64" + ] + }, { "scripts": [ "scripts/common/motd.sh", @@ -9755,6 +9778,90 @@ "parallels_tools_mode": "upload", "parallels_tools_guest_path": "/root/parallels-tools-linux.iso", "prlctl_version_file": "/root/parallels-tools-version.txt" + }, + { + "type": "parallels-iso", + "name": "generic-freebsd14-parallels-x64", + "vm_name": "generic-freebsd14-parallels-x64", + "output_directory": "output/generic-freebsd14-parallels-x64", + "boot_wait": "1s", + "boot_keygroup_interval": "1s", + "boot_command": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "boot -s", + "", + "/bin/sh", + "mdmfs -s 100m md1 /tmp", + "mdmfs -s 100m md2 /mnt", + "dhclient -l /tmp/dhclient.lease.em0 em0", + "fetch -o /tmp/installerconfig http://{{ .HTTPIP }}:{{ .HTTPPort }}/generic.freebsd14.vagrant.cfg", + "bsdinstall script /tmp/installerconfig && reboot" + ], + "disk_size": 32768, + "cpus": 2, + "memory": 2048, + "prlctl": [ + [ + "set", + "{{.Name}}", + "--adaptive-hypervisor", + "on" + ], + [ + "set", + "{{.Name}}", + "--3d-accelerate", + "off" + ], + [ + "set", + "{{.Name}}", + "--videosize", + "16" + ], + [ + "set", + "{{.Name}}", + "--pmu-virt", + "on" + ], + [ + "set", + "{{.Name}}", + "--faster-vm", + "on" + ], + [ + "set", + "{{.Name}}", + "--efi-boot", + "on" + ] + ], + "hard_drive_interface": "ide", + "guest_os_type": "freebsd", + "skip_compaction": false, + "http_directory": "http", + "iso_url": "http://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/14.0/FreeBSD-14.0-RC2-amd64-disc1.iso", + "iso_checksum": "sha256:743a6015fe1b9525343fb4b9ce1abba8727ca58d230372ce66f8a4b592cfafb4", + "ssh_username": "root", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_handshake_attempts": 1000, + "ssh_timeout": "3600s", + "shutdown_command": "shutdown -p now", + "parallels_tools_flavor": "other", + "parallels_tools_mode": "upload", + "parallels_tools_guest_path": "/root/parallels-tools-other.iso", + "prlctl_version_file": "/root/parallels-tools-version.txt" } ], "post-processors": [ diff --git a/generic-virtualbox-x64.json b/generic-virtualbox-x64.json index 6b108b497..f4a21a450 100644 --- a/generic-virtualbox-x64.json +++ b/generic-virtualbox-x64.json @@ -3250,6 +3250,29 @@ "generic-ubuntu2310-virtualbox-x64" ] }, + { + "scripts": [ + "scripts/freebsd14/pkg.sh", + "scripts/freebsd14/hostname.sh", + "scripts/freebsd14/kernel.sh", + "scripts/freebsd14/firstboot.sh", + "scripts/freebsd14/motd.sh", + "scripts/freebsd14/vagrant.sh", + "scripts/freebsd14/virtualbox.sh", + "scripts/freebsd14/parallels.sh", + "scripts/freebsd14/vmware.sh", + "scripts/freebsd14/qemu.sh", + "scripts/freebsd14/cleanup.sh" + ], + "type": "shell", + "timeout": "120m", + "start_retry_timeout": "15m", + "expect_disconnect": "true", + "execute_command": "{{.Vars}} /usr/local/bin/bash {{ .Path }}", + "only": [ + "generic-freebsd14-virtualbox-x64" + ] + }, { "scripts": [ "scripts/common/motd.sh", @@ -8030,6 +8053,64 @@ "guest_additions_path": "VBoxGuestAdditions.iso", "guest_additions_mode": "upload", "virtualbox_version_file": "VBoxVersion.txt" + }, + { + "type": "virtualbox-iso", + "name": "generic-freebsd14-virtualbox-x64", + "vm_name": "generic-freebsd14-virtualbox-x64", + "output_directory": "output/generic-freebsd14-virtualbox-x64", + "boot_wait": "1s", + "boot_keygroup_interval": "1s", + "boot_command": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "boot -s", + "", + "/bin/sh", + "mdmfs -s 100m md1 /tmp", + "mdmfs -s 100m md2 /mnt", + "dhclient -l /tmp/dhclient.lease.em0 em0", + "fetch -o /tmp/installerconfig http://{{ .HTTPIP }}:{{ .HTTPPort }}/generic.freebsd14.vagrant.cfg", + "bsdinstall script /tmp/installerconfig && reboot" + ], + "disk_size": 131072, + "cpus": 2, + "memory": 2048, + "vboxmanage": [ + [ + "modifyvm", + "{{.Name}}", + "--vram", + "64" + ] + ], + "hard_drive_interface": "sata", + "guest_os_type": "FreeBSD_64", + "http_directory": "http", + "headless": true, + "vrdp_bind_address": "127.0.0.1", + "vrdp_port_min": 11000, + "vrdp_port_max": 12000, + "iso_url": "http://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/14.0/FreeBSD-14.0-RC2-amd64-disc1.iso", + "iso_checksum": "sha256:743a6015fe1b9525343fb4b9ce1abba8727ca58d230372ce66f8a4b592cfafb4", + "ssh_username": "root", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_handshake_attempts": 1000, + "ssh_timeout": "3600s", + "shutdown_command": "shutdown -p now", + "guest_additions_url": "https://download.virtualbox.org/virtualbox/5.2.44/VBoxGuestAdditions_5.2.44.iso", + "guest_additions_sha256": "9883ee443a309f4ffa1d5dee2833f9e35ced598686c36d159f410e5edbac1ca4", + "guest_additions_path": "VBoxGuestAdditions.iso", + "guest_additions_mode": "upload", + "virtualbox_version_file": "VBoxVersion.txt" } ], "post-processors": [ diff --git a/generic-vmware-x64.json b/generic-vmware-x64.json index 37d879ce7..2f4f80f24 100644 --- a/generic-vmware-x64.json +++ b/generic-vmware-x64.json @@ -3250,6 +3250,29 @@ "generic-ubuntu2310-vmware-x64" ] }, + { + "scripts": [ + "scripts/freebsd14/pkg.sh", + "scripts/freebsd14/hostname.sh", + "scripts/freebsd14/kernel.sh", + "scripts/freebsd14/firstboot.sh", + "scripts/freebsd14/motd.sh", + "scripts/freebsd14/vagrant.sh", + "scripts/freebsd14/virtualbox.sh", + "scripts/freebsd14/parallels.sh", + "scripts/freebsd14/vmware.sh", + "scripts/freebsd14/qemu.sh", + "scripts/freebsd14/cleanup.sh" + ], + "type": "shell", + "timeout": "120m", + "start_retry_timeout": "15m", + "expect_disconnect": "true", + "execute_command": "{{.Vars}} /usr/local/bin/bash {{ .Path }}", + "only": [ + "generic-freebsd14-vmware-x64" + ] + }, { "scripts": [ "scripts/common/motd.sh", @@ -7926,6 +7949,63 @@ "ssh_timeout": "3600s", "shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now", "tools_upload_flavor": "linux" + }, + { + "type": "vmware-iso", + "name": "generic-freebsd14-vmware-x64", + "vm_name": "generic-freebsd14-vmware-x64", + "vmdk_name": "generic-freebsd14-vmware-x64", + "output_directory": "output/generic-freebsd14-vmware-x64", + "boot_wait": "1s", + "boot_keygroup_interval": "1s", + "boot_command": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "boot -s", + "", + "/bin/sh", + "mdmfs -s 100m md1 /tmp", + "mdmfs -s 100m md2 /mnt", + "dhclient -l /tmp/dhclient.lease.em0 em0", + "fetch -o /tmp/installerconfig http://{{ .HTTPIP }}:{{ .HTTPPort }}/generic.freebsd14.vagrant.cfg", + "bsdinstall script /tmp/installerconfig && reboot" + ], + "disk_size": 131072, + "disk_type_id": "0", + "cpus": 2, + "memory": 2048, + "version": "12", + "vmx_data_post": { + "virtualHW.version": "12", + "cleanShutdown": "TRUE", + "softPowerOff": "FALSE", + "ethernet0.virtualDev": "e1000", + "ethernet0.startConnected": "TRUE", + "ethernet0.wakeonpcktrcv": "false" + }, + "guest_os_type": "freebsd-64", + "skip_compaction": false, + "http_directory": "http", + "headless": true, + "vnc_disable_password": true, + "vnc_bind_address": "127.0.0.1", + "vmx_remove_ethernet_interfaces": true, + "iso_url": "http://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/14.0/FreeBSD-14.0-RC2-amd64-disc1.iso", + "iso_checksum": "sha256:743a6015fe1b9525343fb4b9ce1abba8727ca58d230372ce66f8a4b592cfafb4", + "ssh_username": "root", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_handshake_attempts": 1000, + "ssh_timeout": "3600s", + "shutdown_command": "shutdown -p now", + "tools_upload_flavor": "freebsd" } ], "post-processors": [ diff --git a/http/generic.freebsd14.vagrant.cfg b/http/generic.freebsd14.vagrant.cfg new file mode 100644 index 000000000..88e9114b3 --- /dev/null +++ b/http/generic.freebsd14.vagrant.cfg @@ -0,0 +1,62 @@ +if [ -e /dev/vtbd0 ]; then + PARTITIONS="vtbd0 gpt" +elif [ -e /dev/ada0 ]; then + PARTITIONS="ada0 gpt" +elif [ -e /dev/da0 ]; then + PARTITIONS="da0 gpt" +else + echo "ERROR: There is no disk available for installation" >&2 + exit 1 +fi + +FETCH_RETRY=5 +FETCH_TIMEOUT=30 +HOSTNAME=freebsd14.localdomain + +# Workaround for https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203777 +export nonInteractive="YES" + +#!/bin/sh +if [ -e /dev/vtbd0 ]; then + gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 vtbd0 +elif [ -e /dev/ada0 ]; then + gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0 +elif [ -e /dev/da0 ]; then + gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 da0 +fi + +cat <<-EOF > /etc/resolv.conf +nameserver 4.2.2.1 +nameserver 4.2.2.2 +nameserver 208.67.220.220 +EOF + +ASSUME_ALWAYS_YES=yes FETCH_RETRY=5 pkg install sed +ASSUME_ALWAYS_YES=yes FETCH_RETRY=5 pkg install curl +ASSUME_ALWAYS_YES=yes FETCH_RETRY=5 pkg install sudo +ASSUME_ALWAYS_YES=yes FETCH_RETRY=5 pkg install bash + +INTERFACE=$(route get default | awk '/interface/ { print $2 }') +cat <<-EOF > /etc/rc.conf +ifconfig_DEFAULT="SYNCDHCP" +ifconfig_${INTERFACE}="SYNCDHCP" +ipv6_network_interfaces="none" +sshd_enable="YES" +EOF + +echo 'vagrant' | pw useradd vagrant -h 0 -m +echo 'vagrant' | pw usermod root -h 0 + +cat <<-EOF > /usr/local/etc/sudoers.d/vagrant +Defaults:vagrant !requiretty +vagrant ALL=(ALL) NOPASSWD: ALL +EOF +chmod 440 /usr/local/etc/sudoers.d/vagrant + +sed -i "" -e "s/.*UseDNS.*/UseDNS no/g" /etc/ssh/sshd_config +sed -i "" -e "s/.*PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config + +chsh -s bash root +chsh -s bash vagrant + +reboot diff --git a/packer-cache.json b/packer-cache.json index bf18be276..7b775c2a9 100644 --- a/packer-cache.json +++ b/packer-cache.json @@ -1560,6 +1560,21 @@ "ssh_username": "root", "type": "vmware-iso" }, + { + "name": "freebsd14-x64", + "output_directory": "output/freebsd14-x64", + "iso_url": "http://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/14.0/FreeBSD-14.0-RC2-amd64-disc1.iso", + "iso_checksum": "sha256:743a6015fe1b9525343fb4b9ce1abba8727ca58d230372ce66f8a4b592cfafb4", + "boot_wait": "5s", + "disk_size": 1, + "headless": true, + "shutdown_command": "poweroff", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_timeout": "10s", + "ssh_username": "root", + "type": "vmware-iso" + }, { "name": "virtualbox-7-0-2", "output_directory": "output/virtualbox-7-0-2", diff --git a/scripts/common/lockout.sh b/scripts/common/lockout.sh index 51b270368..1c767d24c 100644 --- a/scripts/common/lockout.sh +++ b/scripts/common/lockout.sh @@ -1,23 +1,23 @@ #!/bin/bash -eux # Randomize the root password and then lock the root account. -if [[ "$PACKER_BUILD_NAME" =~ ^(generic|magma)-(freebsd1[1-3]|hardenedbsd|hardenedbsd1[1-3]|openbsd[6-7])-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64)$ ]]; then +if [[ "$PACKER_BUILD_NAME" =~ ^(generic|magma)-(freebsd1[1-4]|hardenedbsd|hardenedbsd1[1-3]|openbsd[6-7])-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64|a32|p64|p32|m64|m32)$ ]]; then LOCKPWD=`dd if=/dev/urandom count=128 msgfmt=quiet | md5 | awk -F' ' '{print $1}'` printf "$LOCKPWD\n$LOCKPWD\n" | passwd root -elif [[ "$PACKER_BUILD_NAME" =~ ^(generic|magma)-(dragonflybsd[5-6]?)-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64)$ ]]; then +elif [[ "$PACKER_BUILD_NAME" =~ ^(generic|magma)-(dragonflybsd[5-6]?)-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64|a32|p64|p32|m64|m32)$ ]]; then LOCKPWD=`dd if=/dev/urandom count=128 status=value | md5 | awk -F' ' '{print $1}'` echo "$LOCKPWD" | pw mod user root -h 0 pwd_mkdb /etc/master.passwd -elif [[ "$PACKER_BUILD_NAME" =~ ^(generic|magma)-(netbsd[8-9])-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64)$ ]]; then +elif [[ "$PACKER_BUILD_NAME" =~ ^(generic|magma)-(netbsd[8-9])-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64|a32|p64|p32|m64|m32)$ ]]; then LOCKPWD=`dd if=/dev/urandom count=128 msgfmt=quiet | md5 | awk -F' ' '{print $1}'` /usr/sbin/user mod -p "`pwhash $LOCKPWD`" root -elif [[ "$PACKER_BUILD_NAME" =~ ^(generic|magma)-(alpine3[5-9]|alpine31[0-8])-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64)$ ]]; then +elif [[ "$PACKER_BUILD_NAME" =~ ^(generic|magma)-(alpine3[5-9]|alpine31[0-8])-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64|a32|p64|p32|m64|m32)$ ]]; then LOCKPWD=`dd if=/dev/urandom count=128 status=none | md5sum | awk -F' ' '{print $1}'` printf "$LOCKPWD\n$LOCKPWD\n" | passwd root diff --git a/scripts/common/zerodisk.sh b/scripts/common/zerodisk.sh index 32f2b59a3..310b782dd 100644 --- a/scripts/common/zerodisk.sh +++ b/scripts/common/zerodisk.sh @@ -1,6 +1,6 @@ #!/bin/bash -ux -if [[ "$PACKER_BUILD_NAME" =~ ^(generic|magma)-(freebsd1[1-3]|hardenedbsd|hardenedbsd1[1-3]|openbsd[6-7]|alpine3[5-9]|alpine31[0-8])-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64)$ ]]; then +if [[ "$PACKER_BUILD_NAME" =~ ^(generic|magma)-(freebsd1[1-4]|hardenedbsd|hardenedbsd1[1-3]|openbsd[6-7]|alpine3[5-9]|alpine31[0-8])-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64|a32|p64|p32|m64|m32)$ ]]; then # We fill until full so don't abort on error. # set -ux @@ -17,14 +17,14 @@ if [[ "$PACKER_BUILD_NAME" =~ ^(generic|magma)-(freebsd1[1-3]|hardenedbsd|harden rm -f /boot/zerofill fi -elif [[ "$PACKER_BUILD_NAME" =~ ^(generic|magma)-(netbsd[8-9])-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64)$ ]]; then +elif [[ "$PACKER_BUILD_NAME" =~ ^(generic|magma)-(netbsd[8-9])-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64|a32|p64|p32|m64|m32)$ ]]; then # Whiteout root dd if=/dev/zero of=/zerofill bs=8192 sync -f /zerofill rm -f /zerofill -elif [[ "$PACKER_BUILD_NAME" =~ ^(generic|magma)-(dragonflybsd[5-6]?)-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64)$ ]]; then +elif [[ "$PACKER_BUILD_NAME" =~ ^(generic|magma)-(dragonflybsd[5-6]?)-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64|a32|p64|p32|m64|m32)$ ]]; then AVAIL=`df -m / | tail -1 | awk -F' ' '{print $4}'` let FILL=${AVAIL}-256 diff --git a/scripts/freebsd14/cleanup.sh b/scripts/freebsd14/cleanup.sh new file mode 100644 index 000000000..4aa092839 --- /dev/null +++ b/scripts/freebsd14/cleanup.sh @@ -0,0 +1,8 @@ +#!/bin/bash -eux + +# Remove orphans. +pkg-static autoremove --yes + +# Clean the package cache. +pkg-static clean --yes --all +rm -f /var/db/pkg/repo-FreeBSD.sqlite diff --git a/scripts/freebsd14/firstboot.sh b/scripts/freebsd14/firstboot.sh new file mode 100644 index 000000000..608e4eb2c --- /dev/null +++ b/scripts/freebsd14/firstboot.sh @@ -0,0 +1,18 @@ +#!/bin/bash -eux + +# Configure fetch so it retries temporary failures. +export FETCH_RETRY=5 +export FETCH_TIMEOUT=30 +export ASSUME_ALWAYS_YES=yes + +# Uncomment to Enable automatic updating during the first boot. +# pkg add -i firstboot_freebsd_update +# sysrc firstboot_freebsd_update=NO + +pkg-static install -y firstboot-pkgs + +sysrc firstboot_growfs_enable=YES +sysrc firstboot_pkgs_enable=YES + +# Tell the system the next boot will be the first boot. +touch /firstboot diff --git a/scripts/freebsd14/hostname.sh b/scripts/freebsd14/hostname.sh new file mode 100644 index 000000000..d38355ccd --- /dev/null +++ b/scripts/freebsd14/hostname.sh @@ -0,0 +1,15 @@ +#!/bin/bash -eux + +if [[ "$PACKER_BUILD_NAME" =~ ^magma-freebsd14-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64|a32|p64|p32|m64|m32)$ ]]; then + sed -i "" -e "s/hostname=\".*\"/hostname=\"magma.localdomain\"/g" /etc/defaults/rc.conf + printf "\n127.0.0.1 magma magma.localdomain\n" >> /etc/hosts + hostname magma.localdomain +elif [[ "$PACKER_BUILD_NAME" =~ ^generic-freebsd14-(vmware|hyperv|libvirt|parallels|virtualbox)-(x64|x32|a64|a32|p64|p32|m64|m32)$ ]]; then + sed -i "" -e "s/hostname=\".*\"/hostname=\"freebsd14.localdomain\"/g" /etc/defaults/rc.conf + printf "\n127.0.0.1 freebsd14 freebsd14.localdomain\n" >> /etc/hosts + hostname freebsd14.localdomain +else + sed -i "" -e "s/hostname=\".*\"/hostname=\"bazinga.localdomain\"/g" /etc/defaults/rc.conf + printf "\n127.0.0.1 bazinga bazinga.localdomain\n" >> /etc/hosts + hostname bazinga.localdomain +fi diff --git a/scripts/freebsd14/kernel.sh b/scripts/freebsd14/kernel.sh new file mode 100644 index 000000000..dfd976271 --- /dev/null +++ b/scripts/freebsd14/kernel.sh @@ -0,0 +1,19 @@ +#!/bin/bash -eux + +# Disable jemalloc debugging. +ln -sf 'abort:false,junk:false' /etc/malloc.conf + +# Disable crash dumps. +sysrc dumpdev="NO" + +# Boot faster. +echo 'autoboot_delay="-1"' >> /boot/loader.conf + +# Disabling beastie boot screen. +echo 'beastie_disable="YES"' >> /boot/loader.conf +echo 'kern.hz=50' >> /boot/loader.conf + +# Skip the panic screen during reboots. +echo 'debug.trace_on_panic=1' >> /etc/sysctl.conf +echo 'debug.debugger_on_panic=0' >> /etc/sysctl.conf +echo 'kern.panic_reboot_wait_time=0' >> /etc/sysctl.conf diff --git a/scripts/freebsd14/magma.sh b/scripts/freebsd14/magma.sh new file mode 100644 index 000000000..6ecea02c7 --- /dev/null +++ b/scripts/freebsd14/magma.sh @@ -0,0 +1,170 @@ +#!/bin/bash -eux +# +# Setup the the box. This runs as root + +# Configure fetch so it retries temporary failures. +export FETCH_RETRY=5 +export FETCH_TIMEOUT=30 +export ASSUME_ALWAYS_YES=yes + +if [ -d /home/vagrant/ ]; then + OUTPUT="/home/vagrant/magma-build.sh" +else + OUTPUT="/root/magma-build.sh" +fi + +# Grab a snapshot of the development branch. +cat <<-EOF > $OUTPUT +#!/usr/local/bin/bash + +error() { + if [ \$? -ne 0 ]; then + printf "Compilation of the bundled Magma dependencies failed.\n\n"; + exit 1 + fi +} + +if [ -x /usr/bin/id ]; then + ID=\`/usr/bin/id -u\` + if [ -n "\$ID" -a "\$ID" -eq 0 ]; then + systemctl start mariadb.service + systemctl start postfix.service + systemctl start memcached.service + fi +fi + +# If the TERM environment variable is missing, then tput may trigger a fatal error. +if [[ -n "\$TERM" ]] && [[ "\$TERM" -ne "dumb" ]]; then + export TPUT="tput" +else + export TPUT="tput -Tvt100" +fi + +# We need to give the box 30 seconds to get the networking setup or +# the git clone operation will fail. +sleep 30 + +# Temporary [hopefully] workaround to avoid [yet another] bug in NSS. +export NSS_DISABLE_HW_AES=1 + +# If the directory is present, remove it so we can clone a fresh copy. +if [ -d magma-develop ]; then + rm --recursive --force magma-develop +fi + +# Use the GitHub repository to clone the Magma source code. +git clone --quiet https://github.com/lavabit/magma.git magma-develop && \ + printf "\nMagma repository downloaded.\n" ; error +cd magma-develop; error + +# Setup the bin links, just in case we need to troubleshoot something manually. +dev/scripts/linkup.sh; error + +# Explicitly control the number of build jobs (instead of using nproc). +[ ! -z "\${MAGMA_JOBS##*[!0-9]*}" ] && export M_JOBS="\$MAGMA_JOBS" + +# The unit tests for the bundled dependencies get skipped with quick builds. +MAGMA_QUICK=\$(echo \$MAGMA_QUICK | tr "[:lower:]" "[:upper:]") +if [ "\$MAGMA_QUICK" == "YES" ]; then + export QUICK=yes +fi + +# Compile the dependencies into a shared library. +dev/scripts/builders/build.lib.sh all; error + +# Reset the sandbox database and storage files. +dev/scripts/database/schema.reset.sh &> lib/logs/schema.txt && \ + printf "The Magma database schema installed successfully.\n"; error + +# Controls whether ClamAV is enabled, and/or if the signature databases get updated. +MAGMA_CLAMAV=\$(echo \$MAGMA_CLAMAV | tr "[:lower:]" "[:upper:]") +MAGMA_CLAMAV_FRESHEN=\$(echo \$MAGMA_CLAMAV_FRESHEN | tr "[:lower:]" "[:upper:]") +MAGMA_CLAMAV_DOWNLOAD=\$(echo \$MAGMA_CLAMAV_DOWNLOAD | tr "[:lower:]" "[:upper:]") +if [ "\$MAGMA_CLAMAV" == "YES" ]; then + sed -i 's/^[# ]*magma.iface.virus.available[ ]*=.*$/magma.iface.virus.available = true/g' sandbox/etc/magma.sandbox.config +else + sed -i 's/^[# ]*magma.iface.virus.available[ ]*=.*$/magma.iface.virus.available = false/g' sandbox/etc/magma.sandbox.config +fi +if [ "\$MAGMA_CLAMAV_DOWNLOAD" == "YES" ]; then + ( cd sandbox/virus/ && rm -f main.cvd* daily.cvd* bytecode.cvd* && \ + curl -LSOs https://github.com/ladar/clamav-data/raw/main/main.cvd.[01-10] \ + -LSOs https://github.com/ladar/clamav-data/raw/main/main.cvd.sha256 \ + -LSOs https://github.com/ladar/clamav-data/raw/main/daily.cvd.[01-10] \ + -LSOs https://github.com/ladar/clamav-data/raw/main/daily.cvd.sha256 \ + -LSOs https://github.com/ladar/clamav-data/raw/main/bytecode.cvd \ + -LSOs https://github.com/ladar/clamav-data/raw/main/bytecode.cvd.sha256 && \ + cat main.cvd.01 main.cvd.02 main.cvd.03 main.cvd.04 main.cvd.05 \ + main.cvd.06 main.cvd.07 main.cvd.08 main.cvd.09 main.cvd.10 > main.cvd && \ + cat daily.cvd.01 daily.cvd.02 daily.cvd.03 daily.cvd.04 daily.cvd.05 \ + daily.cvd.06 daily.cvd.07 daily.cvd.08 daily.cvd.09 daily.cvd.10 > daily.cvd && \ + sha256sum -c main.cvd.sha256 daily.cvd.sha256 bytecode.cvd.sha256 || \ + { printf "The ClamAV database download failed. Ignoring.\n" ; ls -alh * ; } + + rm -f main.cvd.sha256 daily.cvd.sha256 bytecode.cvd.sha256 main.cvd.[01-10] daily.cvd.[01-10] + cd \$HOME/magma-develop ) +fi +if [ "\$MAGMA_CLAMAV_FRESHEN" == "YES" ]; then + dev/scripts/freshen/freshen.clamav.sh &> lib/logs/freshen.txt && \ + printf "The ClamAV databases have been updated.\n"; error +fi +# Ensure the sandbox config uses port 2525 for relays. +sed -i "" -e "/magma.relay\[[0-9]*\].name.*/d" sandbox/etc/magma.sandbox.config +sed -i "" -e "/magma.relay\[[0-9]*\].port.*/d" sandbox/etc/magma.sandbox.config +sed -i "" -e "/magma.relay\[[0-9]*\].secure.*/d" sandbox/etc/magma.sandbox.config +printf "\n\nmagma.relay[1].name = localhost\nmagma.relay[1].port = 2525\n\n" >> sandbox/etc/magma.sandbox.config + +# Bug fix... create the scan directory so ClamAV unit tests work. +if [ ! -d 'sandbox/spool/scan/' ]; then + mkdir -p sandbox/spool/scan/ +fi + +# Compile the daemon and then compile the unit tests. +make -j4 all &> lib/logs/magma.txt && \ + printf "The Magma code compiled successfully.\n\n"; error + +# Run the unit tests and capture the return code, if they fail, print an error, +# and then exit using the captured return code. +dev/scripts/launch/check.run.sh +RETVAL=\$? +if [ \$RETVAL -ne 0 ]; then + \${TPUT} setaf 1; \${TPUT} bold; printf "Some of the Magma unit tests failed...\n\n"; \${TPUT} sgr0; + exit \$RETVAL +fi + +# Additionally, run the unit tests atop Valgrind, note this will take a +# long time if the anti-virus engine is enabled, but like the normal unit +# tests above, we capture the return code. If they fail, print an error, +# and then exit using the captured return code. +MAGMA_MEMCHECK=\$(echo \$MAGMA_MEMCHECK | tr "[:lower:]" "[:upper:]") +if [ "\$MAGMA_MEMCHECK" == "YES" ]; then + dev/scripts/launch/check.vg.sh + RETVAL=\$? + if [ \$RETVAL -ne 0 ]; then + \${TPUT} setaf 1; \${TPUT} bold; printf "Some of the Magma unit tests failed...\n\n"; \${TPUT} sgr0; + exit \$RETVAL + fi +fi + +# Uncomment the following lines to have Magma daemonize instead of running in the foreground. +# sed -i -e "s/magma.output.file = false/magma.output.file = true/g" sandbox/etc/magma.sandbox.config +# sed -i -e "s/magma.system.daemonize = false/magma.system.daemonize = true/g" sandbox/etc/magma.sandbox.config + +# Launch the daemon, and give it time to start before exiting. +# ./magmad --config magma.system.daemonize=true sandbox/etc/magma.sandbox.config || exit 1 +# sleep 15 + +# Ensure we exit with a zero so Vagrant and/or the various CI systems used +# for testing know everything worked. +exit 0 +EOF + +# Make the script executable. +if [ -d /home/vagrant/ ]; then + chown vagrant:vagrant /home/vagrant/magma-build.sh + chmod +x /home/vagrant/magma-build.sh +else + chmod +x /root/magma-build.sh +fi + +# Customize the message of the day +printf "Magma Daemon Development Environment\nTo download and compile magma, just execute the magma-build.sh script.\n\n" > /etc/motd diff --git a/scripts/freebsd14/motd.sh b/scripts/freebsd14/motd.sh new file mode 100644 index 000000000..7db814140 --- /dev/null +++ b/scripts/freebsd14/motd.sh @@ -0,0 +1,6 @@ +#!/bin/bash -eux + +sed -i "" -e "s/update_motd=\"YES\"/update_motd=\"NO\"/g" /etc/defaults/rc.conf + +cat << EOF > /etc/motd +EOF diff --git a/scripts/freebsd14/parallels.sh b/scripts/freebsd14/parallels.sh new file mode 100644 index 000000000..07449f141 --- /dev/null +++ b/scripts/freebsd14/parallels.sh @@ -0,0 +1,30 @@ +#!/bin/bash -ux + +# Configure fetch so it retries temporary failures. +export FETCH_RETRY=5 +export FETCH_TIMEOUT=30 +export ASSUME_ALWAYS_YES=yes + +# Needed to check whether we're running atop Parallels. +pkg-static install --yes dmidecode + +# Bail if we are not running atop Parallels. +if [[ `dmidecode -s system-product-name` != "Parallels Virtual Platform" ]]; then + exit 0 +fi + +# Install the FreeBSD package with the Parallels guest tools. +pkg-static install --yes parallels-tools + +# Read in the version number. +PARALLELSVERSION=`cat /root/parallels-tools-version.txt` + +mkdir -p /mnt/parallels/ +mount -o loop /root/parallels-tools-other.iso /mnt/parallels/ +# bash /mnt/parallels/install --install-unattended-with-deps +umount /mnt/parallels/ +rmdir /mnt/parallels/ + +# Cleanup the guest additions. +rm -f /root/parallels-tools-other.iso +rm -f /root/parallels-tools-version.txt diff --git a/scripts/freebsd14/pkg.sh b/scripts/freebsd14/pkg.sh new file mode 100644 index 000000000..e2a1d75d0 --- /dev/null +++ b/scripts/freebsd14/pkg.sh @@ -0,0 +1,63 @@ +#!/bin/bash -eux + +# Configure fetch so it retries temporary failures. +export FETCH_RETRY=5 +export FETCH_TIMEOUT=30 +export ASSUME_ALWAYS_YES=yes + +# We need to use HTTP until the CA bundle has been updated. +mkdir -p /usr/local/etc/pkg/repos/ +rm -f /var/db/pkg/FreeBSD.meta /var/db/pkg/repo-FreeBSD.sqlite /var/db/pkg/repo-FreeBSD.sqlite-journal +echo 'FreeBSD: { url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest" }' > /usr/local/etc/pkg/repos/FreeBSD.conf + +# Install the packages needed to update the CA bundle. +pkg bootstrap +pkg-static update -f +pkg-static upgrade --yes perl5 p5-MIME-Base64 p5-Carp curl ca_root_nss + +# Download the bundle generator. +# curl --silent --location --output $HOME/mk-ca-bundle.pl https://raw.githubusercontent.com/curl/curl/85f91248cffb22d151d5983c32f0dbf6b1de572a/lib/mk-ca-bundle.pl +# sha256 -c f819e5844935bad3d7eebab566b55066f21bd7138097d2baab7842bd04fd92d2 $HOME/mk-ca-bundle.pl || exit 1 +# chmod +x $HOME/mk-ca-bundle.pl + +# To ensure we save the certdata.txt file in a predictable place we change directory first. +# cd $HOME && $HOME/mk-ca-bundle.pl $HOME/ca-bundle.crt + +# Move the updated bundle to all the places it might be needed. +# cp $HOME/ca-bundle.crt /etc/ssl/cert.pem +# cp $HOME/ca-bundle.crt /usr/local/openssl/cert.pem +# cp $HOME/ca-bundle.crt /usr/local/etc/ssl/cert.pem +# cp $HOME/ca-bundle.crt /usr/local/share/certs/ca-root-nss.crt + +# Cleanup the downloaded files and clear the cached repo data. +# rm $HOME/ca-bundle.crt $HOME/certdata.txt $HOME/mk-ca-bundle.pl /var/db/pkg/FreeBSD.meta /var/db/pkg/repo-FreeBSD.sqlite + +# Switch to using HTTPS and perform the system upgrade. +rm -f /var/db/pkg/FreeBSD.meta /var/db/pkg/repo-FreeBSD.sqlite /var/db/pkg/repo-FreeBSD.sqlite-journal +echo 'FreeBSD: { url: "pkg+https://pkg.FreeBSD.org/${ABI}/latest" }' > /usr/local/etc/pkg/repos/FreeBSD.conf + +pkg-static update -f +pkg-static upgrade --yes + +# Generic system utils. +pkg-static upgrade --yes vim curl wget sudo bash gnuls gnugrep psmisc + +# Since most scripts expect bash to be in the bin directory, create a symlink. +[ ! -f /bin/bash ] && [ -f /usr/local/bin/bash ] && ln -s /usr/local/bin/bash /bin/bash +[ ! -f /usr/bin/bash ] && [ -f /usr/local/bin/bash ] && ln -s /usr/local/bin/bash /usr/bin/bash + +# Disable fortunate cookies. +sed -i "" -e "/fortune/d" /usr/share/skel/dot.login +sed -i "" -e "/fortune/d" /usr/share/skel/dot.profile + +sed -i "" -e "/fortune/d" /home/vagrant/.login +sed -i "" -e "/fortune/d" /home/vagrant/.profile + +# Update the locate database. +/etc/periodic/weekly/310.locate + +# Configure daily locate database updates. +echo '# 315.locate' >> /etc/periodic.conf +echo 'daily_locate_enable="YES" # Update locate daily' >> /etc/periodic.conf +cp /etc/periodic/weekly/310.locate /usr/local/etc/periodic/daily/315.locate +sed -i "" -e "s/weekly_locate_enable/daily_locate_enable=/g" /usr/local/etc/periodic/daily/315.locate diff --git a/scripts/freebsd14/qemu.sh b/scripts/freebsd14/qemu.sh new file mode 100644 index 000000000..68f38c271 --- /dev/null +++ b/scripts/freebsd14/qemu.sh @@ -0,0 +1,29 @@ +#!/bin/bash -eux + +# Configure fetch so it retries temporary failures. +export FETCH_RETRY=5 +export FETCH_TIMEOUT=30 +export ASSUME_ALWAYS_YES=yes + +# Ensure dmideocode is available. +pkg-static install --yes dmidecode + +# Bail if we are not running atop QEMU. +if [[ `dmidecode -s system-product-name` != "KVM" && `dmidecode -s system-manufacturer` != "QEMU" ]]; then + exit 0 +fi + +# Load the virtio module at boot. +echo 'if_vtnet_load="YES"' >> /boot/loader.conf +echo 'virtio_load="YES"' >> /boot/loader.conf +echo 'virtio_pci_load="YES"' >> /boot/loader.conf +echo 'virtio_blk_load="YES"' >> /boot/loader.conf +echo 'virtio_scsi_load="YES"' >> /boot/loader.conf +echo 'virtio_console_load="YES"' >> /boot/loader.conf +echo 'virtio_balloon_load="YES"' >> /boot/loader.conf +echo 'virtio_random_load="YES"' >> /boot/loader.conf + +# Enable the daemons used for host to geust communication. +sysrc rpcbind_enable="YES" +sysrc rpc_lockd_enable="YES" +sysrc nfs_client_enable="YES" diff --git a/scripts/freebsd14/vagrant.sh b/scripts/freebsd14/vagrant.sh new file mode 100644 index 000000000..ac7f92de1 --- /dev/null +++ b/scripts/freebsd14/vagrant.sh @@ -0,0 +1,29 @@ +#!/bin/bash -ux + +pkg-static install --yes sudo + +# Setup the default user password and ensure the vagrant shell is bash. +pw user show vagrant &>/dev/null || { echo 'vagrant' | pw useradd vagrant -h 0 -m ; } +chsh -s bash vagrant + +cat <<-EOF > /usr/local/etc/sudoers.d/vagrant +Defaults:vagrant !fqdn +Defaults:vagrant !requiretty +vagrant ALL=(ALL) NOPASSWD: ALL +EOF +chmod 0440 /usr/local/etc/sudoers.d/vagrant + +# Create the vagrant user ssh directory. +mkdir -pm 700 /home/vagrant/.ssh + +# Create an authorized keys file and insert the insecure public vagrant key. +cat <<-EOF > /home/vagrant/.ssh/authorized_keys +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key +EOF + +# Ensure the permissions are set correct to avoid OpenSSH complaints. +chmod 0600 /home/vagrant/.ssh/authorized_keys +chown -R vagrant:vagrant /home/vagrant/.ssh + +# Mark the vagrant box build time. +date > /etc/vagrant_box_build_time diff --git a/scripts/freebsd14/virtualbox.sh b/scripts/freebsd14/virtualbox.sh new file mode 100644 index 000000000..8e2f8c463 --- /dev/null +++ b/scripts/freebsd14/virtualbox.sh @@ -0,0 +1,38 @@ +#!/bin/bash -eux + +# Configure fetch so it retries temporary failures. +export FETCH_RETRY=5 +export FETCH_TIMEOUT=30 +export ASSUME_ALWAYS_YES=yes + +# Ensure dmideocode is available. +pkg-static install --yes dmidecode + +# Bail if we are not running atop VirtualBox. +if [[ `dmidecode -s system-product-name` != "VirtualBox" ]]; then + exit 0 +fi + +# Install the virtualbox guest additions. +pkg-static install --yes virtualbox-ose-additions-nox11 + +# Load the virtio module at boot. +echo 'if_vtnet_load="YES"' >> /boot/loader.conf +echo 'virtio_load="YES"' >> /boot/loader.conf +echo 'virtio_pci_load="YES"' >> /boot/loader.conf +echo 'virtio_blk_load="YES"' >> /boot/loader.conf +echo 'virtio_scsi_load="YES"' >> /boot/loader.conf +echo 'virtio_console_load="YES"' >> /boot/loader.conf +echo 'virtio_balloon_load="YES"' >> /boot/loader.conf +echo 'virtio_random_load="YES"' >> /boot/loader.conf + +sysrc ifconfig_em1="inet 10.6.66.42 netmask 255.255.255.0" +sysrc vboxguest_enable="YES" +sysrc vboxservice_enable="YES" + +sysrc rpcbind_enable="YES" +sysrc rpc_lockd_enable="YES" +sysrc nfs_client_enable="YES" + +rm -rf /root/VBoxVersion.txt +rm -rf /root/VBoxGuestAdditions.iso diff --git a/scripts/freebsd14/vmware.sh b/scripts/freebsd14/vmware.sh new file mode 100644 index 000000000..5c33aedda --- /dev/null +++ b/scripts/freebsd14/vmware.sh @@ -0,0 +1,35 @@ +#!/bin/bash -eux + +# Configure fetch so it retries temporary failures. +export FETCH_RETRY=5 +export FETCH_TIMEOUT=30 +export ASSUME_ALWAYS_YES=yes + +# Ensure dmideocode is available. +pkg-static install --yes dmidecode + +# Bail if we are not running inside VMWare. +if [[ `dmidecode -s system-product-name` != "VMware Virtual Platform" ]]; then + exit 0 +fi + +pkg-static install --yes open-vm-tools-nox11 + +# Disable vmxnet in favor of whatever the OpenVM Tools are suggesting. +sed -i "" -e 's#^ifconfig_vmx0#ifconfig_em0#g' /etc/rc.conf +sed -i "" -e '/^if_vmx_load=.*/d' /boot/loader.conf + +sysrc vmware_guest_vmblock_enable=YES +sysrc vmware_guest_vmhgfs_enable=YES +sysrc vmware_guest_vmmemctl_enable=YES +sysrc vmware_guest_vmxnet_enable=YES +sysrc vmware_guestd_enable=YES + +sysrc rpcbind_enable="YES" +sysrc rpc_lockd_enable="YES" +sysrc nfs_client_enable="YES" + +rm -f /root/freebsd.iso + +# Fix the SSH NAT issue on VMWare systems. +printf "\nIPQoS lowdelay throughput\n" >> /etc/ssh/sshd_config diff --git a/tpl/generic-freebsd14.rb b/tpl/generic-freebsd14.rb new file mode 100644 index 000000000..bf2e416ff --- /dev/null +++ b/tpl/generic-freebsd14.rb @@ -0,0 +1,63 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure(2) do |config| + + config.vm.boot_timeout = 1800 + config.vm.synced_folder ".", "/vagrant", disabled: true + + config.vm.box_check_update = true + + # config.vm.post_up_message = "" + config.vm.boot_timeout = 1800 + # config.vm.box_download_checksum = true + config.vm.boot_timeout = 1800 + # config.vm.box_download_checksum_type = "sha256" + + # config.vm.provision "shell", run: "always", inline: <<-SHELL + # SHELL + + # Adding a second CPU and increasing the RAM to 2048MB will speed + # things up considerably should you decide to do anythinc with this box. + config.vm.provider :hyperv do |v, override| + v.maxmemory = 2048 + v.memory = 2048 + v.cpus = 2 + end + + config.vm.provider :libvirt do |v, override| + v.disk_bus = "scsi" + v.driver = "kvm" + v.video_vram = 256 + v.memory = 2048 + v.cpus = 2 + end + + config.vm.provider :parallels do |v, override| + v.customize ["set", :id, "--on-window-close", "keep-running"] + v.customize ["set", :id, "--startup-view", "headless"] + v.customize ["set", :id, "--memsize", "2048"] + v.customize ["set", :id, "--cpus", "2"] + end + + config.vm.provider :virtualbox do |v, override| + v.gui = false + v.functional_vboxsf = false + v.check_guest_additions = false + v.customize ["modifyvm", :id, "--vram", 256] + v.customize ["modifyvm", :id, "--cpus", 2] + v.customize ["modifyvm", :id, "--memory", 2048] + end + + ["vmware_fusion", "vmware_workstation", "vmware_desktop"].each do |provider| + config.vm.provider provider do |v, override| + v.whitelist_verified = true + v.functional_hgfs = false + v.gui = false + v.vmx["cpuid.coresPerSocket"] = "1" + v.vmx["memsize"] = "2048" + v.vmx["numvcpus"] = "2" + end + end + +end diff --git a/tpl/roboxes-freebsd14.rb b/tpl/roboxes-freebsd14.rb new file mode 100644 index 000000000..bf2e416ff --- /dev/null +++ b/tpl/roboxes-freebsd14.rb @@ -0,0 +1,63 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure(2) do |config| + + config.vm.boot_timeout = 1800 + config.vm.synced_folder ".", "/vagrant", disabled: true + + config.vm.box_check_update = true + + # config.vm.post_up_message = "" + config.vm.boot_timeout = 1800 + # config.vm.box_download_checksum = true + config.vm.boot_timeout = 1800 + # config.vm.box_download_checksum_type = "sha256" + + # config.vm.provision "shell", run: "always", inline: <<-SHELL + # SHELL + + # Adding a second CPU and increasing the RAM to 2048MB will speed + # things up considerably should you decide to do anythinc with this box. + config.vm.provider :hyperv do |v, override| + v.maxmemory = 2048 + v.memory = 2048 + v.cpus = 2 + end + + config.vm.provider :libvirt do |v, override| + v.disk_bus = "scsi" + v.driver = "kvm" + v.video_vram = 256 + v.memory = 2048 + v.cpus = 2 + end + + config.vm.provider :parallels do |v, override| + v.customize ["set", :id, "--on-window-close", "keep-running"] + v.customize ["set", :id, "--startup-view", "headless"] + v.customize ["set", :id, "--memsize", "2048"] + v.customize ["set", :id, "--cpus", "2"] + end + + config.vm.provider :virtualbox do |v, override| + v.gui = false + v.functional_vboxsf = false + v.check_guest_additions = false + v.customize ["modifyvm", :id, "--vram", 256] + v.customize ["modifyvm", :id, "--cpus", 2] + v.customize ["modifyvm", :id, "--memory", 2048] + end + + ["vmware_fusion", "vmware_workstation", "vmware_desktop"].each do |provider| + config.vm.provider provider do |v, override| + v.whitelist_verified = true + v.functional_hgfs = false + v.gui = false + v.vmx["cpuid.coresPerSocket"] = "1" + v.vmx["memsize"] = "2048" + v.vmx["numvcpus"] = "2" + end + end + +end