Commenting out log command

This commit is contained in:
vandomej 2025-09-29 22:58:13 -07:00
parent 2c85175912
commit 8de7d2efd3

View file

@ -56,7 +56,7 @@ create_disk_image() {
local disk_path="$vm_path/disk.qcow2" local disk_path="$vm_path/disk.qcow2"
if [[ ! -f "$disk_path" ]]; then if [[ ! -f "$disk_path" ]]; then
log_info "Creating disk image for $vm_name..." # log_info "Creating disk image for $vm_name..."
qemu-img create -f qcow2 "$disk_path" "$DISK_SIZE" qemu-img create -f qcow2 "$disk_path" "$DISK_SIZE"
else else
log_warn "Disk image already exists for $vm_name" log_warn "Disk image already exists for $vm_name"
@ -81,42 +81,26 @@ create_vm_script() {
local script_path="$vm_path/start.sh" local script_path="$vm_path/start.sh"
cat > "$script_path" << 'EOF' # Use a function to escape the variables
cat > "$script_path" << EOF
#!/bin/bash #!/bin/bash
VM_NAME="$1" qemu-system-aarch64 \\
MAC_ADDRESS="$2" -name "$vm_name" \\
ISO_PATH="$3" -machine virt,highmem=off \\
DISK_PATH="$4" -accel hvf \\
CPUS="$5" -cpu host \\
MEMORY="$6" -smp "$CPUS" \\
-m "${MEMORY}M" \\
qemu-system-aarch64 \ -drive file="$disk_path",if=virtio,format=qcow2 \\
-name "$VM_NAME" \ -cdrom "$iso_path" \\
-machine virt,highmem=off \ -netdev user,id=net0 \\
-accel hvf \ -device virtio-net-pci,netdev=net0,mac=$mac_address \\
-cpu host \ -nographic \\
-smp "$CPUS" \
-m "${MEMORY}M" \
-drive file="$DISK_PATH",if=virtio,format=qcow2 \
-cdrom "$ISO_PATH" \
-netdev user,id=net0 \
-device virtio-net-pci,netdev=net0,mac="$MAC_ADDRESS" \
-nographic \
-serial mon:stdio -serial mon:stdio
EOF EOF
# Make the script executable and create a wrapper that passes the parameters
chmod +x "$script_path" chmod +x "$script_path"
echo "$script_path"
# Create a wrapper script that calls the main script with proper arguments
local wrapper_path="$vm_path/run.sh"
cat > "$wrapper_path" << EOF
#!/bin/bash
"$script_path" "$vm_name" "$mac_address" "$iso_path" "$disk_path" "$CPUS" "$MEMORY"
EOF
chmod +x "$wrapper_path"
echo "$wrapper_path"
} }
# Create systemd service file (optional) # Create systemd service file (optional)
@ -165,13 +149,13 @@ main() {
create_service_file "$controlplane_path" "$CONTROLPLANE_NAME" "$controlplane_script" create_service_file "$controlplane_path" "$CONTROLPLANE_NAME" "$controlplane_script"
local manage_script="$VM_DIR/manage-vm.sh" local manage_script="$VM_DIR/manage-vm.sh"
cat > "$manage_script" << EOF cat > "$manage_script" << 'EOF'
#!/bin/bash #!/bin/bash
VM_DIR="\$(cd "\$(dirname "\$0")" && pwd)" VM_DIR="$(cd "$(dirname "$0")" && pwd)"
start_vm() { start_vm() {
echo "Starting Talos VM..." echo "Starting Talos VM..."
"\$VM_DIR/talos-controlplane/run.sh" & "$VM_DIR/talos-controlplane/start.sh" &
} }
stop_vm() { stop_vm() {
@ -179,7 +163,7 @@ stop_vm() {
pkill -f "qemu-system-aarch64.*talos-controlplane" pkill -f "qemu-system-aarch64.*talos-controlplane"
} }
case "\$1" in case "$1" in
start) start)
start_vm start_vm
;; ;;
@ -190,7 +174,7 @@ case "\$1" in
pgrep -f "qemu-system-aarch64.*talos-controlplane" > /dev/null && echo "VM is running" || echo "VM is stopped" pgrep -f "qemu-system-aarch64.*talos-controlplane" > /dev/null && echo "VM is running" || echo "VM is stopped"
;; ;;
*) *)
echo "Usage: \$0 {start|stop|status}" echo "Usage: $0 {start|stop|status}"
exit 1 exit 1
;; ;;
esac esac