From a85ad83f90eec31135dc876b2dd0bb0e867a88a6 Mon Sep 17 00:00:00 2001 From: zstg Date: Sun, 18 Aug 2024 18:04:38 +0530 Subject: [PATCH] Add systemd service to autostart Calamares, improve VM support --- airootfs/etc/calamares | 2 +- airootfs/etc/systemd/system/Calamares.service | 10 ++ .../multi-user.target.wants/Calamares.service | 1 + .../multi-user.target.wants/vcheck.service | 1 + .../etc/systemd/system/pacman-init.service | 1 + airootfs/etc/xdg/autostart/Calamares.desktop | 4 - airootfs/etc/xdg/autostart/custom.desktop | 4 - airootfs/usr/lib/systemd/system/ucode.service | 10 ++ .../system/virtual-machine-check.service | 10 ++ .../usr/local/bin/StratOS-configure-bedrock | 1 + airootfs/usr/local/bin/StratOS-install-apt | 0 airootfs/usr/local/bin/ucode | 21 +++ airootfs/usr/local/bin/vcheck | 149 ++++++++++++++++++ profiledef.sh | 5 +- 14 files changed, 208 insertions(+), 11 deletions(-) create mode 100644 airootfs/etc/systemd/system/Calamares.service create mode 120000 airootfs/etc/systemd/system/multi-user.target.wants/Calamares.service create mode 120000 airootfs/etc/systemd/system/multi-user.target.wants/vcheck.service delete mode 100644 airootfs/etc/xdg/autostart/Calamares.desktop delete mode 100644 airootfs/etc/xdg/autostart/custom.desktop create mode 100644 airootfs/usr/lib/systemd/system/ucode.service create mode 100644 airootfs/usr/lib/systemd/system/virtual-machine-check.service mode change 100644 => 100755 airootfs/usr/local/bin/StratOS-install-apt create mode 100755 airootfs/usr/local/bin/ucode create mode 100755 airootfs/usr/local/bin/vcheck diff --git a/airootfs/etc/calamares b/airootfs/etc/calamares index 2b4cebe59..24a0a2ea8 160000 --- a/airootfs/etc/calamares +++ b/airootfs/etc/calamares @@ -1 +1 @@ -Subproject commit 2b4cebe599a77283b67047f8b39c0c241d262f79 +Subproject commit 24a0a2ea8e9f83df2a6b7869a018d1c11901cadc diff --git a/airootfs/etc/systemd/system/Calamares.service b/airootfs/etc/systemd/system/Calamares.service new file mode 100644 index 000000000..996589523 --- /dev/null +++ b/airootfs/etc/systemd/system/Calamares.service @@ -0,0 +1,10 @@ +[Unit] +Description=Start Calamares +After=graphical-session.target + +[Service] +ExecStart=/usr/bin/sudo -E /usr/bin/calamares -D8 +Restart=on-failure + +[Install] +WantedBy=default.target diff --git a/airootfs/etc/systemd/system/multi-user.target.wants/Calamares.service b/airootfs/etc/systemd/system/multi-user.target.wants/Calamares.service new file mode 120000 index 000000000..b7d4fd856 --- /dev/null +++ b/airootfs/etc/systemd/system/multi-user.target.wants/Calamares.service @@ -0,0 +1 @@ +/etc/systemd/system/Calamares.service \ No newline at end of file diff --git a/airootfs/etc/systemd/system/multi-user.target.wants/vcheck.service b/airootfs/etc/systemd/system/multi-user.target.wants/vcheck.service new file mode 120000 index 000000000..1303d33a6 --- /dev/null +++ b/airootfs/etc/systemd/system/multi-user.target.wants/vcheck.service @@ -0,0 +1 @@ +/usr/lib/systemd/system/virtual-machine-check.service \ No newline at end of file diff --git a/airootfs/etc/systemd/system/pacman-init.service b/airootfs/etc/systemd/system/pacman-init.service index b82488434..075b93ba3 100644 --- a/airootfs/etc/systemd/system/pacman-init.service +++ b/airootfs/etc/systemd/system/pacman-init.service @@ -10,6 +10,7 @@ Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/pacman-key --init ExecStart=/usr/bin/pacman-key --populate +ExecStart=/usr/bin/pacman -Sy [Install] WantedBy=multi-user.target diff --git a/airootfs/etc/xdg/autostart/Calamares.desktop b/airootfs/etc/xdg/autostart/Calamares.desktop deleted file mode 100644 index ebaf579c3..000000000 --- a/airootfs/etc/xdg/autostart/Calamares.desktop +++ /dev/null @@ -1,4 +0,0 @@ -[Desktop Entry] -Type=Application -Name=Calamares -Exec=sh -c "sudo -E calamares -D8" diff --git a/airootfs/etc/xdg/autostart/custom.desktop b/airootfs/etc/xdg/autostart/custom.desktop deleted file mode 100644 index 5d830420f..000000000 --- a/airootfs/etc/xdg/autostart/custom.desktop +++ /dev/null @@ -1,4 +0,0 @@ -# Start GNOME in the live environment -[Desktop Entry] -Type=Application -Exec=gnome-session \ No newline at end of file diff --git a/airootfs/usr/lib/systemd/system/ucode.service b/airootfs/usr/lib/systemd/system/ucode.service new file mode 100644 index 000000000..b05fb6920 --- /dev/null +++ b/airootfs/usr/lib/systemd/system/ucode.service @@ -0,0 +1,10 @@ +[Unit] +Description=Start Calamares +After=graphical-session.target + +[Service] +ExecStart=/usr/local/bin/ucode +Restart=on-failure + +[Install] +WantedBy=default.target diff --git a/airootfs/usr/lib/systemd/system/virtual-machine-check.service b/airootfs/usr/lib/systemd/system/virtual-machine-check.service new file mode 100644 index 000000000..81726b907 --- /dev/null +++ b/airootfs/usr/lib/systemd/system/virtual-machine-check.service @@ -0,0 +1,10 @@ +[Unit] +Description=Start Calamares +After=graphical-session.target + +[Service] +ExecStart=/usr/local/bin/vcheck +Restart=on-failure + +[Install] +WantedBy=default.target diff --git a/airootfs/usr/local/bin/StratOS-configure-bedrock b/airootfs/usr/local/bin/StratOS-configure-bedrock index cfa7faaed..a6a4b1362 100755 --- a/airootfs/usr/local/bin/StratOS-configure-bedrock +++ b/airootfs/usr/local/bin/StratOS-configure-bedrock @@ -3,3 +3,4 @@ echo "Setting up Bedrock!" # curl -sSL https://github.com/bedrocklinux/bedrocklinux-userland/releases/download/0.7.29/bedrock-linux-0.7.29-x86_64.sh > ./install-bedrock echo 'Not reversible!' | bash /usr/local/bin/install-bedrock-x86_64 --hijack rm -f /etc/systemd/system/getty@tty1.service.d/autologin.conf # don't autologin as stratos anymore +rm -f /etc/systemd/system/multi-user.target.wants/Calamares.service /etc/systemd/system/Calamares.service 2>/dev/null # it will NOT run post-install anyways diff --git a/airootfs/usr/local/bin/StratOS-install-apt b/airootfs/usr/local/bin/StratOS-install-apt old mode 100644 new mode 100755 diff --git a/airootfs/usr/local/bin/ucode b/airootfs/usr/local/bin/ucode new file mode 100755 index 000000000..c286c82c1 --- /dev/null +++ b/airootfs/usr/local/bin/ucode @@ -0,0 +1,21 @@ +#!/bin/bash +#set -e +############################################################################### +# Author : DarkXero +# Website : https://xerolinux.xyz +############################################################################### + +cpu_vendor=$(cat /proc/cpuinfo | awk '/vendor_id/ {print $3}' | head -n 1) + +if [[ "$cpu_vendor" == "GenuineIntel" ]]; then + echo "Intel CPU detected." + sudo pacman -Rdd --noconfirm amd-ucode +elif [[ "$cpu_vendor" == "AuthenticAMD" ]]; then + echo "AMD CPU detected." + sudo pacman -Rdd --noconfirm intel-ucode +else + echo "Unknown CPU vendor: $cpu_vendor" + sudo pacman -Rdd --noconfirm intel-ucode amd-ucode +fi + +rm /usr/local/bin/ucode diff --git a/airootfs/usr/local/bin/vcheck b/airootfs/usr/local/bin/vcheck new file mode 100755 index 000000000..9a7dd2270 --- /dev/null +++ b/airootfs/usr/local/bin/vcheck @@ -0,0 +1,149 @@ +#!/bin/bash +#set -e +############################################################################### +# Author : DarkXero +# Website : https://xerolinux.xyz +############################################################################### +# +# DO NOT JUST RUN THIS. EXAMINE AND JUDGE. RUN AT YOUR OWN RISK. +# +############################################################################### + +result=$(systemd-detect-virt) + +while [ -e "/var/lib/pacman/db.lck" ]; +do + echo 'Pacman is not ready yet. Will try again in 5 seconds.' + seconds=$(($seconds + 5)) + sleep 5 + if [[ "$seconds" == "30" ]]; then + echo 'Warning: removing pacman db.lck!' + rm /var/lib/pacman/db.lck + fi +done + +echo "You are working on "$result + +if [ $result = "oracle" ]; + then + #remove vmware + if pacman -Qi open-vm-tools &> /dev/null; then + systemctl disable vmtoolsd.service + echo "Disabled vmtoolsd.service" + pacman -Rns open-vm-tools --noconfirm + echo "Removed open-vm-tools" + fi + + if pacman -Qi xf86-video-vmware &> /dev/null; then + pacman -Rns xf86-video-vmware --noconfirm + echo "Removed xf86-video-vmware" + fi + + if [ -f /etc/systemd/system/multi-user.target.wants/vmtoolsd.service ]; then + rm /etc/systemd/system/multi-user.target.wants/vmtoolsd.service + echo "Removed vmtoolsd.service if still exists" + fi + + #remove qemu + if pacman -Qi qemu-guest-agent &> /dev/null; then + systemctl disable qemu-guest-agent.service + pacman -Rns qemu-guest-agent --noconfirm + echo "Removed qemu-guest-agent" + fi +fi + +if [ $result = "kvm" ]; + then + #remove vmware + if pacman -Qi open-vm-tools &> /dev/null; then + systemctl disable vmtoolsd.service + echo "Disabled vmtoolsd.service" + pacman -Rns open-vm-tools --noconfirm + echo "Removed open-vm-tools" + fi + + if pacman -Qi xf86-video-vmware &> /dev/null; then + pacman -Rns xf86-video-vmware --noconfirm + echo "Removed xf86-video-vmware" + fi + + if [ -f /etc/systemd/system/multi-user.target.wants/vmtoolsd.service ]; then + rm /etc/systemd/system/multi-user.target.wants/vmtoolsd.service + echo "Removed vmtoolsd.service if still exists" + fi + + #remove virtualbox + if pacman -Qi virtualbox-guest-utils &> /dev/null; then + systemctl disable vboxservice.service + pacman -Rns virtualbox-guest-utils --noconfirm + echo "Removed virtualbox-guest-utils" + fi + if pacman -Qi virtualbox-guest-utils-nox &> /dev/null; then + systemctl disable vboxservice.service + pacman -Rns virtualbox-guest-utils-nox --noconfirm + echo "Removed virtualbox-guest-utils-nox" + fi +fi + +if [ $result = "vmware" ]; + then + #remove virtualbox + if pacman -Qi virtualbox-guest-utils &> /dev/null; then + systemctl disable vboxservice.service + pacman -Rns virtualbox-guest-utils --noconfirm + echo "Removed virtualbox-guest-utils" + fi + if pacman -Qi virtualbox-guest-utils-nox &> /dev/null; then + systemctl disable vboxservice.service + pacman -Rns virtualbox-guest-utils-nox --noconfirm + echo "Removed virtualbox-guest-utils-nox" + fi + + #remove qemu + if pacman -Qi qemu-guest-agent &> /dev/null; then + systemctl disable qemu-guest-agent.service + pacman -Rns qemu-guest-agent --noconfirm + echo "Removed qemu-guest-agent" + fi +fi + +if [ $result = "none" ]; + then + #remove virtualbox + if pacman -Qi virtualbox-guest-utils &> /dev/null; then + systemctl disable vboxservice.service + pacman -Rns virtualbox-guest-utils --noconfirm + echo "Removed virtualbox-guest-utils" + fi + + if pacman -Qi virtualbox-guest-utils-nox &> /dev/null; then + systemctl disable vboxservice.service + pacman -Rns virtualbox-guest-utils-nox --noconfirm + echo "Removed virtualbox-guest-utils-nox" + fi + + #remove vmware + if pacman -Qi open-vm-tools &> /dev/null; then + systemctl disable vmtoolsd.service + echo "Disabled vmtoolsd.service" + pacman -Rns open-vm-tools --noconfirm + echo "Removed open-vm-tools" + fi + + if pacman -Qi xf86-video-vmware &> /dev/null; then + pacman -Rns xf86-video-vmware --noconfirm + echo "Removed xf86-video-vmware" + fi + + if [ -f /etc/systemd/system/multi-user.target.wants/vmtoolsd.service ]; then + rm /etc/systemd/system/multi-user.target.wants/vmtoolsd.service + echo "Removed vmtoolsd.service if still exists" + fi + + #remove qemu + if pacman -Qi qemu-guest-agent &> /dev/null; then + systemctl disable qemu-guest-agent.service + pacman -Rns qemu-guest-agent --noconfirm + echo "Removed qemu-guest-agent" + fi +fi diff --git a/profiledef.sh b/profiledef.sh index 07d4c49ab..e11b1914f 100644 --- a/profiledef.sh +++ b/profiledef.sh @@ -29,9 +29,8 @@ file_permissions=( ["/usr/local/bin/neofetch"]="0:0:777" ["/usr/local/bin/install-using-pacman"]="0:0:777" ["/usr/local/bin/install-using-yay"]="0:0:777" - ["/usr/local/bin/install-using-flatpak"]="0:0:777" + ["/usr/local/bin/StratOS-install-apt"]="0:0:777" ["/usr/local/bin/StratOS-choose-atril"]="0:0:777" - ["/usr/local/bin/StratOS-choose-brave"]="0:0:777" ["/usr/local/bin/StratOS-choose-chromium"]="0:0:777" ["/usr/local/bin/StratOS-choose-evince"]="0:0:777" ["/usr/local/bin/StratOS-choose-firefox"]="0:0:777" @@ -51,4 +50,6 @@ file_permissions=( ["/usr/local/bin/StratOS-configure-gnome"]="0:0:777" ["/usr/local/bin/StratOS-configure-theme"]="0:0:777" ["/usr/local/bin/StratOS-configure-ubuntu"]="0:0:777" + ["/usr/local/bin/ucode"]="0:0:777" + ["/usr/local/bin/vcheck"]="0:0:777" )