Commenting out log command
This commit is contained in:
parent
2c85175912
commit
8de7d2efd3
1 changed files with 21 additions and 37 deletions
|
|
@ -56,7 +56,7 @@ create_disk_image() {
|
|||
local disk_path="$vm_path/disk.qcow2"
|
||||
|
||||
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"
|
||||
else
|
||||
log_warn "Disk image already exists for $vm_name"
|
||||
|
|
@ -81,42 +81,26 @@ create_vm_script() {
|
|||
|
||||
local script_path="$vm_path/start.sh"
|
||||
|
||||
cat > "$script_path" << 'EOF'
|
||||
# Use a function to escape the variables
|
||||
cat > "$script_path" << EOF
|
||||
#!/bin/bash
|
||||
VM_NAME="$1"
|
||||
MAC_ADDRESS="$2"
|
||||
ISO_PATH="$3"
|
||||
DISK_PATH="$4"
|
||||
CPUS="$5"
|
||||
MEMORY="$6"
|
||||
|
||||
qemu-system-aarch64 \
|
||||
-name "$VM_NAME" \
|
||||
-machine virt,highmem=off \
|
||||
-accel hvf \
|
||||
-cpu host \
|
||||
-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 \
|
||||
qemu-system-aarch64 \\
|
||||
-name "$vm_name" \\
|
||||
-machine virt,highmem=off \\
|
||||
-accel hvf \\
|
||||
-cpu host \\
|
||||
-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
|
||||
EOF
|
||||
|
||||
# Make the script executable and create a wrapper that passes the parameters
|
||||
chmod +x "$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"
|
||||
echo "$script_path"
|
||||
}
|
||||
|
||||
# Create systemd service file (optional)
|
||||
|
|
@ -165,13 +149,13 @@ main() {
|
|||
create_service_file "$controlplane_path" "$CONTROLPLANE_NAME" "$controlplane_script"
|
||||
|
||||
local manage_script="$VM_DIR/manage-vm.sh"
|
||||
cat > "$manage_script" << EOF
|
||||
cat > "$manage_script" << 'EOF'
|
||||
#!/bin/bash
|
||||
VM_DIR="\$(cd "\$(dirname "\$0")" && pwd)"
|
||||
VM_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
start_vm() {
|
||||
echo "Starting Talos VM..."
|
||||
"\$VM_DIR/talos-controlplane/run.sh" &
|
||||
"$VM_DIR/talos-controlplane/start.sh" &
|
||||
}
|
||||
|
||||
stop_vm() {
|
||||
|
|
@ -179,7 +163,7 @@ stop_vm() {
|
|||
pkill -f "qemu-system-aarch64.*talos-controlplane"
|
||||
}
|
||||
|
||||
case "\$1" in
|
||||
case "$1" in
|
||||
start)
|
||||
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"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: \$0 {start|stop|status}"
|
||||
echo "Usage: $0 {start|stop|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue