Compare commits

..

No commits in common. "cdc4689d6ace3c7faabba6506daa59cb35480287" and "fd5ec5222609091befc21f3433b697226b3521aa" have entirely different histories.

3 changed files with 17 additions and 29 deletions

View File

@ -1,7 +1,6 @@
#!/usr/bin/env bash
set -Eeuo pipefail
: "${DHCP:="N"}"
: "${NETWORK:="Y"}"
[ -f "/run/shm/qemu.end" ] && echo "QEMU is shutting down.." && exit 1
@ -10,7 +9,6 @@ set -Eeuo pipefail
file="/run/shm/dsm.url"
address="/run/shm/qemu.ip"
gateway="/run/shm/qemu.gw"
[ ! -s "$file" ] && echo "DSM has not enabled networking yet.." && exit 1
@ -18,13 +16,13 @@ location=$(<"$file")
if ! curl -m 20 -ILfSs "http://$location/" > /dev/null; then
if [[ "$DHCP" == [Yy1]* ]]; then
ip=$(<"$address")
echo "Failed to reach DSM at http://$location"
else
ip=$(<"$gateway")
if [[ "$location" == "20.20"* ]]; then
ip="20.20.20.1"
port="${location##*:}"
echo "Failed to reach DSM at port $port"
else
echo "Failed to reach DSM at http://$location"
ip=$(<"$address")
fi
echo "You might need to whitelist IP $ip in the DSM firewall." && exit 1

View File

@ -121,8 +121,6 @@ configureDNS() {
local mask="$5"
local gateway="$6"
echo "$gateway" > /run/shm/qemu.gw
[[ "${DNSMASQ_DISABLE:-}" == [Yy1]* ]] && return 0
[[ "$DEBUG" == [Yy1]* ]] && echo "Starting dnsmasq daemon..."
@ -260,10 +258,9 @@ configureSlirp() {
if [[ "${DNSMASQ_DISABLE:-}" != [Yy1]* ]]; then
cp /etc/resolv.conf /etc/resolv.dnsmasq
echo -e "nameserver 127.0.0.1\nsearch .\noptions ndots:0" >/etc/resolv.conf
configureDNS "lo" "$ip" "$VM_NET_MAC" "$VM_NET_HOST" "$VM_NET_MASK" "$gateway" || return 1
fi
configureDNS "lo" "$ip" "$VM_NET_MAC" "$VM_NET_HOST" "$VM_NET_MASK" "$gateway" || return 1
VM_NET_IP="$ip"
return 0
}
@ -371,14 +368,7 @@ configureNAT() {
fi
fi
local ip base
base=$(echo "$IP" | sed -r 's/([^.]*.){2}//')
if [[ "$IP" != "172.30."* ]]; then
ip="172.30.$base"
else
ip="172.31.$base"
fi
local ip="172.30.0.2"
[ -n "$VM_NET_IP" ] && ip="$VM_NET_IP"
local gateway=""
@ -552,8 +542,8 @@ checkOS() {
local if="macvlan"
kernel=$(uname -a)
[[ "${kernel,,}" == *"darwin"* ]] && os="$ENGINE Desktop for macOS"
[[ "${kernel,,}" == *"microsoft"* ]] && os="$ENGINE Desktop for Windows"
[[ "${kernel,,}" == *"darwin"* ]] && os="Docker Desktop for macOS"
[[ "${kernel,,}" == *"microsoft"* ]] && os="Docker Desktop for Windows"
if [[ "$DHCP" == [Yy1]* ]]; then
if="macvtap"
@ -693,8 +683,6 @@ getInfo() {
fi
echo "$IP" > /run/shm/qemu.ip
echo "$nic" > /run/shm/qemu.nic
return 0
}

View File

@ -11,12 +11,11 @@ error () { printf "%b%s%b" "\E[1;31m " "ERROR: $1" "\E[0m\n" >&2; }
file="/run/shm/dsm.url"
info="/run/shm/msg.html"
driver="/run/shm/qemu.nic"
page="/run/shm/index.html"
address="/run/shm/qemu.ip"
shutdown="/run/shm/qemu.end"
template="/var/www/index.html"
url="http://127.0.0.1:2210/read?command=10"
url="http://127.0.0.1:$COM_PORT/read?command=10"
resp_err="Guest returned an invalid response:"
curl_err="Failed to connect to guest: curl error"
@ -57,7 +56,11 @@ do
(( rc != 0 )) && error "$jq_err $rc ( $json )" && continue
[[ "$ip" == "null" ]] && error "$resp_err $json" && continue
[ -z "$ip" ] && continue
if [ -z "$ip" ]; then
[[ "$DHCP" == [Yy1]* ]] && continue
ip="20.20.20.21"
fi
echo "$ip:$port" > $file
done
@ -66,7 +69,7 @@ done
location=$(<"$file")
if [[ "$DHCP" == [Yy1]* ]]; then
if [[ "$location" != "20.20"* ]]; then
msg="http://$location"
title="<title>Virtual DSM</title>"
@ -85,11 +88,10 @@ if [[ "$DHCP" == [Yy1]* ]]; then
else
nic=$(<"$driver")
ip=$(<"$address")
port="${location##*:}"
if [[ "${nic,,}" != "macvlan" ]]; then
if [[ "$ip" == "172."* ]]; then
msg="port $port"
else
msg="http://$ip:$port"