Compare commits

...

5 Commits

Author SHA1 Message Date
Kroese
2c6efc45f2 feat: Make webserver port configurable (#1028) 2025-09-27 11:44:13 +02:00
Kroese
24d795fbe3 buid: Add ethtool package (#1027) 2025-09-27 10:45:09 +02:00
Kroese
7fae62d286 feat: Detect host mode networking (#1026) 2025-09-27 10:44:02 +02:00
Kroese
2135df07ea docs: Additional info for user-mode networking (#1025) 2025-09-27 10:08:11 +02:00
Kroese
521beedf1c feat: Add note for MAC address availability (#1024) 2025-09-27 09:49:11 +02:00
3 changed files with 21 additions and 9 deletions

View File

@@ -28,6 +28,7 @@ RUN set -eu && \
unzip \ unzip \
nginx \ nginx \
procps \ procps \
ethtool \
python3 \ python3 \
python3-pip \ python3-pip \
python3-msgpack \ python3-msgpack \
@@ -57,7 +58,7 @@ RUN set -eu && \
COPY --chmod=755 ./src /run/ COPY --chmod=755 ./src /run/
COPY --chmod=755 ./web /var/www/ COPY --chmod=755 ./web /var/www/
COPY --chmod=755 --from=builder /qemu-host.bin /run/host.bin COPY --chmod=755 --from=builder /qemu-host.bin /run/host.bin
COPY --chmod=744 ./web/conf/nginx.conf /etc/nginx/sites-enabled/web.conf COPY --chmod=744 ./web/conf/nginx.conf /etc/nginx/default.conf
ADD --chmod=775 https://raw.githubusercontent.com/sud0woodo/patology/refs/heads/main/patology.py /run/extract.py ADD --chmod=775 https://raw.githubusercontent.com/sud0woodo/patology/refs/heads/main/patology.py /run/extract.py
VOLUME /storage VOLUME /storage

View File

@@ -67,6 +67,7 @@ configureDHCP() {
while ! ip link set "$VM_NET_TAP" up; do while ! ip link set "$VM_NET_TAP" up; do
info "Waiting for MAC address $VM_NET_MAC to become available..." info "Waiting for MAC address $VM_NET_MAC to become available..."
info "If you cloned this machine, please delete the 'dsm.mac' file to generate a different MAC address."
sleep 2 sleep 2
done done
@@ -172,7 +173,7 @@ getUserPorts() {
getHostPorts() { getHostPorts() {
local list=$1 local list="$1"
[ -z "$list" ] && echo "" && return 0 [ -z "$list" ] && echo "" && return 0
@@ -392,6 +393,13 @@ getInfo() {
error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 26 error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 26
fi fi
NIC=$(ethtool -i "$VM_NET_DEV" | grep -m 1 -i 'driver:' | awk '{print $(2)}')
if [[ "${NIC,,}" != "veth" ]]; then
[[ "$DEBUG" == [Yy1]* ]] && info "Detected NIC: $NIC"
error "This container does not support host mode networking!" && exit 29
fi
BASE_IP="${VM_NET_IP%.*}." BASE_IP="${VM_NET_IP%.*}."
if [ "${VM_NET_IP/$BASE_IP/}" -lt "3" ]; then if [ "${VM_NET_IP/$BASE_IP/}" -lt "3" ]; then
@@ -526,7 +534,7 @@ else
msg="podman detected, $msg" msg="podman detected, $msg"
fi fi
warn "$msg" warn "$msg"
[ -z "$USER_PORTS" ] && info "Notice: port mapping will not work without \"USER_PORTS\" now." [ -z "$USER_PORTS" ] && info "Notice: when you want to expose ports in this mode, map them using this variable: \"USER_PORTS=5000,5001\"."
fi fi

View File

@@ -202,19 +202,22 @@ addPackage() {
return 0 return 0
} }
: "${WEB_PORT:="5000"}" # Webserver port
cp -r /var/www/* /run/shm cp -r /var/www/* /run/shm
html "Starting $APP for Docker..." html "Starting $APP for Docker..."
if [[ "${WEB:-}" != [Nn]* ]]; then if [[ "${WEB:-}" != [Nn]* ]]; then
mkdir -p /etc/nginx/sites-enabled
cp /etc/nginx/default.conf /etc/nginx/sites-enabled/web.conf
sed -i "s/listen 5000 default_server;/listen $WEB_PORT default_server;/g" /etc/nginx/sites-enabled/web.conf
# shellcheck disable=SC2143 # shellcheck disable=SC2143
if [ -f /proc/net/if_inet6 ] && [ -n "$(ifconfig -a | grep inet6)" ]; then if [ -f /proc/net/if_inet6 ] && [ -n "$(ifconfig -a | grep inet6)" ]; then
sed -i "s/listen 5000 default_server;/listen [::]:5000 default_server ipv6only=off;/g" /etc/nginx/sites-enabled/web.conf sed -i "s/listen $WEB_PORT default_server;/listen [::]:$WEB_PORT default_server ipv6only=off;/g" /etc/nginx/sites-enabled/web.conf
else
sed -i "s/listen [::]:5000 default_server ipv6only=off;/listen 5000 default_server;/g" /etc/nginx/sites-enabled/web.conf
fi fi