Skip to content

Commit b9e315b

Browse files
committed
Add Linux VM support with Docker implementation
- Remove Windows-specific wording - Adjust Python path for cross-platform compatibility - Provide Docker-based Linux VM implementation - Update README with Linux setup instructions - Add graceful VM setup and cleanup procedures
1 parent 5171b09 commit b9e315b

File tree

7 files changed

+562
-24
lines changed

7 files changed

+562
-24
lines changed

omnitool/gradio/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def valid_params(user_input, state):
190190
"""Validate all requirements and return a list of error messages."""
191191
errors = []
192192

193-
for server_name, url in [('Windows Host', 'localhost:5000'), ('OmniParser Server', args.omniparser_server_url)]:
193+
for server_name, url in [('Guest Host', 'localhost:5000'), ('OmniParser Server', args.omniparser_server_url)]:
194194
try:
195195
url = f'http://{url}/probe'
196196
response = requests.get(url, timeout=3)

omnitool/omnibox/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ vm/win11iso/custom.iso
22
vm/win11storage
33
vm/win11setup/setupscripts/firstboot_log.txt
44
vm/win11setup/setupscripts/server/server.log
5+
vm.linux/storage/

omnitool/omnibox/Dockerfile.linux

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Copyright 2025 esmit<[email protected]>
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# This Dockerfile is based on https://github.com/Tiryoh/docker-ros-desktop-vnc/tree/master/noetic
16+
# which is released under the Apache-2.0 license.
17+
18+
FROM ubuntu:focal-20241011
19+
20+
ARG TARGETPLATFORM
21+
LABEL maintainer="esmit<[email protected]>"
22+
23+
SHELL ["/bin/bash", "-c"]
24+
25+
# Upgrade OS
26+
RUN apt-get update -q && \
27+
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \
28+
apt-get autoclean && \
29+
apt-get autoremove && \
30+
rm -rf /var/lib/apt/lists/*
31+
32+
# Install Ubuntu Mate desktop
33+
RUN apt-get update -q && \
34+
DEBIAN_FRONTEND=noninteractive apt-get install -y \
35+
ubuntu-mate-desktop && \
36+
apt-get autoclean && \
37+
apt-get autoremove && \
38+
rm -rf /var/lib/apt/lists/*
39+
40+
# Add Package
41+
RUN apt-get update && \
42+
DEBIAN_FRONTEND=noninteractive apt-get install -y \
43+
tigervnc-standalone-server tigervnc-common \
44+
supervisor wget curl gosu git sudo python3-pip tini \
45+
build-essential vim sudo lsb-release locales \
46+
bash-completion tzdata terminator && \
47+
apt-get autoclean && \
48+
apt-get autoremove && \
49+
rm -rf /var/lib/apt/lists/*
50+
51+
# noVNC and Websockify
52+
RUN git clone https://github.com/AtsushiSaito/noVNC.git -b add_clipboard_support /usr/lib/novnc
53+
RUN pip install --no-cache-dir git+https://github.com/novnc/[email protected]
54+
RUN ln -s /usr/lib/novnc/vnc.html /usr/lib/novnc/index.html
55+
56+
# Set remote resize function enabled by default
57+
RUN sed -i "s/UI.initSetting('resize', 'off');/UI.initSetting('resize', 'remote');/g" /usr/lib/novnc/app/ui.js
58+
59+
# Disable auto update and crash report
60+
RUN sed -i 's/Prompt=.*/Prompt=never/' /etc/update-manager/release-upgrades
61+
RUN sed -i 's/enabled=1/enabled=0/g' /etc/default/apport
62+
63+
# Install Firefox
64+
RUN DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:mozillateam/ppa -y && \
65+
echo 'Package: *' > /etc/apt/preferences.d/mozilla-firefox && \
66+
echo 'Pin: release o=LP-PPA-mozillateam' >> /etc/apt/preferences.d/mozilla-firefox && \
67+
echo 'Pin-Priority: 1001' >> /etc/apt/preferences.d/mozilla-firefox && \
68+
apt-get update -q && \
69+
apt-get install -y --allow-downgrades \
70+
firefox && \
71+
apt-get autoclean && \
72+
apt-get autoremove && \
73+
rm -rf /var/lib/apt/lists/*
74+
75+
76+
# Enable apt-get completion after running `apt-get update` in the container
77+
RUN rm /etc/apt/apt.conf.d/docker-clean
78+
79+
COPY --chmod=755 ./vm.linux/buildcontainer/entry.sh /run/
80+
#ENTRYPOINT ["/usr/bin/tini", "-s", "/run/entrypoint.sh"]
81+
ENTRYPOINT [ "/bin/bash", "-c", "/run/entry.sh" ]
82+
83+
ENV USER ubuntu
84+
ENV PASSWD ubuntu

omnitool/omnibox/compose.linux.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
services:
2+
linux:
3+
image: linux-local
4+
container_name: omni-linux
5+
privileged: true
6+
environment:
7+
RAM_SIZE: "8G"
8+
CPU_CORES: "4"
9+
DISK_SIZE: "20G"
10+
devices:
11+
- /dev/kvm
12+
- /dev/net/tun
13+
cap_add:
14+
- NET_ADMIN
15+
ports:
16+
- 8006:80 # Web Viewer access
17+
- 5000:5000 # Computer control server
18+
volumes:
19+
- ./vm.linux/storage:/data
20+
- ./vm/win11setup/setupscripts/server:/controlserver # reuse the same server code for windows and linux
Lines changed: 104 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
#!/bin/bash
22

3+
# Default VM type is windows if not specified
4+
VM_TYPE="windows"
5+
6+
# Get the directory where the script is located
7+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
8+
# Get the parent directory (omnibox directory)
9+
OMNIBOX_DIR="$( cd "$SCRIPT_DIR/.." && pwd )"
10+
311
create_vm() {
4-
if ! docker images windows-local -q | grep -q .; then
12+
local dockerfile="Dockerfile"
13+
local compose_file="compose.yml"
14+
local image_name="windows-local"
15+
16+
if [ "$VM_TYPE" == "linux" ]; then
17+
dockerfile="Dockerfile.linux"
18+
compose_file="compose.linux.yml"
19+
image_name="linux-local"
20+
fi
21+
22+
if ! docker images $image_name -q | grep -q .; then
523
echo "Image not found locally. Building..."
6-
docker build -t windows-local ..
24+
docker build --no-cache --pull -t $image_name -f "$OMNIBOX_DIR/$dockerfile" "$OMNIBOX_DIR"
725
else
826
echo "Image found locally. Skipping build."
927
fi
1028

11-
docker compose -f ../compose.yml up -d
29+
docker compose -f "$OMNIBOX_DIR/$compose_file" up -d
1230

1331
# Wait for the VM to start up
1432
while true; do
@@ -20,12 +38,39 @@ create_vm() {
2038
sleep 5
2139
done
2240

23-
echo "VM + server is up and running!"
41+
echo "$VM_TYPE VM + server is up and running!"
2442
}
2543

2644
start_vm() {
27-
echo "Starting VM..."
28-
docker compose -f ../compose.yml start
45+
local compose_file="compose.yml"
46+
47+
if [ "$VM_TYPE" == "linux" ]; then
48+
compose_file="compose.linux.yml"
49+
fi
50+
51+
echo "Starting $VM_TYPE VM..."
52+
53+
# Show container status before starting
54+
echo "Container status before starting:"
55+
docker compose -f "$OMNIBOX_DIR/$compose_file" ps
56+
57+
# Start the containers
58+
docker compose -f "$OMNIBOX_DIR/$compose_file" start
59+
60+
# Show container status after starting
61+
echo "Container status after starting:"
62+
docker compose -f "$OMNIBOX_DIR/$compose_file" ps
63+
64+
# Check if containers are running
65+
if docker compose -f "$OMNIBOX_DIR/$compose_file" ps --status running | grep -q .; then
66+
echo "Containers are running."
67+
else
68+
echo "Warning: No containers appear to be running. Check logs for details."
69+
echo "Container logs:"
70+
docker compose -f "$OMNIBOX_DIR/$compose_file" logs --tail=20
71+
fi
72+
73+
# Uncomment this section if you want to wait for the server to respond
2974
while true; do
3075
response=$(curl --write-out '%{http_code}' --silent --output /dev/null localhost:5000/probe)
3176
if [ $response -eq 200 ]; then
@@ -34,29 +79,70 @@ start_vm() {
3479
echo "Waiting for a response from the computer control server"
3580
sleep 5
3681
done
37-
echo "VM started"
82+
83+
echo "$VM_TYPE VM started"
3884
}
3985

4086
stop_vm() {
41-
echo "Stopping VM..."
42-
docker compose -f ../compose.yml stop
43-
echo "VM stopped"
87+
local compose_file="compose.yml"
88+
89+
if [ "$VM_TYPE" == "linux" ]; then
90+
compose_file="compose.linux.yml"
91+
fi
92+
93+
echo "Stopping $VM_TYPE VM..."
94+
docker compose -f "$OMNIBOX_DIR/$compose_file" stop
95+
echo "$VM_TYPE VM stopped"
4496
}
4597

4698
delete_vm() {
47-
echo "Removing VM and associated containers..."
48-
docker compose -f ../compose.yml down
49-
echo "VM removed"
99+
local compose_file="compose.yml"
100+
local image_name="windows-local"
101+
102+
if [ "$VM_TYPE" == "linux" ]; then
103+
compose_file="compose.linux.yml"
104+
image_name="linux-local"
105+
fi
106+
107+
echo "Removing $VM_TYPE VM and associated containers..."
108+
docker compose -f "$OMNIBOX_DIR/$compose_file" down
109+
docker rmi $image_name
110+
echo "$VM_TYPE VM removed"
50111
}
51112

52-
# Check if control parameter is provided
53-
if [ -z "$1" ]; then
54-
echo "Usage: $0 [create|start|stop|delete]"
113+
# Parse command line arguments
114+
while [[ $# -gt 0 ]]; do
115+
case "$1" in
116+
create|start|stop|delete)
117+
COMMAND="$1"
118+
shift
119+
;;
120+
--linux)
121+
VM_TYPE="linux"
122+
shift
123+
;;
124+
--windows)
125+
VM_TYPE="windows"
126+
shift
127+
;;
128+
*)
129+
echo "Unknown option: $1"
130+
echo "Usage: $0 [create|start|stop|delete] [--linux|--windows]"
131+
exit 1
132+
;;
133+
esac
134+
done
135+
136+
# Check if command is provided
137+
if [ -z "$COMMAND" ]; then
138+
echo "Usage: $0 [create|start|stop|delete] [--linux|--windows]"
139+
echo " --linux Use Linux VM configuration (default is Windows)"
140+
echo " --windows Use Windows VM configuration"
55141
exit 1
56142
fi
57143

58-
# Execute the appropriate function based on the control parameter
59-
case "$1" in
144+
# Execute the appropriate function based on the command
145+
case "$COMMAND" in
60146
"create")
61147
create_vm
62148
;;
@@ -69,9 +155,4 @@ case "$1" in
69155
"delete")
70156
delete_vm
71157
;;
72-
*)
73-
echo "Invalid option: $1"
74-
echo "Usage: $0 [create|start|stop|delete]"
75-
exit 1
76-
;;
77158
esac

0 commit comments

Comments
 (0)