diff --git a/README.md b/README.md index 2a51dc6c9..9a2b78575 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,6 @@ https://quay.io/organization/lavabit FreeBSD 13.2 Fedora 38 -Ubuntu 23.04 (Lunar Lobster) OpenBSD 7.3 ## Upcoming Additions @@ -97,7 +96,7 @@ git clone https://github.com/lavabit/robox && cd robox You will to replace the BOX and PROVIDER placeholders in the example above. -Replace `BOX` with one of the these values: `[alma8|alma9|alpine35|alpine36|alpine37|alpine38|alpine39|alpine310|alpine311|alpine312|alpine313|alpine314|alpine315|alpine316|alpine317|arch|centos6|centos7|centos8|centos8s|centos9s|debian8|debian9|debian10|debian11|devuan1|devuan2|devuan3|devuan4|dragonflybsd5|dragonflybsd6|fedora25|fedora26|fedora27|fedora28|fedora29|fedora30|fedora31|fedora32|fedora33|fedora34|fedora35|fedora36|fedora37|freebsd11|freebsd12|freebsd13|gentoo|hardenedbsd11|hardenedbsd12|hardenedbsd13|netbsd8|netbsd9|openbsd6|openbsd7|opensuse15|opensuse42|oracle7|oracle8|oracle8|rhel6|rhel7|rhel8|rocky8|rocky9|ubuntu1604|ubuntu1610|ubuntu1704|ubuntu1710|ubuntu1804|ubuntu1810|ubuntu1904|ubuntu1910|ubuntu2004|ubuntu2010|ubuntu2104|ubuntu2110|ubuntu2204|ubuntu2210]` +Replace `BOX` with one of the these values: `[alma8|alma9|alpine35|alpine36|alpine37|alpine38|alpine39|alpine310|alpine311|alpine312|alpine313|alpine314|alpine315|alpine316|alpine317|arch|centos6|centos7|centos8|centos8s|centos9s|debian8|debian9|debian10|debian11|devuan1|devuan2|devuan3|devuan4|dragonflybsd5|dragonflybsd6|fedora25|fedora26|fedora27|fedora28|fedora29|fedora30|fedora31|fedora32|fedora33|fedora34|fedora35|fedora36|fedora37|freebsd11|freebsd12|freebsd13|gentoo|hardenedbsd11|hardenedbsd12|hardenedbsd13|netbsd8|netbsd9|openbsd6|openbsd7|opensuse15|opensuse42|oracle7|oracle8|oracle8|rhel6|rhel7|rhel8|rocky8|rocky9|ubuntu1604|ubuntu1610|ubuntu1704|ubuntu1710|ubuntu1804|ubuntu1810|ubuntu1904|ubuntu1910|ubuntu2004|ubuntu2010|ubuntu2104|ubuntu2110|ubuntu2204|ubuntu2210|ubuntu2304]` And replace `PROVIDER` with one of these values: `[docker|hyperv|libvirt|parallels|virtualbox|vmware]`. diff --git a/check/ubuntu2304.tpl b/check/ubuntu2304.tpl new file mode 100644 index 000000000..c5f1c10aa --- /dev/null +++ b/check/ubuntu2304.tpl @@ -0,0 +1,50 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure(2) do |config| + + config.vm.box = "generic/ubuntu2304" + + config.ssh.forward_x11 = true + config.ssh.forward_agent = true + 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 + 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.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.vmx["memsize"] = "2048" + v.vmx["numvcpus"] = "2" + v.vmx["cpuid.coresPerSocket"] = "1" + end + end + + config.vm.provision "shell", inline: <<-SHELL + sudo sed -i 's/.*X11Forwarding.*/X11Forwarding yes/g' /etc/ssh/sshd_config + sudo sed -i 's/.*X11UseLocalhost.*/X11UseLocalhost no/g' /etc/ssh/sshd_config + sudo sed -i 's/.*X11DisplayOffset.*/X11DisplayOffset 10/g' /etc/ssh/sshd_config + sudo systemctl reload ssh.service + SHELL + +end diff --git a/generic-hyperv.json b/generic-hyperv.json index f3525c97b..534a3cc50 100644 --- a/generic-hyperv.json +++ b/generic-hyperv.json @@ -3027,6 +3027,42 @@ "generic-alpine317-hyperv" ] }, + { + "type": "shell", + "timeout": "120m", + "scripts": [ + "scripts/ubuntu2304/apt.sh", + "scripts/ubuntu2304/floppy.sh", + "scripts/ubuntu2304/fixkvp.sh", + "scripts/ubuntu2304/network.sh" + ], + "start_retry_timeout": "15m", + "expect_disconnect": "true", + "only": [ + "generic-ubuntu2304-hyperv" + ] + }, + { + "type": "shell", + "timeout": "120m", + "scripts": [ + "scripts/ubuntu2304/vagrant.sh", + "scripts/ubuntu2304/profile.sh", + "scripts/ubuntu2304/motd.sh", + "scripts/ubuntu2304/fixtty.sh", + "scripts/ubuntu2304/virtualbox.sh", + "scripts/ubuntu2304/parallels.sh", + "scripts/ubuntu2304/vmware.sh", + "scripts/ubuntu2304/qemu.sh", + "scripts/ubuntu2304/cleanup.sh" + ], + "pause_before": "120s", + "start_retry_timeout": "15m", + "expect_disconnect": "true", + "only": [ + "generic-ubuntu2304-hyperv" + ] + }, { "type": "shell", "timeout": "120m", @@ -6463,6 +6499,44 @@ "enable_dynamic_memory": false, "guest_additions_mode": "disable", "enable_virtualization_extensions": false + }, + { + "type": "hyperv-iso", + "name": "generic-ubuntu2304-hyperv", + "vm_name": "generic-ubuntu2304-hyperv", + "temp_path": "output/", + "output_directory": "output/generic-ubuntu2304-hyperv", + "boot_wait": "10s", + "boot_keygroup_interval": "1s", + "boot_command": [ + "", + "c", + "set gfxpayload=keep", + "linux /casper/vmlinuz autoinstall quiet net.ifnames=0 biosdevname=0 ", + "ds=\"nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/generic.ubuntu2304.vagrant\" --- ", + "initrd /casper/initrd", + "boot" + ], + "disk_size": 131072, + "memory": 2048, + "cpus": 2, + "http_directory": "http", + "iso_url": "https://releases.ubuntu.com/23.04/ubuntu-23.04-live-server-amd64.iso", + "iso_checksum": "sha256:c7cda48494a6d7d9665964388a3fc9c824b3bef0c9ea3818a1be982bc80d346b", + "ssh_username": "root", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_timeout": "7200s", + "shutdown_command": "echo 'vagrant' | sudo -S 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.json b/generic-libvirt.json index 9fb1f7d40..e974cf6ba 100644 --- a/generic-libvirt.json +++ b/generic-libvirt.json @@ -3027,6 +3027,42 @@ "generic-alpine317-libvirt" ] }, + { + "type": "shell", + "timeout": "120m", + "scripts": [ + "scripts/ubuntu2304/apt.sh", + "scripts/ubuntu2304/floppy.sh", + "scripts/ubuntu2304/fixkvp.sh", + "scripts/ubuntu2304/network.sh" + ], + "start_retry_timeout": "15m", + "expect_disconnect": "true", + "only": [ + "generic-ubuntu2304-libvirt" + ] + }, + { + "type": "shell", + "timeout": "120m", + "scripts": [ + "scripts/ubuntu2304/vagrant.sh", + "scripts/ubuntu2304/profile.sh", + "scripts/ubuntu2304/motd.sh", + "scripts/ubuntu2304/fixtty.sh", + "scripts/ubuntu2304/virtualbox.sh", + "scripts/ubuntu2304/parallels.sh", + "scripts/ubuntu2304/vmware.sh", + "scripts/ubuntu2304/qemu.sh", + "scripts/ubuntu2304/cleanup.sh" + ], + "pause_before": "120s", + "start_retry_timeout": "15m", + "expect_disconnect": "true", + "only": [ + "generic-ubuntu2304-libvirt" + ] + }, { "scripts": [ "scripts/common/motd.sh", @@ -6459,6 +6495,45 @@ "ssh_port": 22, "ssh_timeout": "3600s", "shutdown_command": "/sbin/poweroff" + }, + { + "type": "qemu", + "name": "generic-ubuntu2304-libvirt", + "vm_name": "generic-ubuntu2304-libvirt", + "output_directory": "output/generic-ubuntu2304-libvirt", + "qemu_binary": "qemu-system-x86_64", + "boot_wait": "10s", + "boot_keygroup_interval": "1s", + "boot_command": [ + "", + "c", + "set gfxpayload=keep", + "linux /casper/vmlinuz autoinstall quiet net.ifnames=0 biosdevname=0 ", + "ds=\"nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/generic.ubuntu2304.vagrant\" --- ", + "initrd /casper/initrd", + "boot" + ], + "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": "https://releases.ubuntu.com/23.04/ubuntu-23.04-live-server-amd64.iso", + "iso_checksum": "sha256:c7cda48494a6d7d9665964388a3fc9c824b3bef0c9ea3818a1be982bc80d346b", + "ssh_username": "root", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_timeout": "3600s", + "ssh_handshake_attempts": "10000", + "shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now" } ], "post-processors": [ diff --git a/generic-parallels.json b/generic-parallels.json index 941b29ff6..dd8d8c05b 100644 --- a/generic-parallels.json +++ b/generic-parallels.json @@ -3019,6 +3019,42 @@ "generic-alpine317-parallels" ] }, + { + "type": "shell", + "timeout": "120m", + "scripts": [ + "scripts/ubuntu2304/apt.sh", + "scripts/ubuntu2304/floppy.sh", + "scripts/ubuntu2304/fixkvp.sh", + "scripts/ubuntu2304/network.sh" + ], + "start_retry_timeout": "45m", + "expect_disconnect": "true", + "only": [ + "generic-ubuntu2304-parallels" + ] + }, + { + "type": "shell", + "timeout": "120m", + "scripts": [ + "scripts/ubuntu2304/vagrant.sh", + "scripts/ubuntu2304/profile.sh", + "scripts/ubuntu2304/motd.sh", + "scripts/ubuntu2304/fixtty.sh", + "scripts/ubuntu2304/virtualbox.sh", + "scripts/ubuntu2304/parallels.sh", + "scripts/ubuntu2304/vmware.sh", + "scripts/ubuntu2304/qemu.sh", + "scripts/ubuntu2304/cleanup.sh" + ], + "pause_before": "120s", + "start_retry_timeout": "45m", + "expect_disconnect": "true", + "only": [ + "generic-ubuntu2304-parallels" + ] + }, { "scripts": [ "scripts/common/motd.sh", @@ -8823,6 +8859,73 @@ "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-ubuntu2304-parallels", + "vm_name": "generic-ubuntu2304-parallels", + "output_directory": "output/generic-ubuntu2304-parallels", + "boot_wait": "10s", + "boot_keygroup_interval": "1s", + "boot_command": [ + "", + "c", + "set gfxpayload=keep", + "linux /casper/vmlinuz autoinstall quiet net.ifnames=0 biosdevname=0 ", + "ds=\"nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/generic.ubuntu2304.vagrant\" --- ", + "initrd /casper/initrd", + "boot" + ], + "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" + ] + ], + "hard_drive_interface": "ide", + "guest_os_type": "ubuntu", + "skip_compaction": false, + "http_directory": "http", + "iso_url": "https://releases.ubuntu.com/23.04/ubuntu-23.04-live-server-amd64.iso", + "iso_checksum": "sha256:c7cda48494a6d7d9665964388a3fc9c824b3bef0c9ea3818a1be982bc80d346b", + "ssh_username": "root", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_timeout": "3600s", + "shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now", + "parallels_tools_flavor": "lin", + "parallels_tools_mode": "upload", + "parallels_tools_guest_path": "/root/parallels-tools-linux.iso", + "prlctl_version_file": "/root/parallels-tools-version.txt" } ], "post-processors": [ diff --git a/generic-virtualbox.json b/generic-virtualbox.json index 8264ae723..04dd67c4b 100644 --- a/generic-virtualbox.json +++ b/generic-virtualbox.json @@ -3027,6 +3027,42 @@ "generic-alpine317-virtualbox" ] }, + { + "type": "shell", + "timeout": "120m", + "scripts": [ + "scripts/ubuntu2304/apt.sh", + "scripts/ubuntu2304/floppy.sh", + "scripts/ubuntu2304/fixkvp.sh", + "scripts/ubuntu2304/network.sh" + ], + "start_retry_timeout": "15m", + "expect_disconnect": "true", + "only": [ + "generic-ubuntu2304-virtualbox" + ] + }, + { + "type": "shell", + "timeout": "120m", + "scripts": [ + "scripts/ubuntu2304/vagrant.sh", + "scripts/ubuntu2304/profile.sh", + "scripts/ubuntu2304/motd.sh", + "scripts/ubuntu2304/fixtty.sh", + "scripts/ubuntu2304/virtualbox.sh", + "scripts/ubuntu2304/parallels.sh", + "scripts/ubuntu2304/vmware.sh", + "scripts/ubuntu2304/qemu.sh", + "scripts/ubuntu2304/cleanup.sh" + ], + "pause_before": "120s", + "start_retry_timeout": "15m", + "expect_disconnect": "true", + "only": [ + "generic-ubuntu2304-virtualbox" + ] + }, { "scripts": [ "scripts/common/motd.sh", @@ -7242,6 +7278,53 @@ "guest_additions_path": "VBoxGuestAdditions.iso", "guest_additions_mode": "upload", "virtualbox_version_file": "VBoxVersion.txt" + }, + { + "type": "virtualbox-iso", + "name": "generic-ubuntu2304-virtualbox", + "vm_name": "generic-ubuntu2304-virtualbox", + "output_directory": "output/generic-ubuntu2304-virtualbox", + "boot_wait": "10s", + "boot_keygroup_interval": "1s", + "boot_command": [ + "", + "c", + "set gfxpayload=keep", + "linux /casper/vmlinuz autoinstall quiet net.ifnames=0 biosdevname=0 ", + "ds=\"nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/generic.ubuntu2304.vagrant\" --- ", + "initrd /casper/initrd", + "boot" + ], + "disk_size": 131072, + "cpus": 2, + "memory": 2048, + "vboxmanage": [ + [ + "modifyvm", + "{{.Name}}", + "--vram", + "64" + ] + ], + "hard_drive_interface": "sata", + "guest_os_type": "Ubuntu_64", + "http_directory": "http", + "headless": true, + "vrdp_bind_address": "127.0.0.1", + "vrdp_port_min": 11000, + "vrdp_port_max": 12000, + "iso_url": "https://releases.ubuntu.com/23.04/ubuntu-23.04-live-server-amd64.iso", + "iso_checksum": "sha256:c7cda48494a6d7d9665964388a3fc9c824b3bef0c9ea3818a1be982bc80d346b", + "ssh_username": "root", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_timeout": "3600s", + "shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now", + "guest_additions_url": "https://download.virtualbox.org/virtualbox/6.1.40/VBoxGuestAdditions_6.1.40.iso", + "guest_additions_sha256": "d456c559926f1a8fdd7259056e0a50f12339fd494122cf30db7736e2032970c6", + "guest_additions_path": "VBoxGuestAdditions.iso", + "guest_additions_mode": "upload", + "virtualbox_version_file": "VBoxVersion.txt" } ], "post-processors": [ diff --git a/generic-vmware.json b/generic-vmware.json index fdfb1eb10..e39cc8c3a 100644 --- a/generic-vmware.json +++ b/generic-vmware.json @@ -3027,6 +3027,42 @@ "generic-alpine317-vmware" ] }, + { + "type": "shell", + "timeout": "120m", + "scripts": [ + "scripts/ubuntu2304/apt.sh", + "scripts/ubuntu2304/floppy.sh", + "scripts/ubuntu2304/fixkvp.sh", + "scripts/ubuntu2304/network.sh" + ], + "start_retry_timeout": "15m", + "expect_disconnect": "true", + "only": [ + "generic-ubuntu2304-vmware" + ] + }, + { + "type": "shell", + "timeout": "120m", + "scripts": [ + "scripts/ubuntu2304/vagrant.sh", + "scripts/ubuntu2304/profile.sh", + "scripts/ubuntu2304/motd.sh", + "scripts/ubuntu2304/fixtty.sh", + "scripts/ubuntu2304/virtualbox.sh", + "scripts/ubuntu2304/parallels.sh", + "scripts/ubuntu2304/vmware.sh", + "scripts/ubuntu2304/qemu.sh", + "scripts/ubuntu2304/cleanup.sh" + ], + "pause_before": "120s", + "start_retry_timeout": "15m", + "expect_disconnect": "true", + "only": [ + "generic-ubuntu2304-vmware" + ] + }, { "scripts": [ "scripts/common/motd.sh", @@ -7161,6 +7197,52 @@ "ssh_timeout": "3600s", "shutdown_command": "/sbin/poweroff", "tools_upload_flavor": "linux" + }, + { + "type": "vmware-iso", + "name": "generic-ubuntu2304-vmware", + "vm_name": "generic-ubuntu2304-vmware", + "vmdk_name": "generic-ubuntu2304-vmware", + "output_directory": "output/generic-ubuntu2304-vmware", + "boot_wait": "10s", + "boot_keygroup_interval": "1s", + "boot_command": [ + "", + "c", + "set gfxpayload=keep", + "linux /casper/vmlinuz autoinstall quiet net.ifnames=0 biosdevname=0 ", + "ds=\"nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/generic.ubuntu2304.vagrant\" --- ", + "initrd /casper/initrd", + "boot" + ], + "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": "ubuntu-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": "https://releases.ubuntu.com/23.04/ubuntu-23.04-live-server-amd64.iso", + "iso_checksum": "sha256:c7cda48494a6d7d9665964388a3fc9c824b3bef0c9ea3818a1be982bc80d346b", + "ssh_username": "root", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_timeout": "3600s", + "shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now", + "tools_upload_flavor": "linux" } ], "post-processors": [ diff --git a/http/generic.ubuntu2304.vagrant/meta-data b/http/generic.ubuntu2304.vagrant/meta-data new file mode 100644 index 000000000..e69de29bb diff --git a/http/generic.ubuntu2304.vagrant/user-data b/http/generic.ubuntu2304.vagrant/user-data new file mode 100644 index 000000000..173b8c4b7 --- /dev/null +++ b/http/generic.ubuntu2304.vagrant/user-data @@ -0,0 +1,87 @@ + +#cloud-config +autoinstall: + version: 1 + locale: en_US.UTF-8 + keyboard: + layout: us + variant: "" + toggle: "" + network: + network: + version: 2 + ethernets: + eth0: + dhcp4: yes + dhcp6: no + apt: + geoip: false + primary: + - arches: [default] + uri: https://mirrors.edge.kernel.org/ubuntu/ + # uri: https://old-releases.ubuntu.com/ubuntu/ + security: + - arches: [default] + uri: https://mirrors.edge.kernel.org/ubuntu/ + # uri: https://old-releases.ubuntu.com/ubuntu/ + storage: + layout: + name: lvm + identity: + username: root + hostname: ubuntu2304.localdomain + password: "$6$RsFnUPD4Axp9Y9yQ$jPjBajFAlATEBb8wa.xmvGimRz8I9vQgfGLWyuBOcqcyLxgt23KrsVWS3khrH19i6oqdMi75L0UYgWkkmHEyw/" + ssh: + install-server: yes + authorized-keys: [] + allow-pw: yes + user-data: + disable_root: false + packages: + - sed + - curl + - sudo + - openssh-server + - linux-cloud-tools-virtual + output: + init: "> /var/log/cloud-init.log" + config: [ ">> /tmp/foo.out", "> /var/log/cloud-config.log" ] + final: + output: "| tee /tmp/final.stdout | tee /var/log/cloud-final.log" + error: "&1" + final_message: "System installation complete." + write_files: + - encoding: b64 + content: W01hdGNoXQpOYW1lPWV0aDAKCltOZXR3b3JrXQpESENQPWlwdjQK + owner: root:root + path: /etc/systemd/network/eth0.network + permissions: '0644' + early-commands: + - systemctl stop ssh.socket + - systemctl stop ssh.service + - sed -i "s/#Cache=.*/Cache=yes/g" /etc/systemd/resolved.conf + - sed -i "s/#DNS=.*/DNS=4.2.2.1 4.2.2.2 208.67.220.220/g" /etc/systemd/resolved.conf + - sed -i "s/#FallbackDNS=.*/FallbackDNS=4.2.2.1 4.2.2.2 208.67.220.220/g" /etc/systemd/resolved.conf + - systemctl restart systemd-resolved + late-commands: + - sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT="\(.*\)"$/GRUB_CMDLINE_LINUX_DEFAULT=="\1 net.ifnames=0 biosdevname=0"/g' /target/etc/default/grub + - sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT=" net.ifnames/GRUB_CMDLINE_LINUX_DEFAULT="net.ifnames/g' /target/etc/default/grub + - echo "PermitRootLogin yes" >> /target/etc/ssh/sshd_config + - sudo chroot /target /bin/bash -c '/usr/sbin/useradd --create-home --shell /bin/bash --password vagrant vagrant' + - sudo chroot /target /bin/bash -c 'printf "vagrant\nvagrant\n" | passwd root' + - curtin in-target --target=/target -- update-grub + +# End of life config additions. +# sources_list: | +# deb $MIRROR jammy main restricted +# deb $MIRROR jammy-security main restricted +# conf: | +# Acquire::AllowReleaseInfoChange::Suite "true"; +# Acquire::AllowReleaseInfoChange::Origin "true"; +# Acquire::AllowReleaseInfoChange::Label "true"; +# Acquire::AllowReleaseInfoChange::Version "true"; +# Acquire::AllowReleaseInfoChange::Codename "true"; + +# End of life early command additions. +# - printf "\n91.189.91.124 old-releases.ubuntu.com\n" >> /etc/hosts + diff --git a/scripts/ubuntu2304/apt.sh b/scripts/ubuntu2304/apt.sh new file mode 100644 index 000000000..b55ee2354 --- /dev/null +++ b/scripts/ubuntu2304/apt.sh @@ -0,0 +1,171 @@ +#!/bin/bash -ex + +# If the TERM environment variable is set to dumb, tput will generate spurrious error messages. +[ "$TERM" == "dumb" ] && export TERM="vt100" + +retry() { + local COUNT=1 + local DELAY=0 + local RESULT=0 + while [[ "${COUNT}" -le 10 ]]; do + [[ "${RESULT}" -ne 0 ]] && { + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput setaf 1 + echo -e "\n${*} failed... retrying ${COUNT} of 10.\n" >&2 + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput sgr0 + } + "${@}" && { RESULT=0 && break; } || RESULT="${?}" + COUNT="$((COUNT + 1))" + + # Increase the delay with each iteration. + DELAY="$((DELAY + 10))" + sleep $DELAY + done + + [[ "${COUNT}" -gt 10 ]] && { + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput setaf 1 + echo -e "\nThe command failed 10 times.\n" >&2 + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput sgr0 + } + + return "${RESULT}" +} + +error() { + if [ $? -ne 0 ]; then + printf "\n\nAPT failed... again.\n\n"; + exit 1 + fi +} + +# To allow for automated installs, we disable interactive configuration steps. +export DEBIAN_FRONTEND=noninteractive +export DEBCONF_NONINTERACTIVE_SEEN=true + +# Temporarily disable IPv6, update the nameservers so packages download +# properly. A more permanent soulution is applied by the network +# configuration script. +sysctl net.ipv6.conf.all.disable_ipv6=1 +printf "nameserver 4.2.2.1\nnameserver 4.2.2.2\nnameserver 208.67.220.220\n" > /etc/resolv.conf + +# Disable upgrades to new releases, and prevent notifications from being added to motd. +sed -i -e 's/^Prompt=.*$/Prompt=never/' /etc/update-manager/release-upgrades + +if [ -f /usr/lib/ubuntu-release-upgrader/release-upgrade-motd ]; then +cat <<-EOF > /usr/lib/ubuntu-release-upgrader/release-upgrade-motd +#!/bin/sh +if [ -d /var/lib/ubuntu-release-upgrader/ ]; then + date +%s > /var/lib/ubuntu-release-upgrader/release-upgrade-available +fi +exit 0 +EOF +fi + +# Remove a confusing, and potentially conflicting sources file left by the install process. +[ -f /etc/apt/sources.list.curtin.old ] && rm --force /etc/apt/sources.list.curtin.old + +# If the APT configuration directory exists, we add our own config options. +if [ -d /etc/apt/apt.conf.d/ ]; then + +# Disable APT periodic so it doesn't cause problems. +if [ -f /etc/apt/apt.conf.d/10periodic ]; then + sed -i "/^APT::Periodic::Enable/d" /etc/apt/apt.conf.d/10periodic + sed -i "/^APT::Periodic::AutocleanInterval/d" /etc/apt/apt.conf.d/10periodic + sed -i "/^APT::Periodic::Unattended-Upgrade/d" /etc/apt/apt.conf.d/10periodic + sed -i "/^APT::Periodic::Update-Package-Lists/d" /etc/apt/apt.conf.d/10periodic + sed -i "/^APT::Periodic::Download-Upgradeable-Packages/d" /etc/apt/apt.conf.d/10periodic +fi + +cat <<-EOF >> /etc/apt/apt.conf.d/10periodic + +APT::Periodic::Enable "0"; +APT::Periodic::AutocleanInterval "0"; +APT::Periodic::Unattended-Upgrade "0"; +APT::Periodic::Update-Package-Lists "0"; +APT::Periodic::Download-Upgradeable-Packages "0"; + +EOF + +# We disable APT retries, to avoid inconsistent error handling, as it only retries some errors. Instead we let the retry function detect, and retry a given command regardless of the error. +cat <<-EOF >> /etc/apt/apt.conf.d/20retries + +APT::Acquire::Retries "0"; + +EOF + +fi + +# Keep the daily apt updater from deadlocking our the upgrade/install commands we are about to run. +# systemctl --quiet is-active snapd.service && systemctl stop snapd.service snapd.socket + +# Stop the active services/timers. +systemctl --quiet is-active apt-daily.timer && systemctl stop apt-daily.timer +systemctl --quiet is-active apt-daily-upgrade.timer && systemctl stop apt-daily-upgrade.timer +systemctl --quiet is-active update-notifier-download.timer && systemctl stop update-notifier-download.timer +systemctl --quiet is-active apt-daily.service && systemctl stop apt-daily.service +systemctl --quiet is-active packagekit.service && systemctl stop packagekit.service +systemctl --quiet is-active apt-daily-upgrade.service && systemctl stop apt-daily-upgrade.service +systemctl --quiet is-active unattended-upgrades.service && systemctl stop unattended-upgrades.service +systemctl --quiet is-active update-notifier-download.service && systemctl stop update-notifier-download.service + +# Disable them so they don't restart. +systemctl --quiet is-enabled apt-daily.timer && systemctl disable apt-daily.timer +systemctl --quiet is-enabled apt-daily-upgrade.timer && systemctl disable apt-daily-upgrade.timer +systemctl --quiet is-enabled update-notifier-download.timer && systemctl disable update-notifier-download.timer +systemctl --quiet is-enabled unattended-upgrades.service && systemctl disable unattended-upgrades.service +systemctl --quiet is-enabled apt-daily.service && systemctl mask apt-daily.service +systemctl --quiet is-enabled apt-daily-upgrade.service && systemctl mask apt-daily-upgrade.service +systemctl --quiet is-enabled update-notifier-download.service && systemctl mask update-notifier-download.service + +# Truncate the sources list in order to force a status purge. +# truncate --size=0 /etc/apt/sources.list + +# Run clean/autoclean/purge/update first, this will work around problems with ghost packages, and/or +# conflicting data in the repo index cache. After the cleanup is complete, we can proceed with the +# update/upgrade/install commands below. +apt-get --assume-yes clean ; error +apt-get --assume-yes autoclean ; error +apt-get --assume-yes update ; error + +# # Enable this once 23.04 reaches the end of its life. +# # Write out a nice and compact sources list. +# cat <<-EOF > /etc/apt/sources.list +# +# deb https://old-releases.ubuntu.com/ubuntu/ jammy main restricted universe multiverse +# deb https://old-releases.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse +# deb https://old-releases.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse +# deb https://old-releases.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse +# +# # deb-src https://old-releases.ubuntu.com/ubuntu/ jammy main restricted universe multiverse +# # deb-src https://old-releases.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse +# # deb-src https://old-releases.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse +# # deb-src https://old-releases.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse +# +# EOF +# +# # Some of the ubuntu archive servers appear to be missing files/packages.. +# printf "\n91.189.91.124 old-releases.ubuntu.com\n" >> /etc/hosts + +# Update the package database. +retry apt-get --assume-yes -o Dpkg::Options::="--force-confnew" update ; error + +# Ensure the linux-tools and linux-cloud-tools get updated with the kernel. +retry apt-get --assume-yes -o Dpkg::Options::="--force-confnew" install linux-cloud-tools-virtual + +# Upgrade the installed packages. +retry apt-get --assume-yes -o Dpkg::Options::="--force-confnew" upgrade ; error +retry apt-get --assume-yes -o Dpkg::Options::="--force-confnew" dist-upgrade ; error + +# Needed to retrieve source code, and other misc system tools. +retry apt-get --assume-yes install vim vim-nox gawk git git-man liberror-perl wget curl rsync gnupg mlocate sudo sysstat lsof pciutils usbutils lsb-release psmisc ; error + +# Enable the sysstat collection service. +sed -i -e "s|.*ENABLED=\".*\"|ENABLED=\"true\"|g" /etc/default/sysstat + +# Start the services we just added so the system will track its own performance. +systemctl enable sysstat.service && systemctl start sysstat.service + +# Setup vim as the default editor. +printf "alias vi=vim\n" >> /etc/profile.d/vim.sh + +# Populate the mlocate database during boot. +printf "@reboot root command bash -c '/etc/cron.daily/mlocate'\n" > /etc/cron.d/mlocate diff --git a/scripts/ubuntu2304/cleanup.sh b/scripts/ubuntu2304/cleanup.sh new file mode 100644 index 000000000..3d53d4889 --- /dev/null +++ b/scripts/ubuntu2304/cleanup.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +error() { + if [ $? -ne 0 ]; then + printf "\n\napt failed...\n\n"; + exit 1 + fi +} + +# To allow for automated installs, we disable interactive configuration steps. +export DEBIAN_FRONTEND=noninteractive +export DEBCONF_NONINTERACTIVE_SEEN=true + +# Keep the daily apt updater from deadlocking our cleanup commands. +systemctl --quiet is-active snapd.service && systemctl stop snapd.service snapd.socket +systemctl --quiet is-active packagekit.service && systemctl stop packagekit.service +systemctl --quiet is-active apt-daily.timer && systemctl stop apt-daily.timer +systemctl --quiet is-active apt-daily.service && systemctl stop apt-daily.service +systemctl --quiet is-active apt-daily-upgrade.timer && systemctl stop apt-daily-upgrade.timer +systemctl --quiet is-active apt-daily-upgrade.service && systemctl stop apt-daily-upgrade.service +systemctl --quiet is-active unattended-upgrades.service && systemctl stop unattended-upgrades.service +systemctl --quiet is-active update-notifier-donwload.service && systemctl stop update-notifier-donwload.service + +# Remove cloud init packages. +dpkg -l eatmydata &>/dev/null && apt-get --assume-yes purge eatmydata +dpkg -l libeatmydata1 &>/dev/null && apt-get --assume-yes purge libeatmydata1 +dpkg -l cloud-init &>/dev/null && apt-get --assume-yes purge cloud-init + +# We can probably also remove unattended-upgrades ... but we'll save that for later. +# dpkg -l unattended-upgrades &>/dev/null && apt-get --assume-yes purge unattended-upgrades + +# Cleanup unused packages. +apt-get --assume-yes autoremove; error +apt-get --assume-yes autoclean; error + +# Restore the system default apt retry value. +[ -f /etc/apt/apt.conf.d/20retries ] && rm --force /etc/apt/apt.conf.d/20retries + +# Remove leftover config files/directories. +[ -d /etc/cloud/ ] && rm --recursive --force /etc/cloud/ + +# Remove the workaround IP address for old-releases if its present. +sed -i '/old-releases.ubuntu.com/d' /etc/hosts + +# Remove log files. +[ -d /var/log/dist-upgrade/ ] && rm --recursive --force /var/log/dist-upgrade/ +[ -d /var/log/installer/ ] && rm --recursive --force /var/log/installer/ + +[ -f /var/log/apt/eipp.log.xz ] && rm --force /var/log/apt/eipp.log.xz +[ -f /var/log/cloud-init-output.log ] && rm --force /var/log/cloud-init-output.log +[ -f /var/log/cloud-init.log ] && rm --force /var/log/cloud-init.log +[ -f /var/log/bootstrap.log ] && rm --force /var/log/bootstrap.log +[ -f /var/log/dmesg.1.gz ] && rm --force /var/log/dmesg.1.gz +[ -f /var/log/dmesg.0 ] && rm --force /var/log/dmesg.0 +[ -f /var/log/dmesg ] && rm --force /var/log/dmesg + +[ -f /var/log/apt/history.log ] && truncate --size=0 truncate --size=0 /var/log/apt/history.log +[ -f /var/log/apt/term.log ] && truncate --size=0 truncate --size=0 /var/log/apt/term.log +[ -f /var/log/ubuntu-advantage-timer.log ] && truncate --size=0 truncate --size=0 /var/log/ubuntu-advantage-timer.log +[ -f /var/log/ubuntu-advantage.log ] && truncate --size=0 truncate --size=0 /var/log/ubuntu-advantage.log +[ -f /var/log/alternatives.log ] && truncate --size=0 truncate --size=0 /var/log/alternatives.log +[ -f /var/log/dpkg.log ] && truncate --size=0 truncate --size=0 /var/log/dpkg.log +[ -f /var/log/kern.log ] && truncate --size=0 /var/log/kern.log +[ -f /var/log/syslog ] && truncate --size=0 /var/log/syslog + +# Removethe random seed so a unique value is used the first time the box is booted. +systemctl --quiet is-active systemd-random-seed.service && systemctl stop systemd-random-seed.service +[ -f /var/lib/systemd/random-seed ] && rm --force /var/lib/systemd/random-seed + diff --git a/scripts/ubuntu2304/fixkvp.sh b/scripts/ubuntu2304/fixkvp.sh new file mode 100644 index 000000000..ab77fb166 --- /dev/null +++ b/scripts/ubuntu2304/fixkvp.sh @@ -0,0 +1,29 @@ +#!/bin/bash -eux + +# Fix to prevent the kv-kvp-daemon from hanging for 90 seconds during boot. +# https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1820063 + + +# Disable the daemon to remove the symlihk. +systemctl disable hv-kvp-daemon.service + +# Override the default unit file with a version that won't hang during boot ups. +cat <<-EOF > /etc/systemd/system/multi-user.target.wants/hv-kvp-daemon.service +[Unit] +Description=Hyper-V KVP Protocol Daemon +ConditionVirtualization=microsoft +ConditionPathExists=/dev/vmbus/hv_kvp +DefaultDependencies=no +BindsTo=sys-devices-virtual-misc-vmbus\x21hv_kvp.device +After=systemd-remount-fs.service +Before=shutdown.target cloud-init-local.service walinuxagent.service +Conflicts=shutdown.target +RequiresMountsFor=/var/lib/hyperv + +[Service] +ExecStart=/usr/sbin/hv_kvp_daemon -n + +[Install] +WantedBy=multi-user.target + +EOF diff --git a/scripts/ubuntu2304/fixtty.sh b/scripts/ubuntu2304/fixtty.sh new file mode 100644 index 000000000..9a21734b9 --- /dev/null +++ b/scripts/ubuntu2304/fixtty.sh @@ -0,0 +1,9 @@ +#!/bin/bash -eux + +# Fix the no tty bug with vagrant. +# https://github.com/mitchellh/vagrant/issues/1673 + +sed -i -e 's,^\(ACTIVE_CONSOLES="/dev/tty\).*,\11",' /etc/default/console-setup +for f in /etc/init/tty[^1]*.conf; do + rm --force "$f" +done diff --git a/scripts/ubuntu2304/floppy.sh b/scripts/ubuntu2304/floppy.sh new file mode 100644 index 000000000..ab0a6ca8f --- /dev/null +++ b/scripts/ubuntu2304/floppy.sh @@ -0,0 +1,5 @@ +#!/bin/bash -eux + +printf 'blacklist floppy\n' > /etc/modprobe.d/floppy.conf +mkinitramfs -o /boot/initrd.img-$(uname -r) $(uname -r) + diff --git a/scripts/ubuntu2304/motd.sh b/scripts/ubuntu2304/motd.sh new file mode 100644 index 000000000..218d68f7c --- /dev/null +++ b/scripts/ubuntu2304/motd.sh @@ -0,0 +1,28 @@ +#!/bin/bash -eux + +sed -i -e "s/motd=\/run\/motd.dynamic/motd=\/etc\/motd/g" /etc/pam.d/sshd +sed -i -e "s/\(.*pam_motd.so.*noupdate.*\)/# \1/g" /etc/pam.d/sshd + +sed -i -e "s/motd=\/run\/motd.dynamic/motd=\/etc\/motd/g" /etc/pam.d/login +sed -i -e "s/\(.*pam_motd.so.*noupdate.*\)/# \1/g" /etc/pam.d/login + +mkdir -p /root/.cache/ +touch /root/.cache/motd.legal-displayed + +if [ -d /home/vagrant/ ]; then + mkdir -p /home/vagrant/.cache/ + touch /home/vagrant/.cache/motd.legal-displayed + chown vagrant:vagrant /home/vagrant/.cache/ + chown vagrant:vagrant /home/vagrant/.cache/motd.legal-displayed +fi + +[ -f /etc/apt/apt.conf.d/99update-notifier ] && truncate --size=0 /etc/apt/apt.conf.d/99update-notifier +[ -f /etc/motd ] && truncate --size=0 /etc/motd + +systemctl --quiet is-active update-notifier-motd.timer && systemctl stop update-notifier-motd.timer +systemctl --quiet is-active motd-news.timer && systemctl stop motd-news.timer + +systemctl --quiet is-enabled update-notifier-motd.timer && systemctl disable update-notifier-motd.timer +systemctl --quiet is-enabled motd-news.timer && systemctl disable motd-news.timer + +[ -f /etc/default/motd-news ] && sed -i 's/.*ENABLE.*/ENABLE=0/g' /etc/default/motd-news diff --git a/scripts/ubuntu2304/network.sh b/scripts/ubuntu2304/network.sh new file mode 100644 index 000000000..c1792bbdc --- /dev/null +++ b/scripts/ubuntu2304/network.sh @@ -0,0 +1,91 @@ +#!/bin/bash -ex + +# If the TERM environment variable is set to dumb, tput will generate spurrious error messages. +[ "$TERM" == "dumb" ] && export TERM="vt100" + +retry() { + local COUNT=1 + local DELAY=0 + local RESULT=0 + while [[ "${COUNT}" -le 10 ]]; do + [[ "${RESULT}" -ne 0 ]] && { + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput setaf 1 + echo -e "\n${*} failed... retrying ${COUNT} of 10.\n" >&2 + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput sgr0 + } + "${@}" && { RESULT=0 && break; } || RESULT="${?}" + COUNT="$((COUNT + 1))" + + # Increase the delay with each iteration. + DELAY="$((DELAY + 10))" + sleep $DELAY + done + + [[ "${COUNT}" -gt 10 ]] && { + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput setaf 1 + echo -e "\nThe command failed 10 times.\n" >&2 + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput sgr0 + } + + return "${RESULT}" +} + +# To allow for automated installs, we disable interactive configuration steps. +export DEBIAN_FRONTEND=noninteractive +export DEBCONF_NONINTERACTIVE_SEEN=true + +# Disable IPv6 for the current boot. +sysctl net.ipv6.conf.all.disable_ipv6=1 + +# Ensure IPv6 stays disabled. +printf "\nnet.ipv6.conf.all.disable_ipv6 = 1\n" >> /etc/sysctl.conf + +# Set the hostname, and then ensure it will resolve properly. +if [[ "$PACKER_BUILD_NAME" =~ ^generic-ubuntu2304-(vmware|hyperv|libvirt|parallels|virtualbox)$ ]]; then + printf "ubuntu2304.localdomain\n" > /etc/hostname + printf "\n127.0.0.1 ubuntu2304.localdomain\n\n" >> /etc/hosts +else + printf "magma.localdomain\n" > /etc/hostname + printf "\n127.0.0.1 magma.localdomain\n\n" >> /etc/hosts +fi + +cat <<-EOF > /etc/netplan/01-netcfg.yaml +network: + version: 2 + renderer: networkd + ethernets: + eth0: + dhcp4: true + dhcp6: false + optional: true + nameservers: + addresses: [4.2.2.1, 4.2.2.2, 208.67.220.220] +EOF + +# Apply the network plan configuration. +netplan generate + +# Ensure a nameserver is being used that won't return an IP for non-existent domain names. +sed -i -e "s/#DNS=.*/DNS=4.2.2.1 4.2.2.2 208.67.220.220/g" /etc/systemd/resolved.conf +sed -i -e "s/#FallbackDNS=.*/FallbackDNS=/g" /etc/systemd/resolved.conf +sed -i -e "s/#Domains=.*/Domains=/g" /etc/systemd/resolved.conf +sed -i -e "s/#DNSSEC=.*/DNSSEC=yes/g" /etc/systemd/resolved.conf +sed -i -e "s/#Cache=.*/Cache=yes/g" /etc/systemd/resolved.conf +sed -i -e "s/#DNSStubListener=.*/DNSStubListener=yes/g" /etc/systemd/resolved.conf + +# Install ifplugd so we can monitor and auto-configure nics. +retry apt-get --assume-yes install ifplugd + +# Configure ifplugd to monitor the eth0 interface. +sed -i -e 's/INTERFACES=.*/INTERFACES="eth0"/g' /etc/default/ifplugd + +# Ensure the networking interfaces get configured on boot. +systemctl enable systemd-networkd.service + +# Ensure ifplugd also gets started, so the ethernet interface is monitored. +systemctl enable ifplugd.service + +# Reboot onto the new kernel (if applicable). +(shutdown -r +1) & +exit 0 + diff --git a/scripts/ubuntu2304/parallels.sh b/scripts/ubuntu2304/parallels.sh new file mode 100644 index 000000000..dfe3b6b0a --- /dev/null +++ b/scripts/ubuntu2304/parallels.sh @@ -0,0 +1,60 @@ +#!/bin/bash -ex + +# If the TERM environment variable is set to dumb, tput will generate spurrious error messages. +[ "$TERM" == "dumb" ] && export TERM="vt100" + +retry() { + local COUNT=1 + local DELAY=0 + local RESULT=0 + while [[ "${COUNT}" -le 10 ]]; do + [[ "${RESULT}" -ne 0 ]] && { + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput setaf 1 + echo -e "\n${*} failed... retrying ${COUNT} of 10.\n" >&2 + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput sgr0 + } + "${@}" && { RESULT=0 && break; } || RESULT="${?}" + COUNT="$((COUNT + 1))" + + # Increase the delay with each iteration. + DELAY="$((DELAY + 10))" + sleep $DELAY + done + + [[ "${COUNT}" -gt 10 ]] && { + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput setaf 1 + echo -e "\nThe command failed 10 times.\n" >&2 + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput sgr0 + } + + return "${RESULT}" +} + +# Needed to check whether we're running atop Parallels. +export DEBIAN_FRONTEND=noninteractive +export DEBCONF_NONINTERACTIVE_SEEN=true + +retry apt-get --assume-yes install dmidecode + +# Bail if we are not running atop Parallels. +if [[ `dmidecode -s system-product-name` != "Parallels Virtual Platform" ]]; then + exit 0 +fi + +# Read in the version number. +PARALLELSVERSION=`cat /root/parallels-tools-version.txt` + +echo "Installing the Parallels tools, version $PARALLELSVERSION." + +mkdir -p /mnt/parallels/ +mount -o loop /root/parallels-tools-linux.iso /mnt/parallels/ + +/mnt/parallels/install --install-unattended-with-deps --verbose --progress \ + || (status="$?" ; echo "Parallels tools installation failed. Error: $status" ; cat /var/log/parallels-tools-install.log ; exit $status) + +umount /mnt/parallels/ +rmdir /mnt/parallels/ + +# Cleanup the guest additions. +rm --force /root/parallels-tools-linux.iso +rm --force /root/parallels-tools-version.txt diff --git a/scripts/ubuntu2304/profile.sh b/scripts/ubuntu2304/profile.sh new file mode 100644 index 000000000..3d70afa47 --- /dev/null +++ b/scripts/ubuntu2304/profile.sh @@ -0,0 +1,84 @@ +#!/bin/bash -eux + +cd /root/ && patch -p1 <<-EOF +diff --git a/.bashrc b/.bashrc +index f6939ee..545eaea 100644 +--- a/.bashrc ++++ b/.bashrc +@@ -7,14 +7,14 @@ + + # don't put duplicate lines in the history. See bash(1) for more options + # ... or force ignoredups and ignorespace +-HISTCONTROL=ignoredups:ignorespace ++HISTCONTROL=ignoredups + + # append to the history file, don't overwrite it + shopt -s histappend + + # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +-HISTSIZE=1000 +-HISTFILESIZE=2000 ++HISTSIZE=100000 ++HISTFILESIZE=100000 + + # check the window size after each command and, if necessary, + # update the values of LINES and COLUMNS. +@@ -30,7 +30,7 @@ fi + + # set a fancy prompt (non-color, unless we know we "want" color) + case "\$TERM" in +- xterm-color) color_prompt=yes;; ++ xterm-color|*-256color) color_prompt=yes;; + esac + + # uncomment for a colored prompt, if the terminal has the capability; turned +@@ -94,6 +94,6 @@ fi + # enable programmable completion features (you don't need to enable + # this, if it's already enabled in /etc/bash.bashrc and /etc/profile + # sources /etc/bash.bashrc). +-#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then +-# . /etc/bash_completion +-#fi ++if [ -f /etc/bash_completion ] && ! shopt -oq posix; then ++ . /etc/bash_completion ++fi +EOF + +cat <<-EOF > /root/.vimrc +set mouse-=a +EOF + +if [ -d /home/vagrant/ ] && [ -f /home/vagrant/.bashrc ]; then +cd /home/vagrant/ && patch -p1 <<-EOF +diff --git a/.bashrc b/.bashrc +index b488fcc..559370c 100644 +--- a/.bashrc ++++ b/.bashrc +@@ -10,14 +10,14 @@ esac + + # don't put duplicate lines or lines starting with space in the history. + # See bash(1) for more options +-HISTCONTROL=ignoreboth ++HISTCONTROL=ignoredups + + # append to the history file, don't overwrite it + shopt -s histappend + + # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +-HISTSIZE=1000 +-HISTFILESIZE=2000 ++HISTSIZE=100000 ++HISTFILESIZE=100000 + + # check the window size after each command and, if necessary, + # update the values of LINES and COLUMNS. +EOF +chown vagrant:vagrant /home/vagrant/.bashrc +fi + +if [ -d /home/vagrant/ ]; then +cat <<-EOF > /home/vagrant/.vimrc +set mouse-=a +EOF +chown vagrant:vagrant /home/vagrant/.vimrc +fi \ No newline at end of file diff --git a/scripts/ubuntu2304/qemu.sh b/scripts/ubuntu2304/qemu.sh new file mode 100644 index 000000000..ae12ab0db --- /dev/null +++ b/scripts/ubuntu2304/qemu.sh @@ -0,0 +1,62 @@ +#!/bin/bash -ex + +# If the TERM environment variable is set to dumb, tput will generate spurrious error messages. +[ "$TERM" == "dumb" ] && export TERM="vt100" + +retry() { + local COUNT=1 + local DELAY=0 + local RESULT=0 + while [[ "${COUNT}" -le 10 ]]; do + [[ "${RESULT}" -ne 0 ]] && { + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput setaf 1 + echo -e "\n${*} failed... retrying ${COUNT} of 10.\n" >&2 + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput sgr0 + } + "${@}" && { RESULT=0 && break; } || RESULT="${?}" + COUNT="$((COUNT + 1))" + + # Increase the delay with each iteration. + DELAY="$((DELAY + 10))" + sleep $DELAY + done + + [[ "${COUNT}" -gt 10 ]] && { + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput setaf 1 + echo -e "\nThe command failed 10 times.\n" >&2 + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput sgr0 + } + + return "${RESULT}" +} + +error() { + if [ $? -ne 0 ]; then + printf "\n\nqemu addons failed to install...\n\n"; + exit 1 + fi +} + + +# Bail if we are not running atop QEMU. +if [[ `dmidecode -s system-product-name` != "KVM" && `dmidecode -s system-manufacturer` != "QEMU" ]]; then + exit 0 +fi + +# Install the QEMU using Yum. +printf "Installing the QEMU Tools.\n" + +# To allow for automated installs, we disable interactive configuration steps. +export DEBIAN_FRONTEND=noninteractive +export DEBCONF_NONINTERACTIVE_SEEN=true + +retry apt-get --assume-yes install qemu-guest-agent; error + +# For some reason the VMWare tools are installed on QEMU guest images. +systemctl disable open-vm-tools.service + +# Boosts the available entropy which allows magma to start faster. +retry apt-get --assume-yes install haveged; error + +# Autostart the haveged daemon. +systemctl enable haveged.service diff --git a/scripts/ubuntu2304/vagrant.sh b/scripts/ubuntu2304/vagrant.sh new file mode 100644 index 000000000..d5e4988fa --- /dev/null +++ b/scripts/ubuntu2304/vagrant.sh @@ -0,0 +1,30 @@ +#!/bin/bash -x + +# Create the vagrant user account. +/usr/sbin/useradd vagrant + +# Enable exit/failure on error. +set -eux + +printf "vagrant\nvagrant\n" | passwd vagrant +cat <<-EOF > /etc/sudoers.d/vagrant +Defaults:vagrant !fqdn +Defaults:vagrant !requiretty +vagrant ALL=(ALL) NOPASSWD: ALL +EOF +chmod 0440 /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 --utc > /etc/vagrant_box_build_time diff --git a/scripts/ubuntu2304/virtualbox.sh b/scripts/ubuntu2304/virtualbox.sh new file mode 100644 index 000000000..61a6eac74 --- /dev/null +++ b/scripts/ubuntu2304/virtualbox.sh @@ -0,0 +1,81 @@ +#!/bin/bash -ex + +# If the TERM environment variable is set to dumb, tput will generate spurrious error messages. +[ "$TERM" == "dumb" ] && export TERM="vt100" + +retry() { + local COUNT=1 + local DELAY=0 + local RESULT=0 + while [[ "${COUNT}" -le 10 ]]; do + [[ "${RESULT}" -ne 0 ]] && { + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput setaf 1 + echo -e "\n${*} failed... retrying ${COUNT} of 10.\n" >&2 + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput sgr0 + } + "${@}" && { RESULT=0 && break; } || RESULT="${?}" + COUNT="$((COUNT + 1))" + + # Increase the delay with each iteration. + DELAY="$((DELAY + 10))" + sleep $DELAY + done + + [[ "${COUNT}" -gt 10 ]] && { + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput setaf 1 + echo -e "\nThe command failed 10 times.\n" >&2 + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput sgr0 + } + + return "${RESULT}" +} + +error() { + if [ $? -ne 0 ]; then + printf "\n\nThe VirtualBox install failed...\n\n" + exit 1 + fi +} + +# Bail if we are not running atop VirtualBox. +if [[ `dmidecode -s system-product-name` != "VirtualBox" ]]; then + exit 0 +fi + +# Install the Virtual Box Tools from the Linux Guest Additions ISO. +printf "Installing the Virtual Box Tools.\n" + +# To allow for automated installs, we disable interactive configuration steps. +export DEBIAN_FRONTEND=noninteractive +export DEBCONF_NONINTERACTIVE_SEEN=true + +retry apt-get --assume-yes install virtualbox-guest-utils; error + +# Read in the version number. +export VBOXVERSION=`cat /root/VBoxVersion.txt` + +# export DEBIAN_FRONTEND=noninteractive +# export DEBCONF_NONINTERACTIVE_SEEN=true +# apt-get --assume-yes install dkms build-essential module-assistant linux-headers-$(uname -r); error +# +# # The group vboxsf is needed for shared folder access. +# getent group vboxsf >/dev/null || groupadd --system vboxsf; error +# getent passwd vboxadd >/dev/null || useradd --system --gid bin --home-dir /var/run/vboxadd --shell /sbin/nologin vboxadd; error +# +# mkdir -p /mnt/virtualbox; error +# mount -o loop /root/VBoxGuestAdditions.iso /mnt/virtualbox; error +# +# # For some reason the vboxsf module fails the first time, but installs +# # successfully if we run the installer a second time. +# sh /mnt/virtualbox/VBoxLinuxAdditions.run --nox11 || sh /mnt/virtualbox/VBoxLinuxAdditions.run --nox11; error +# ln -s /opt/VBoxGuestAdditions-$VBOXVERSION/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions; error +# +# umount /mnt/virtualbox; error +rm -rf /root/VBoxVersion.txt; error +rm -rf /root/VBoxGuestAdditions.iso; error + +# Boosts the available entropy which allows magma to start faster. +retry apt-get --assume-yes install haveged; error + +# Autostart the haveged daemon. +systemctl enable haveged.service diff --git a/scripts/ubuntu2304/vmware.sh b/scripts/ubuntu2304/vmware.sh new file mode 100644 index 000000000..5c29a0df7 --- /dev/null +++ b/scripts/ubuntu2304/vmware.sh @@ -0,0 +1,76 @@ +#!/bin/bash -ex + +# If the TERM environment variable is set to dumb, tput will generate spurrious error messages. +[ "$TERM" == "dumb" ] && export TERM="vt100" + +retry() { + local COUNT=1 + local DELAY=0 + local RESULT=0 + while [[ "${COUNT}" -le 10 ]]; do + [[ "${RESULT}" -ne 0 ]] && { + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput setaf 1 + echo -e "\n${*} failed... retrying ${COUNT} of 10.\n" >&2 + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput sgr0 + } + "${@}" && { RESULT=0 && break; } || RESULT="${?}" + COUNT="$((COUNT + 1))" + + # Increase the delay with each iteration. + DELAY="$((DELAY + 10))" + sleep $DELAY + done + + [[ "${COUNT}" -gt 10 ]] && { + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput setaf 1 + echo -e "\nThe command failed 10 times.\n" >&2 + [ "`which tput 2> /dev/null`" != "" ] && [ -n "$TERM" ] && tput sgr0 + } + + return "${RESULT}" +} + +error() { + if [ $? -ne 0 ]; then + printf "\n\nvmware install failed...\n\n"; + exit 1 + fi +} + + +# Bail if we are not running inside VMWare. +if [[ `dmidecode -s system-product-name` != "VMware Virtual Platform" ]]; then + exit 0 +fi + +# Install the VMWare Tools from the Linux ISO. +printf "Installing the VMWare Tools.\n" + +# To allow for automated installs, we disable interactive configuration steps. +export DEBIAN_FRONTEND=noninteractive +export DEBCONF_NONINTERACTIVE_SEEN=true + +retry apt-get --assume-yes install open-vm-tools ethtool libdumbnet1 zerofree +systemctl enable open-vm-tools.service +systemctl start open-vm-tools.service + +#mkdir -p /mnt/vmware; error +#mount -o loop /root/linux.iso /mnt/vmware; error + +#cd /tmp; error +#tar xzf /mnt/vmware/VMwareTools-*.tar.gz; error + +#umount /mnt/vmware; error +rm -rf /root/linux.iso; error + +#/tmp/vmware-tools-distrib/vmware-install.pl -d; error +#rm -rf /tmp/vmware-tools-distrib; error + +# Boosts the available entropy which allows magma to start faster. +retry apt-get --assume-yes install haveged; error + +# Autostart the haveged daemon. +systemctl enable haveged.service + +# Fix the SSH NAT issue on VMWare systems. +printf "\nIPQoS lowdelay throughput\n" >> /etc/ssh/sshd_config diff --git a/tpl/generic-ubuntu2304.rb b/tpl/generic-ubuntu2304.rb new file mode 100644 index 000000000..cc63a9365 --- /dev/null +++ b/tpl/generic-ubuntu2304.rb @@ -0,0 +1,63 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure(2) do |config| + + config.vm.boot_timeout = 1800 + # config.vm.box = "generic/bazinga" + # config.vm.hostname = "bazinga.box" + 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 = "virtio" + v.driver = "kvm" + v.video_vram = 256 + v.memory = 2048 + v.cpus = 2 + v.graphics_type = "none" + 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.customize ["modifyvm", :id, "--memory", 2048] + v.customize ["modifyvm", :id, "--vram", 256] + v.customize ["modifyvm", :id, "--cpus", 2] + v.gui = false + end + + ["vmware_fusion", "vmware_workstation", "vmware_desktop"].each do |provider| + config.vm.provider provider do |v, override| + v.whitelist_verified = true + v.gui = false + v.vmx["cpuid.coresPerSocket"] = "1" + v.vmx["memsize"] = "2048" + v.vmx["numvcpus"] = "2" + end + end + +end diff --git a/tpl/roboxes-ubuntu2304.rb b/tpl/roboxes-ubuntu2304.rb new file mode 100644 index 000000000..496ce95f7 --- /dev/null +++ b/tpl/roboxes-ubuntu2304.rb @@ -0,0 +1,62 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure(2) do |config| + + config.vm.boot_timeout = 1800 + # config.vm.box = "roboxes/bazinga" + # config.vm.hostname = "bazinga.roboxes" + 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 = "virtio" + 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.customize ["modifyvm", :id, "--memory", 2048] + v.customize ["modifyvm", :id, "--vram", 256] + v.customize ["modifyvm", :id, "--cpus", 2] + v.gui = false + end + + ["vmware_fusion", "vmware_workstation", "vmware_desktop"].each do |provider| + config.vm.provider provider do |v, override| + v.whitelist_verified = true + v.gui = false + v.vmx["cpuid.coresPerSocket"] = "1" + v.vmx["memsize"] = "2048" + v.vmx["numvcpus"] = "2" + end + end + +end