Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
virtualbox_scripts [22 January 2026 / 14:37:04] – created kadekvirtualbox_scripts [22 January 2026 / 14:43:23] (current) kadek
Line 1: Line 1:
-==== VirtualBox Scripts ====+===== VirtualBox Scripts =====
  
 === Script for Check & Start VM === === Script for Check & Start VM ===
 +
  
 This script will check VM status and start inactive VM: This script will check VM status and start inactive VM:
Line 7: Line 8:
   #!/bin/bash   #!/bin/bash
      
-# List of VirtualBox VM names +  # List of VirtualBox VM names 
-VM_NAMES=("WinServer" "LinServer"+  VM_NAMES=("WinServer" "LinServer"
-echo "==== VirtualBox VM Checker ====" +  echo "==== VirtualBox VM Checker ====" 
-echo "==== Script from KdeK.One ====" +  echo "==== Script from KdeK.One ====" 
-for NAME in "${VM_NAMES[@]}"; do +  for NAME in "${VM_NAMES[@]}"; do 
-    # Check if VM exists +     # Check if VM exists 
-    EXISTS=$(VBoxManage list vms | grep -w "\"$NAME\""+     EXISTS=$(VBoxManage list vms | grep -w "\"$NAME\""
-    if [ -z "$EXISTS" ]; then+     if [ -z "$EXISTS" ]; then
         echo "[WARNING] VM '$NAME' not found in VirtualBox."         echo "[WARNING] VM '$NAME' not found in VirtualBox."
         continue         continue
-    fi+     fi
          
-    # Check if VM is running +     # Check if VM is running 
-    RUNNING=$(VBoxManage list runningvms | grep -w "\"$NAME\"")+     RUNNING=$(VBoxManage list runningvms | grep -w "\"$NAME\"")
          
-    if [ -n "$RUNNING" ]; then+     if [ -n "$RUNNING" ]; then
         echo "[OK] VM '$NAME' is already running."         echo "[OK] VM '$NAME' is already running."
-    else+     else
         echo "[ACTION] VM '$NAME' is NOT running. Starting..."         echo "[ACTION] VM '$NAME' is NOT running. Starting..."
         VBoxManage startvm "$NAME" --type headless          VBoxManage startvm "$NAME" --type headless 
Line 35: Line 36:
             echo "[ERROR] Failed to start VM '$NAME'."             echo "[ERROR] Failed to start VM '$NAME'."
         fi         fi
-    fi +     fi 
-done +  done 
-echo "==== Done ===="+  echo "==== Done ===="