-
Notifications
You must be signed in to change notification settings - Fork 345
feat: Add Arch virtualization setup script #813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ChrisTitusTech
merged 7 commits into
ChrisTitusTech:main
from
jeevithakannan2:virtual-manager
Nov 7, 2024
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b5520a3
Add Arch virtualization setup script
jeevithakannan2 9a4ed01
Replace hardcoded pacman
jeevithakannan2 1ee60ff
Update core/tabs/system-setup/arch/virtualization.sh
jeevithakannan2 8e400f7
Update virtualization.sh
jeevithakannan2 41ff081
Update core/tabs/system-setup/arch/virtualization.sh
jeevithakannan2 e9aa592
Merge remote-tracking branch 'upstream/main' into virtual-manager
jeevithakannan2 2891ccd
chore: formatting
jeevithakannan2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#!/bin/sh -e | ||
|
||
. ../../common-script.sh | ||
|
||
installQEMUDesktop() { | ||
if ! command_exists qemu-img; then | ||
printf "%b\n" "${YELLOW}Installing QEMU.${RC}" | ||
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm qemu-desktop | ||
else | ||
printf "%b\n" "${GREEN}QEMU is already installed.${RC}" | ||
fi | ||
checkKVM | ||
} | ||
|
||
installQEMUEmulators() { | ||
if ! "$PACKAGER" -Q | grep -q "qemu-emulators-full "; then | ||
printf "%b\n" "${YELLOW}Installing QEMU-Emulators.${RC}" | ||
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm qemu-emulators-full swtpm | ||
else | ||
printf "%b\n" "${GREEN}QEMU-Emulators already installed.${RC}" | ||
fi | ||
} | ||
|
||
installVirtManager() { | ||
if ! command_exists virt-manager; then | ||
printf "%b\n" "${YELLOW}Installing Virt-Manager.${RC}" | ||
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm virt-manager | ||
else | ||
printf "%b\n" "${GREEN}Virt-Manager already installed.${RC}" | ||
fi | ||
} | ||
|
||
checkKVM() { | ||
hardware_avail="$(grep -E 'vmx|svm|0xc0f' /proc/cpuinfo)" | ||
kernel_avail="$(zgrep CONFIG_KVM= /proc/config.gz | cut -d '=' -f 2)" | ||
modules_avail="$(lsmod | grep kvm)" | ||
if [ -z "$hardware_avail" ] || [ -z "$modules_avail" ] || { [ "$kernel_avail" != "m" ] && [ "$kernel_avail" != "y" ]; }; then | ||
printf "%b\n" "${RED}KVM is not avaiable please refer https://wiki.archlinux.org/title/KVM for more information.${RC}" | ||
jeevithakannan2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
else | ||
"$ESCALATION_TOOL" usermod "$USER" -aG kvm | ||
fi | ||
} | ||
|
||
setupLibvirt() { | ||
printf "%b\n" "${YELLOW}Configuring Libvirt.${RC}" | ||
if "$PACKAGER" -Q | grep -q "iptables "; then | ||
"$ESCALATION_TOOL" "$PACKAGER" -Rdd --noconfirm iptables | ||
fi | ||
|
||
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm dnsmasq iptables-nft | ||
"$ESCALATION_TOOL" sed -i 's/^#\?firewall_backend\s*=\s*".*"/firewall_backend = "iptables"/' "/etc/libvirt/network.conf" | ||
|
||
if systemctl is-active --quiet polkit; then | ||
"$ESCALATION_TOOL" sed -i 's/^#\?auth_unix_ro\s*=\s*".*"/auth_unix_ro = "polkit"/' "/etc/libvirt/libvirtd.conf" | ||
"$ESCALATION_TOOL" sed -i 's/^#\?auth_unix_rw\s*=\s*".*"/auth_unix_rw = "polkit"/' "/etc/libvirt/libvirtd.conf" | ||
fi | ||
|
||
"$ESCALATION_TOOL" usermod "$USER" -aG libvirt | ||
|
||
for value in libvirt libvirt_guest; do | ||
if ! grep -wq "$value" /etc/nsswitch.conf;then | ||
"$ESCALATION_TOOL" sed -i "/^hosts:/ s/$/ ${value}/" /etc/nsswitch.conf | ||
fi | ||
done | ||
|
||
"$ESCALATION_TOOL" systemctl enable --now libvirtd.service | ||
"$ESCALATION_TOOL" virsh net-autostart default | ||
|
||
checkKVM | ||
} | ||
|
||
installLibvirt() { | ||
if ! command_exists libvirtd; then | ||
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm libvirt dmidecode | ||
else | ||
printf "%b\n" "${GREEN}Libvirt is already installed.${RC}" | ||
fi | ||
setupLibvirt | ||
} | ||
|
||
main() { | ||
printf "%b\n" "${YELLOW}Choose what to install:${RC}" | ||
printf "%b\n" "1. ${YELLOW}QEMU${RC}" | ||
printf "%b\n" "2. ${YELLOW}QEMU-Emulators ( Extended architectures )${RC}" | ||
printf "%b\n" "3. ${YELLOW}Libvirt${RC}" | ||
printf "%b\n" "4. ${YELLOW}Virtual-Manager${RC}" | ||
printf "%b\n" "5. ${YELLOW}All${RC}" | ||
printf "%b" "Enter your choice [1-5]: " | ||
read -r CHOICE | ||
case "$CHOICE" in | ||
1) installQEMUDesktop ;; | ||
2) installQEMUEmulators ;; | ||
3) installLibvirt ;; | ||
4) installVirtManager ;; | ||
5) installQEMUDesktop | ||
installQEMUEmulators | ||
installLibvirt | ||
installVirtManager | ||
;; | ||
*) printf "%b\n" "${RED}Invalid choice.${RC}" && exit 1 ;; | ||
esac | ||
} | ||
|
||
checkEnv | ||
checkEscalationTool | ||
main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.