update manage vm script

This commit is contained in:
Alexey Taymano
2025-09-09 20:36:23 +00:00
parent 8e0f0ecb0f
commit 8186ddef43
2 changed files with 47 additions and 29 deletions

View File

@@ -12,7 +12,7 @@ create_vm() {
# Wait for the VM to start up
while true; do
response=$(curl --write-out '%{http_code}' --silent --output /dev/null localhost:5000/probe)
response=$(docker exec -it omni-windows bash -c "curl --write-out '%{http_code}' --silent --output /dev/null localhost:5000/probe")
if [ $response -eq 200 ]; then
break
fi
@@ -27,7 +27,7 @@ start_vm() {
echo "Starting VM..."
docker compose -f ../compose.yml start
while true; do
response=$(curl --write-out '%{http_code}' --silent --output /dev/null localhost:5000/probe)
response=$(docker exec -it omni-windows bash -c "curl --write-out '%{http_code}' --silent --output /dev/null localhost:5000/probe")
if [ $response -eq 200 ]; then
break
fi

View File

@@ -10,28 +10,10 @@ import pyautogui
from PIL import Image
from io import BytesIO
parser = argparse.ArgumentParser()
parser.add_argument("--log_file", help="log file path", type=str,
default=os.path.join(os.path.dirname(__file__), "server.log"))
parser.add_argument("--port", help="port", type=int, default=5000)
args = parser.parse_args()
logging.basicConfig(filename=args.log_file,level=logging.DEBUG, filemode='w' )
logger = logging.getLogger('werkzeug')
app = Flask(__name__)
computer_control_lock = threading.Lock()
@app.route('/probe', methods=['GET'])
def probe_endpoint():
return jsonify({"status": "Probe successful", "message": "Service is operational"}), 200
@app.route('/execute', methods=['POST'])
def execute_command():
# Only execute one command at a time
with computer_control_lock:
data = request.json
def execute_anything(data):
"""Execute any command received in the JSON request.
WARNING: This function executes commands without any safety checks."""
# The 'command' key in the JSON request should contain the command to be executed.
shell = data.get('shell', False)
command = data.get('command', "" if shell else [])
@@ -60,6 +42,42 @@ def execute_command():
'message': str(e)
}), 500
def execute(data):
"""Action space aware implementation. Should not use arbitrary code execution."""
return jsonify({
'status': 'error',
'message': 'Not implemented. Please add your implementation to omnitool/omnibox/vm/win11setup/setupscripts/server/main.py.'
}), 500
execute_impl = execute # switch to execute_anything to allow any command. Please use with caution only for testing purposes.
parser = argparse.ArgumentParser()
parser.add_argument("--log_file", help="log file path", type=str,
default=os.path.join(os.path.dirname(__file__), "server.log"))
parser.add_argument("--port", help="port", type=int, default=5000)
args = parser.parse_args()
logging.basicConfig(filename=args.log_file,level=logging.DEBUG, filemode='w' )
logger = logging.getLogger('werkzeug')
app = Flask(__name__)
computer_control_lock = threading.Lock()
@app.route('/probe', methods=['GET'])
def probe_endpoint():
return jsonify({"status": "Probe successful", "message": "Service is operational"}), 200
@app.route('/execute', methods=['POST'])
def execute_command():
# Only execute one command at a time
with computer_control_lock:
data = request.json
return execute_impl(data)
@app.route('/screenshot', methods=['GET'])
def capture_screen_with_cursor():
cursor_path = os.path.join(os.path.dirname(__file__), "cursor.png")