From ab9482c2f90e8ca7539e9de3ea9692409af2f3a4 Mon Sep 17 00:00:00 2001 From: Tommy Date: Fri, 1 Dec 2023 20:19:31 -0700 Subject: [PATCH] Differentiating bare metal and virtual Ubuntu server installs Signed-off-by: Tommy --- Ubuntu-22.04-Server.sh | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/Ubuntu-22.04-Server.sh b/Ubuntu-22.04-Server.sh index 1e88dad..1fd9b41 100644 --- a/Ubuntu-22.04-Server.sh +++ b/Ubuntu-22.04-Server.sh @@ -158,9 +158,41 @@ ExecStart=/usr/bin/fwupdmgr update' | tee /etc/systemd/system/fwupd-refresh.serv sudo systemctl daemon-reload sudo systemctl enable --now fwupd-refresh.timer -# Setup tuned -sudo apt install tuned -y -sudo tuned-adm profile virtual-guest - # Enable fstrim.timer sudo systemctl enable --now fstrim.timer + +### Differentiating bare metal and virtual installs + +# Installing tuned first here because virt-what is 1 of its dependencies anyways +sudo apt install tuned -y + +virt_type=$(echo $(virt-what)) +if [ "$virt_type" = "" ]; then + output "Virtualization: Bare Metal." +elif [ "$virt_type" = "openvz lxc" ]; then + output "Virtualization: OpenVZ 7." +elif [ "$virt_type" = "xen xen-hvm" ]; then + output "Virtualization: Xen-HVM." +elif [ "$virt_type" = "xen xen-hvm aws" ]; then + output "Virtualization: Xen-HVM on AWS." +else + output "Virtualization: $virt_type." +fi + +# Setup tuned +if [ "$virt_type" = "" ]; then + sudo tuned-adm profile latency-performance +else + sudo tuned-adm profile virtual-guest +fi + +# Setup fwupd +if [ "$virt_type" = "" ]; then + sudo apt install fwupd -y + echo 'UriSchemes=file;https' | sudo tee -a /etc/fwupd/fwupd.conf + sudo systemctl restart fwupd + mkdir -p /etc/systemd/system/fwupd-refresh.service.d + sudo curl https://raw.githubusercontent.com/TommyTran732/Linux-Setup-Scripts/main/etc/systemd/system/fwupd-refresh.service.d/override.conf -o /etc/systemd/system/fwupd-refresh.service.d/override.conf + sudo systemctl daemon-reload + sudo systemctl enable --now fwupd-refresh.timer +fi \ No newline at end of file