Compare commits
2 Commits
1dfc10b5c9
...
8c1c11fda7
Author | SHA1 | Date | |
---|---|---|---|
8c1c11fda7 | |||
3fafb78838 |
57
README.md
57
README.md
@ -40,7 +40,7 @@ luanti # Multiplayer infinite-world block sandbox with survival mode
|
|||||||
Instead of creating a recipe from scratch, let's make a copy of the `virtual-desktop.cfg` recipe, which provide a Desktop environment necessary for *luanti* to function
|
Instead of creating a recipe from scratch, let's make a copy of the `virtual-desktop.cfg` recipe, which provide a Desktop environment necessary for *luanti* to function
|
||||||
|
|
||||||
```
|
```
|
||||||
$ cp recipes/virtual-desktop.cfg recipes/virtual-desktop-luanti.cfg
|
cp recipes/virtual-desktop.cfg recipes/virtual-desktop-luanti.cfg
|
||||||
```
|
```
|
||||||
|
|
||||||
- Add the extra ingredient to the new recipe:
|
- Add the extra ingredient to the new recipe:
|
||||||
@ -54,52 +54,35 @@ echo "%include ../ingredients/extra-luanti.cfg # Sandbox video game engine" >> r
|
|||||||
- Prepare the dish by following the recipe, a process called 'flattening'
|
- Prepare the dish by following the recipe, a process called 'flattening'
|
||||||
|
|
||||||
```
|
```
|
||||||
$ ksflatten -c recipes/virtual-desktop-luanti.cfg -o dishes/virtual-desktop-luanti.cfg
|
ksflatten -c recipes/virtual-desktop-luanti.cfg -o dishes/virtual-desktop-luanti.cfg
|
||||||
```
|
```
|
||||||
|
|
||||||
> If any errors are detected, go back and fix them.
|
> If any errors are detected, go back and fix them.
|
||||||
|
|
||||||
It is time to test the new dish!
|
It is time to test the new dish!
|
||||||
|
|
||||||
- Navigate inside the `dishes` folder:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ cd dishes/
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Kickstart
|
#### Kickstart
|
||||||
|
|
||||||
* You can then kickstart your own installation:
|
- Make the `deploy-vm.sh` script executable
|
||||||
|
|
||||||
```
|
```
|
||||||
# virt-install \
|
chmod +x deploy-vm.sh
|
||||||
--connect qemu:///system \
|
```
|
||||||
--metadata description="Virtual desktop with Luanti" \
|
|
||||||
--os-variant fedora41 \
|
- Execute the script
|
||||||
--virt-type kvm \
|
|
||||||
--arch x86_64 \
|
```
|
||||||
--machine q35 \
|
./deploy-vm.sh
|
||||||
--name virtual-desktop-luanti \
|
```
|
||||||
--boot uefi \
|
|
||||||
--cpu host-model,topology.sockets=1,topology.cores=2,topology.threads=1 \
|
- Select the new dish, *virtual-desktop-luanti*
|
||||||
--vcpus 2 \
|
|
||||||
--memory 4096 \
|
```
|
||||||
--video virtio \
|
[...]
|
||||||
--graphics spice,listen=none \
|
Available files:
|
||||||
--channel spicevmc \
|
1. desktop-hypervisor-amdcpu
|
||||||
--autoconsole none \
|
[...]
|
||||||
--console pty,target.type=virtio \
|
14. virtual-desktop-luanti
|
||||||
--sound none \
|
|
||||||
--network type=user,model=virtio \
|
|
||||||
--controller type=virtio-serial \
|
|
||||||
--controller type=usb,model=none \
|
|
||||||
--controller type=scsi,model=virtio-scsi \
|
|
||||||
--input type=keyboard,bus=virtio \
|
|
||||||
--input type=tablet,bus=virtio \
|
|
||||||
--rng /dev/urandom,model=virtio \
|
|
||||||
--disk path=/var/lib/libvirt/images/virtual-desktop-luanti.img,format=raw,bus=virtio,cache=writeback,size=10 \
|
|
||||||
--location=https://download.fedoraproject.org/pub/fedora/linux/releases/42/Everything/x86_64/os/ \
|
|
||||||
--initrd-inject virtual-desktop-luanti.cfg --extra-args "inst.ks=file:virtual-desktop-luanti.cfg"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- When the installation is done, the machine will shut down
|
- When the installation is done, the machine will shut down
|
||||||
|
26
deploy-vm.sh
Executable file
26
deploy-vm.sh
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Function to execute a script
|
||||||
|
execute_script() {
|
||||||
|
local script_to_execute="$1"
|
||||||
|
echo "Executing: $script_to_execute"
|
||||||
|
"$script_to_execute" || {
|
||||||
|
echo "Script failed: $script_to_execute"
|
||||||
|
return 1 # Indicate failure
|
||||||
|
}
|
||||||
|
return 0 # Indicate success
|
||||||
|
}
|
||||||
|
|
||||||
|
# Array of scripts
|
||||||
|
scripts=(
|
||||||
|
"./scripts/core-count.sh"
|
||||||
|
"./scripts/system-memory.sh"
|
||||||
|
"./scripts/deploy-distro.sh"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Iterate through the scripts and execute them
|
||||||
|
for script in "${scripts[@]}"; do
|
||||||
|
execute_script "$script"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "All scripts executed."
|
13
scripts/core-count.sh
Executable file
13
scripts/core-count.sh
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get the core count using nproc --all
|
||||||
|
core_count=$(nproc --all)
|
||||||
|
|
||||||
|
# Check if nproc --all returns a numerical value greater than 2
|
||||||
|
if (( core_count > 1 )); then
|
||||||
|
echo "System has more than 1 core (nproc --all: $core_count)."
|
||||||
|
else
|
||||||
|
echo "Warning: System has only $core_count core)."
|
||||||
|
echo "The script requires at least two cores"
|
||||||
|
exit 1 # Exit with an error code to indicate the condition is not met
|
||||||
|
fi
|
60
scripts/deploy-distro.sh
Executable file
60
scripts/deploy-distro.sh
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get a list of files in the directory dishes without extensions
|
||||||
|
mapfile -t dish_name < <(find "dishes/" -maxdepth 1 -type f -printf "%f\n" | sed 's/\.[^.]*$//')
|
||||||
|
|
||||||
|
# Check if there are any files
|
||||||
|
if [ ${#dish_name[@]} -eq 0 ]; then
|
||||||
|
echo "No files found in the directory ../dishes."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Display the files with numbered options
|
||||||
|
echo "Available files:"
|
||||||
|
for i in "${!dish_name[@]}"; do
|
||||||
|
echo "$((i + 1)). ${dish_name[$i]}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Prompt the user to select a file
|
||||||
|
read -r -p "Enter the number of the file you want to select: " choice
|
||||||
|
|
||||||
|
# Validate the user's choice
|
||||||
|
if ! [[ "$choice" =~ ^[0-9]+$ ]] || (( choice < 1 )) || (( choice > ${#dish_name[@]} )); then
|
||||||
|
echo "Invalid choice. Please enter a number from 1 to ${#dish_name[@]}."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get the selected filename
|
||||||
|
vm_name="${dish_name[$((choice - 1))]}"
|
||||||
|
|
||||||
|
# Output the selected filename
|
||||||
|
echo "You selected: $vm_name"
|
||||||
|
|
||||||
|
# virt-install command with user-defined VM name
|
||||||
|
virt-install \
|
||||||
|
--connect qemu:///system \
|
||||||
|
--os-variant fedora41 \
|
||||||
|
--virt-type kvm \
|
||||||
|
--arch x86_64 \
|
||||||
|
--machine q35 \
|
||||||
|
--name "$vm_name" \
|
||||||
|
--boot uefi \
|
||||||
|
--cpu host-model,topology.sockets=1,topology.cores=2,topology.threads=1 \
|
||||||
|
--vcpus 2 \
|
||||||
|
--memory 2048 \
|
||||||
|
--video virtio \
|
||||||
|
--autoconsole none \
|
||||||
|
--console pty,target.type=virtio \
|
||||||
|
--sound none \
|
||||||
|
--network type=user,model=virtio \
|
||||||
|
--controller type=virtio-serial \
|
||||||
|
--controller type=usb,model=none \
|
||||||
|
--controller type=scsi,model=virtio-scsi \
|
||||||
|
--input type=keyboard,bus=virtio \
|
||||||
|
--input type=tablet,bus=virtio \
|
||||||
|
--rng /dev/urandom,model=virtio \
|
||||||
|
--disk path=/var/lib/libvirt/images/"$vm_name".img,format=raw,bus=virtio,cache=writeback,size=10 \
|
||||||
|
--location=https://download.fedoraproject.org/pub/fedora/linux/releases/42/Everything/x86_64/os/ \
|
||||||
|
--initrd-inject "dishes/$vm_name".cfg --extra-args "inst.ks=file:dishes/$vm_name.cfg"
|
||||||
|
|
||||||
|
echo "virt-install command executed with VM name: $vm_name"
|
14
scripts/system-memory.sh
Executable file
14
scripts/system-memory.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Read the total memory from /proc/meminfo in MiB
|
||||||
|
total_memory=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
|
||||||
|
|
||||||
|
# Convert to MiB by dividing by 1024 (since MemTotal is in KiB)
|
||||||
|
total_memory_mb=$(( total_memory / 1024 ))
|
||||||
|
|
||||||
|
if [[ "$total_memory_mb" -lt "2048" ]]; then
|
||||||
|
echo "Not enough RAM: The system has only ${total_memory_mb}MiB of RAM, but at least 2048 MiB is required."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Sufficient memory available. System has ${total_memory_mb}MiB of RAM."
|
||||||
|
fi
|
Reference in New Issue
Block a user