Loading src/check.sh +7 −5 Original line number Diff line number Diff line #!/usr/bin/env bash set -Eeuo pipefail : "${DHCP:="N"}" : "${NETWORK:="Y"}" [ -f "/run/shm/qemu.end" ] && echo "QEMU is shutting down.." && exit 1 Loading @@ -9,6 +10,7 @@ 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 Loading @@ -16,13 +18,13 @@ location=$(<"$file") if ! curl -m 20 -ILfSs "http://$location/" > /dev/null; then if [[ "$location" == "20.20"* ]]; then ip="20.20.20.1" if [[ "$DHCP" == [Yy1]* ]]; then ip=$(<"$address") echo "Failed to reach DSM at http://$location" else ip=$(<"$gateway") 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 Loading src/network.sh +14 −2 Original line number Diff line number Diff line Loading @@ -121,6 +121,8 @@ configureDNS() { local mask="$5" local gateway="$6" echo "$gateway" > /run/shm/qemu.gw [[ "${DNSMASQ_DISABLE:-}" == [Yy1]* ]] && return 0 [[ "$DEBUG" == [Yy1]* ]] && echo "Starting dnsmasq daemon..." Loading Loading @@ -258,9 +260,10 @@ 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 } Loading Loading @@ -368,7 +371,14 @@ configureNAT() { fi fi local ip="172.30.0.2" 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 [ -n "$VM_NET_IP" ] && ip="$VM_NET_IP" local gateway="" Loading Loading @@ -683,6 +693,8 @@ getInfo() { fi echo "$IP" > /run/shm/qemu.ip echo "$nic" > /run/shm/qemu.nic return 0 } Loading src/print.sh +6 −8 Original line number Diff line number Diff line Loading @@ -11,11 +11,12 @@ 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:$COM_PORT/read?command=10" url="http://127.0.0.1:2210/read?command=10" resp_err="Guest returned an invalid response:" curl_err="Failed to connect to guest: curl error" Loading Loading @@ -56,11 +57,7 @@ do (( rc != 0 )) && error "$jq_err $rc ( $json )" && continue [[ "$ip" == "null" ]] && error "$resp_err $json" && continue if [ -z "$ip" ]; then [[ "$DHCP" == [Yy1]* ]] && continue ip="20.20.20.21" fi [ -z "$ip" ] && continue echo "$ip:$port" > $file done Loading @@ -69,7 +66,7 @@ done location=$(<"$file") if [[ "$location" != "20.20"* ]]; then if [[ "$DHCP" == [Yy1]* ]]; then msg="http://$location" title="<title>Virtual DSM</title>" Loading @@ -88,10 +85,11 @@ if [[ "$location" != "20.20"* ]]; then else nic=$(<"$driver") ip=$(<"$address") port="${location##*:}" if [[ "$ip" == "172."* ]]; then if [[ "${nic,,}" != "macvlan" ]]; then msg="port $port" else msg="http://$ip:$port" Loading Loading
src/check.sh +7 −5 Original line number Diff line number Diff line #!/usr/bin/env bash set -Eeuo pipefail : "${DHCP:="N"}" : "${NETWORK:="Y"}" [ -f "/run/shm/qemu.end" ] && echo "QEMU is shutting down.." && exit 1 Loading @@ -9,6 +10,7 @@ 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 Loading @@ -16,13 +18,13 @@ location=$(<"$file") if ! curl -m 20 -ILfSs "http://$location/" > /dev/null; then if [[ "$location" == "20.20"* ]]; then ip="20.20.20.1" if [[ "$DHCP" == [Yy1]* ]]; then ip=$(<"$address") echo "Failed to reach DSM at http://$location" else ip=$(<"$gateway") 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 Loading
src/network.sh +14 −2 Original line number Diff line number Diff line Loading @@ -121,6 +121,8 @@ configureDNS() { local mask="$5" local gateway="$6" echo "$gateway" > /run/shm/qemu.gw [[ "${DNSMASQ_DISABLE:-}" == [Yy1]* ]] && return 0 [[ "$DEBUG" == [Yy1]* ]] && echo "Starting dnsmasq daemon..." Loading Loading @@ -258,9 +260,10 @@ 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 } Loading Loading @@ -368,7 +371,14 @@ configureNAT() { fi fi local ip="172.30.0.2" 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 [ -n "$VM_NET_IP" ] && ip="$VM_NET_IP" local gateway="" Loading Loading @@ -683,6 +693,8 @@ getInfo() { fi echo "$IP" > /run/shm/qemu.ip echo "$nic" > /run/shm/qemu.nic return 0 } Loading
src/print.sh +6 −8 Original line number Diff line number Diff line Loading @@ -11,11 +11,12 @@ 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:$COM_PORT/read?command=10" url="http://127.0.0.1:2210/read?command=10" resp_err="Guest returned an invalid response:" curl_err="Failed to connect to guest: curl error" Loading Loading @@ -56,11 +57,7 @@ do (( rc != 0 )) && error "$jq_err $rc ( $json )" && continue [[ "$ip" == "null" ]] && error "$resp_err $json" && continue if [ -z "$ip" ]; then [[ "$DHCP" == [Yy1]* ]] && continue ip="20.20.20.21" fi [ -z "$ip" ] && continue echo "$ip:$port" > $file done Loading @@ -69,7 +66,7 @@ done location=$(<"$file") if [[ "$location" != "20.20"* ]]; then if [[ "$DHCP" == [Yy1]* ]]; then msg="http://$location" title="<title>Virtual DSM</title>" Loading @@ -88,10 +85,11 @@ if [[ "$location" != "20.20"* ]]; then else nic=$(<"$driver") ip=$(<"$address") port="${location##*:}" if [[ "$ip" == "172."* ]]; then if [[ "${nic,,}" != "macvlan" ]]; then msg="port $port" else msg="http://$ip:$port" Loading