-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add server libvirt install script for debian servers
- Loading branch information
1 parent
af24cd4
commit 31d94eb
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,76 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo -e "\n\nEverything is now getting setup. This process will take a few minutes...\n\n" | ||
|
||
sudo apt update && sudo apt install gpg jq -y && sudo apt clean | ||
|
||
#remove unattended upgrades | ||
sudo apt-get remove --purge unattended-upgrades || true | ||
|
||
#Install tailscale | ||
curl -fsSL https://tailscale.com/install.sh | sh | ||
|
||
#Install nix package manager | ||
sh <(curl -L https://nixos.org/nix/install) --daemon --yes | ||
|
||
# Load the Nix environment | ||
. /etc/profile.d/nix.sh | ||
|
||
# Install packages from a pinned version of Nixpkgs | ||
nix-env -iA \ | ||
-f https://github.com/NixOS/nixpkgs/archive/53f3c92b4d1f5f297258954c5026e39c45afd180.tar.gz \ | ||
libvirt qemu bridge-utils virt-manager dnsmasq | ||
|
||
# Find the Nix-installed dnsmasq binary | ||
DNSMASQ_BIN=$(which dnsmasq) | ||
LIBVIRTD_BIN=$(which libvirtd) | ||
|
||
|
||
if [[ -z "$DNSMASQ_BIN" || -z "$LIBVIRTD_BIN" ]]; then | ||
echo "Error: One or both binaries (dnsmasq, libvirtd) not found after installation!" | ||
exit 1 | ||
fi | ||
|
||
# Create a systemd service for dnsmasq | ||
echo "Creating systemd service for dnsmasq..." | ||
sudo bash -c "cat > /etc/systemd/system/dnsmasq-nix.service" <<EOF | ||
[Unit] | ||
Description=DNS caching server (via Nix) | ||
After=network.target | ||
[Service] | ||
ExecStart=$DNSMASQ_BIN --no-daemon | ||
Restart=always | ||
[Install] | ||
WantedBy=multi-user.target | ||
EOF | ||
|
||
# Create a systemd service for libvirtd | ||
echo "Creating systemd service for libvirtd..." | ||
sudo bash -c "cat > /etc/systemd/system/libvirtd-nix.service" <<EOF | ||
[Unit] | ||
Description=Virtualization daemon (via Nix) | ||
After=network.target | ||
[Service] | ||
ExecStart=$LIBVIRTD_BIN | ||
Restart=always | ||
[Install] | ||
WantedBy=multi-user.target | ||
EOF | ||
|
||
# Reload systemd, enable, and start the service | ||
echo "Enabling and starting dnsmasq service..." | ||
sudo systemctl daemon-reload | ||
sudo systemctl enable dnsmasq-nix libvirtd-nix | ||
sudo systemctl start dnsmasq-nix libvirtd-nix | ||
|
||
# Verify the service is running | ||
echo "Checking dnsmasq service status..." | ||
sudo systemctl status dnsmasq-nix --no-pager | ||
|
||
echo "Checking libvirtd service status..." | ||
sudo systemctl status libvirtd-nix --no-page |