mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2026-08-29 04:07:02 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51d6f3aeca | ||
|
|
4544620d48 | ||
|
|
de8468161f | ||
|
|
18d6be8210 | ||
|
|
e5b8cf3bf8 | ||
|
|
ec12039f43 | ||
|
|
3c7c3ca1b1 | ||
|
|
2b27f32cd4 | ||
|
|
55d1d50284 | ||
|
|
784b73b5b5 | ||
|
|
85f00bb9cc | ||
|
|
efe8732e47 | ||
|
|
f6871dd61b | ||
|
|
a713b728ff | ||
|
|
0d74c6ac80 |
@@ -1,4 +1,5 @@
|
|||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
updates:
|
updates:
|
||||||
- package-ecosystem: docker
|
- package-ecosystem: docker
|
||||||
directory: /
|
directory: /
|
||||||
@@ -6,9 +7,15 @@ updates:
|
|||||||
interval: weekly
|
interval: weekly
|
||||||
cooldown:
|
cooldown:
|
||||||
default-days: 7
|
default-days: 7
|
||||||
|
|
||||||
- package-ecosystem: github-actions
|
- package-ecosystem: github-actions
|
||||||
directory: /
|
directory: /
|
||||||
schedule:
|
schedule:
|
||||||
interval: weekly
|
interval: weekly
|
||||||
cooldown:
|
cooldown:
|
||||||
default-days: 7
|
default-days: 7
|
||||||
|
ignore:
|
||||||
|
- dependency-name: "*"
|
||||||
|
update-types:
|
||||||
|
- version-update:semver-minor
|
||||||
|
- version-update:semver-patch
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ jobs:
|
|||||||
-e SC2153
|
-e SC2153
|
||||||
-
|
-
|
||||||
name: Lint Dockerfile
|
name: Lint Dockerfile
|
||||||
uses: hadolint/hadolint-action@v3.3.0
|
uses: hadolint/hadolint-action@v3.4.0
|
||||||
with:
|
with:
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
ignore: DL3008
|
ignore: DL3008
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ ARG TARGETPLATFORM
|
|||||||
|
|
||||||
ARG VERSION_ARG="0.0"
|
ARG VERSION_ARG="0.0"
|
||||||
ARG VERSION_CSTRUCT="4.7"
|
ARG VERSION_CSTRUCT="4.7"
|
||||||
ARG VERSION_PASST="2026_07_16"
|
ARG VERSION_PASST="2026_07_28"
|
||||||
|
|
||||||
ARG DEBCONF_NOWARNINGS="yes"
|
ARG DEBCONF_NOWARNINGS="yes"
|
||||||
ARG DEBIAN_FRONTEND="noninteractive"
|
ARG DEBIAN_FRONTEND="noninteractive"
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ An empty default means the variable is unset and its value is determined automat
|
|||||||
| `DISK_DISCARD` | `unmap` | Discard/TRIM mode for the primary disk. |
|
| `DISK_DISCARD` | `unmap` | Discard/TRIM mode for the primary disk. |
|
||||||
| `DISK_ROTATION` | `1` | Rotation rate reported to the guest. Use `1` to identify the disk as an SSD. |
|
| `DISK_ROTATION` | `1` | Rotation rate reported to the guest. Use `1` to identify the disk as an SSD. |
|
||||||
| `DISK_FLAGS` | | Additional options used when creating `qcow2` disks. |
|
| `DISK_FLAGS` | | Additional options used when creating `qcow2` disks. |
|
||||||
|
| `DISK_OPTIONS` | | Additional options appended to QEMU disk devices. |
|
||||||
| `ALLOCATE` | `N` | Preallocates space for the data disks. |
|
| `ALLOCATE` | `N` | Preallocates space for the data disks. |
|
||||||
| `STORAGE` | `/storage` | Storage directory used for disks, settings, and downloads. |
|
| `STORAGE` | `/storage` | Storage directory used for disks, settings, and downloads. |
|
||||||
|
|
||||||
|
|||||||
+15
-5
@@ -7,6 +7,7 @@ set -Eeuo pipefail
|
|||||||
: "${DISK_FMT:="raw"}" # Disk file format, 'raw' by default for best performance
|
: "${DISK_FMT:="raw"}" # Disk file format, 'raw' by default for best performance
|
||||||
: "${DISK_TYPE:=""}" # Device type to be used, "sata", "nvme", "blk" or "scsi"
|
: "${DISK_TYPE:=""}" # Device type to be used, "sata", "nvme", "blk" or "scsi"
|
||||||
: "${DISK_FLAGS:=""}" # Specifies the options for use with the qcow2 disk format
|
: "${DISK_FLAGS:=""}" # Specifies the options for use with the qcow2 disk format
|
||||||
|
: "${DISK_OPTIONS:=""}" # Specifies additional options for the QEMU disk device
|
||||||
: "${DISK_CACHE:="none"}" # Caching mode, can be set to 'writeback' for better performance
|
: "${DISK_CACHE:="none"}" # Caching mode, can be set to 'writeback' for better performance
|
||||||
: "${DISK_DISCARD:="unmap"}" # Controls whether unmap (TRIM) commands are passed to the host.
|
: "${DISK_DISCARD:="unmap"}" # Controls whether unmap (TRIM) commands are passed to the host.
|
||||||
: "${DISK_ROTATION:="1"}" # Rotation rate, set to 1 for SSD storage and increase for HDD
|
: "${DISK_ROTATION:="1"}" # Rotation rate, set to 1 for SSD storage and increase for HDD
|
||||||
@@ -16,6 +17,7 @@ DISK_IO=$(strip "$DISK_IO")
|
|||||||
DISK_FMT=$(strip "$DISK_FMT")
|
DISK_FMT=$(strip "$DISK_FMT")
|
||||||
DISK_TYPE=$(strip "$DISK_TYPE")
|
DISK_TYPE=$(strip "$DISK_TYPE")
|
||||||
DISK_FLAGS=$(strip "$DISK_FLAGS")
|
DISK_FLAGS=$(strip "$DISK_FLAGS")
|
||||||
|
DISK_OPTIONS=$(strip "$DISK_OPTIONS")
|
||||||
DISK_CACHE=$(strip "$DISK_CACHE")
|
DISK_CACHE=$(strip "$DISK_CACHE")
|
||||||
DISK_DISCARD=$(strip "$DISK_DISCARD")
|
DISK_DISCARD=$(strip "$DISK_DISCARD")
|
||||||
DISK_ROTATION=$(strip "$DISK_ROTATION")
|
DISK_ROTATION=$(strip "$DISK_ROTATION")
|
||||||
@@ -508,6 +510,9 @@ createDevice () {
|
|||||||
|
|
||||||
[[ -z "${PCI_BUS:-}" && ( "${MACHINE,,}" == pc || "${MACHINE,,}" == pc-i440fx* ) ]] && bus="pci.0"
|
[[ -z "${PCI_BUS:-}" && ( "${MACHINE,,}" == pc || "${MACHINE,,}" == pc-i440fx* ) ]] && bus="pci.0"
|
||||||
|
|
||||||
|
local options=""
|
||||||
|
[ -n "$DISK_OPTIONS" ] && options=",${DISK_OPTIONS#,}"
|
||||||
|
|
||||||
local bootIndex=""
|
local bootIndex=""
|
||||||
local diskId="data$diskIndex"
|
local diskId="data$diskIndex"
|
||||||
[ -n "$diskIndex" ] && bootIndex=",bootindex=$diskIndex"
|
[ -n "$diskIndex" ] && bootIndex=",bootindex=$diskIndex"
|
||||||
@@ -520,29 +525,29 @@ createDevice () {
|
|||||||
;;
|
;;
|
||||||
"usb" )
|
"usb" )
|
||||||
result+=",if=none \
|
result+=",if=none \
|
||||||
-device usb-storage,drive=${diskId}${bootIndex}${diskSerial}${diskSectors}"
|
-device usb-storage,drive=${diskId}${bootIndex}${diskSerial}${diskSectors}${options}"
|
||||||
echo "$result"
|
echo "$result"
|
||||||
;;
|
;;
|
||||||
"nvme" )
|
"nvme" )
|
||||||
result+=",if=none \
|
result+=",if=none \
|
||||||
-device nvme,drive=${diskId}${bootIndex},serial=deadbeaf${diskIndex}${diskSerial}${diskSectors}"
|
-device nvme,drive=${diskId}${bootIndex},serial=deadbeaf${diskIndex}${diskSerial}${diskSectors}${options}"
|
||||||
echo "$result"
|
echo "$result"
|
||||||
;;
|
;;
|
||||||
"ide" | "sata" )
|
"ide" | "sata" )
|
||||||
result+=",if=none \
|
result+=",if=none \
|
||||||
-device ich9-ahci,id=ahci${diskIndex},addr=$diskAddress \
|
-device ich9-ahci,id=ahci${diskIndex},addr=$diskAddress \
|
||||||
-device ide-hd,drive=${diskId},bus=ahci$diskIndex.0,rotation_rate=$DISK_ROTATION${bootIndex}${diskSerial}${diskSectors}"
|
-device ide-hd,drive=${diskId},bus=ahci$diskIndex.0,rotation_rate=$DISK_ROTATION${bootIndex}${diskSerial}${diskSectors}${options}"
|
||||||
echo "$result"
|
echo "$result"
|
||||||
;;
|
;;
|
||||||
"blk" | "virtio-blk" )
|
"blk" | "virtio-blk" )
|
||||||
result+=",if=none \
|
result+=",if=none \
|
||||||
-device virtio-blk-pci,drive=${diskId},bus=$bus,addr=$diskAddress,iothread=io2${bootIndex}${diskSerial}${diskSectors}"
|
-device virtio-blk-pci,drive=${diskId},bus=$bus,addr=$diskAddress,iothread=io2${bootIndex}${diskSerial}${diskSectors}${options}"
|
||||||
echo "$result"
|
echo "$result"
|
||||||
;;
|
;;
|
||||||
"scsi" | "virtio-scsi" )
|
"scsi" | "virtio-scsi" )
|
||||||
result+=",if=none \
|
result+=",if=none \
|
||||||
-device virtio-scsi-pci,id=${diskId}b,bus=$bus,addr=$diskAddress,iothread=io2,hotplug=off \
|
-device virtio-scsi-pci,id=${diskId}b,bus=$bus,addr=$diskAddress,iothread=io2,hotplug=off \
|
||||||
-device scsi-hd,drive=${diskId},bus=${diskId}b.0,channel=0,scsi-id=0,lun=0,rotation_rate=$DISK_ROTATION${bootIndex}${diskSerial}${diskSectors}"
|
-device scsi-hd,drive=${diskId},bus=${diskId}b.0,channel=0,scsi-id=0,lun=0,rotation_rate=$DISK_ROTATION${bootIndex}${diskSerial}${diskSectors}${options}"
|
||||||
echo "$result"
|
echo "$result"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -771,6 +776,11 @@ if [[ "$DISK_FLAGS" =~ [[:space:]] ]]; then
|
|||||||
exit 78
|
exit 78
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$DISK_OPTIONS" =~ [[:space:]] ]]; then
|
||||||
|
error "Invalid DISK_OPTIONS value '$DISK_OPTIONS', spaces are not allowed."
|
||||||
|
exit 78
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$ALLOCATE" ]; then
|
if [ -z "$ALLOCATE" ]; then
|
||||||
ALLOCATE="N"
|
ALLOCATE="N"
|
||||||
fi
|
fi
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
if enabled "$DEBUG"; then
|
if enabled "$DEBUG"; then
|
||||||
printf "QEMU arguments:\n\n%s\n\n" "${ARGS// -/$'\n-'}"
|
printf "QEMU arguments:\n\n %s\n\n" "${ARGS// -/$'\n -'}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
+4
-4
@@ -254,7 +254,7 @@ if ! touch "$SYSTEM"; then
|
|||||||
error "Could not create file $SYSTEM for the system disk." && exit 98
|
error "Could not create file $SYSTEM for the system disk." && exit 98
|
||||||
fi
|
fi
|
||||||
|
|
||||||
! setOwner "$SYSTEM" && warn "failed to set the owner for \"$SYSTEM\" !"
|
setOwner "$SYSTEM" || warn "failed to set the owner for \"$SYSTEM\" !"
|
||||||
|
|
||||||
if [[ "${FS,,}" == "btrfs" ]]; then
|
if [[ "${FS,,}" == "btrfs" ]]; then
|
||||||
{ chattr +C "$SYSTEM"; } || :
|
{ chattr +C "$SYSTEM"; } || :
|
||||||
@@ -329,7 +329,7 @@ fakeroot -- bash -c "set -Eeu;\
|
|||||||
|
|
||||||
rm -rf "$MOUNT"
|
rm -rf "$MOUNT"
|
||||||
echo "$BASE" > "$STORAGE/dsm.ver"
|
echo "$BASE" > "$STORAGE/dsm.ver"
|
||||||
! setOwner "$STORAGE/dsm.ver" && warn "failed to set the owner for \"$STORAGE/dsm.ver\" !"
|
setOwner "$STORAGE/dsm.ver" || warn "failed to set the owner for \"$STORAGE/dsm.ver\" !"
|
||||||
|
|
||||||
if [[ "$URL" == "file://$STORAGE/$BASE.pat" ]]; then
|
if [[ "$URL" == "file://$STORAGE/$BASE.pat" ]]; then
|
||||||
rm -f "$PAT"
|
rm -f "$PAT"
|
||||||
@@ -338,11 +338,11 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$STORAGE/$BASE.pat" ]; then
|
if [ -f "$STORAGE/$BASE.pat" ]; then
|
||||||
! setOwner "$STORAGE/$BASE.pat" && warn "failed to set the owner for \"$STORAGE/$BASE.pat\" !"
|
setOwner "$STORAGE/$BASE.pat" || warn "failed to set the owner for \"$STORAGE/$BASE.pat\" !"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mv -f "$BOOT" "$STORAGE/$BASE.boot.img"
|
mv -f "$BOOT" "$STORAGE/$BASE.boot.img"
|
||||||
! setOwner "$STORAGE/$BASE.boot.img" && warn "failed to set the owner for \"$STORAGE/$BASE.boot.img\" !"
|
setOwner "$STORAGE/$BASE.boot.img" || warn "failed to set the owner for \"$STORAGE/$BASE.boot.img\" !"
|
||||||
|
|
||||||
rm -rf "$TMP"
|
rm -rf "$TMP"
|
||||||
|
|
||||||
|
|||||||
+77
-54
@@ -405,36 +405,6 @@ natGuestIP() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
kernelAtLeast() {
|
|
||||||
|
|
||||||
local major="$1"
|
|
||||||
local minor="${2:-0}"
|
|
||||||
|
|
||||||
(( KERNEL > major || (KERNEL == major && MINOR >= minor) ))
|
|
||||||
}
|
|
||||||
|
|
||||||
canBindToDevice() {
|
|
||||||
|
|
||||||
local dev="$1"
|
|
||||||
[ -n "$dev" ] || return 1
|
|
||||||
|
|
||||||
kernelAtLeast 5 7 || return 1
|
|
||||||
[ -d "/sys/class/net/$dev" ] || return 1
|
|
||||||
command -v python3 > /dev/null 2>&1 || return 0
|
|
||||||
|
|
||||||
python3 - "$dev" > /dev/null 2>&1 <<'PY'
|
|
||||||
import socket
|
|
||||||
import sys
|
|
||||||
|
|
||||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
|
||||||
sock.setsockopt(
|
|
||||||
socket.SOL_SOCKET,
|
|
||||||
socket.SO_BINDTODEVICE,
|
|
||||||
sys.argv[1].encode() + b"\0",
|
|
||||||
)
|
|
||||||
PY
|
|
||||||
}
|
|
||||||
|
|
||||||
# ######################################
|
# ######################################
|
||||||
# DNS / port helpers
|
# DNS / port helpers
|
||||||
# ######################################
|
# ######################################
|
||||||
@@ -449,6 +419,7 @@ configureDNS() {
|
|||||||
local gateway="$6"
|
local gateway="$6"
|
||||||
local upstream="${7:-}"
|
local upstream="${7:-}"
|
||||||
local arguments="$DNSMASQ_OPTS"
|
local arguments="$DNSMASQ_OPTS"
|
||||||
|
local pid
|
||||||
|
|
||||||
if ! echo "$gateway" > /run/shm/qemu.gw; then
|
if ! echo "$gateway" > /run/shm/qemu.gw; then
|
||||||
error "Failed to write gateway file."
|
error "Failed to write gateway file."
|
||||||
@@ -458,7 +429,10 @@ configureDNS() {
|
|||||||
enabled "${DNSMASQ_DISABLE:-}" && return 0
|
enabled "${DNSMASQ_DISABLE:-}" && return 0
|
||||||
enabled "$DEBUG" && echo "Starting dnsmasq daemon..."
|
enabled "$DEBUG" && echo "Starting dnsmasq daemon..."
|
||||||
|
|
||||||
[ -s "$DNSMASQ_PID" ] && pKill "$(<"$DNSMASQ_PID")"
|
if readPidFile pid "$DNSMASQ_PID"; then
|
||||||
|
pKill "$pid"
|
||||||
|
fi
|
||||||
|
|
||||||
rm -f "$DNSMASQ_PID"
|
rm -f "$DNSMASQ_PID"
|
||||||
|
|
||||||
if isNAT; then
|
if isNAT; then
|
||||||
@@ -518,7 +492,7 @@ configureDNS() {
|
|||||||
arguments+=" --log-facility=$log"
|
arguments+=" --log-facility=$log"
|
||||||
|
|
||||||
arguments=$(echo "$arguments" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//')
|
arguments=$(echo "$arguments" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//')
|
||||||
enabled "$DEBUG" && printf "Dnsmasq arguments:\n\n%s\n\n" "${arguments// -/$'\n-'}"
|
enabled "$DEBUG" && printf "Dnsmasq arguments:\n\n %s\n\n" "${arguments// -/$'\n -'}"
|
||||||
|
|
||||||
{ $DNSMASQ ${arguments:+ $arguments}; local rc=$?; } || :
|
{ $DNSMASQ ${arguments:+ $arguments}; local rc=$?; } || :
|
||||||
|
|
||||||
@@ -541,11 +515,12 @@ configureDNS() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
getHostPorts() {
|
normalizePorts() {
|
||||||
|
|
||||||
local list="${HOST_PORTS// /},"
|
local list="$1"
|
||||||
local port ports=""
|
local mode="${2:-tcp}"
|
||||||
local mode="${1:-tcp}"
|
local port num
|
||||||
|
local ports=""
|
||||||
|
|
||||||
for port in ${list//,/ }; do
|
for port in ${list//,/ }; do
|
||||||
|
|
||||||
@@ -554,31 +529,78 @@ getHostPorts() {
|
|||||||
case "$mode" in
|
case "$mode" in
|
||||||
"tcp" )
|
"tcp" )
|
||||||
[[ "$port" == *"/udp" ]] && continue
|
[[ "$port" == *"/udp" ]] && continue
|
||||||
local num="${port%/tcp}"
|
num="${port%/tcp}"
|
||||||
|
[ -n "$num" ] && ports+="$num,"
|
||||||
;;
|
;;
|
||||||
"all" )
|
"all" )
|
||||||
if [[ "$port" == *"/udp" ]]; then
|
if [[ "$port" == *"/udp" ]]; then
|
||||||
local num="${port%/udp}"
|
num="${port%/udp}"
|
||||||
[ -n "$num" ] && ports+="$num/udp,"
|
[ -n "$num" ] && ports+="$num/udp,"
|
||||||
else
|
else
|
||||||
local num="${port%/tcp}"
|
num="${port%/tcp}"
|
||||||
[ -n "$num" ] && ports+="$num/tcp,"
|
[ -n "$num" ] && ports+="$num/tcp,"
|
||||||
fi
|
fi
|
||||||
continue
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[ -n "$num" ] && ports+="$num,"
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove duplicates
|
# Remove duplicates
|
||||||
ports=$(echo "${ports//,,/,}," | awk 'BEGIN{RS=ORS=","} !seen[$0]++' | sed 's/,*$//g')
|
echo "${ports//,,/,}," | awk 'BEGIN{RS=ORS=","} !seen[$0]++' | sed 's/,*$//g'
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
getReservedPorts() {
|
||||||
|
|
||||||
|
local list=""
|
||||||
|
local mode="${1:-tcp}"
|
||||||
|
|
||||||
|
# Reserve the DNS port while the internal dnsmasq resolver is active.
|
||||||
|
if ! enabled "${DNSMASQ_DISABLE:-}" && ! isNAT; then
|
||||||
|
list+="53/tcp,53/udp,"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# WEB_PORT and WSD_PORT are intentionally not reserved. In non-DHCP modes,
|
||||||
|
# closeWeb() releases both before NAT or user-mode forwarding is configured,
|
||||||
|
# allowing WEB_PORT (normally 5000) to be handed over to DSM.
|
||||||
|
|
||||||
|
normalizePorts "$list" "$mode"
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
getCustomHostPorts() {
|
||||||
|
|
||||||
|
local mode="${1:-tcp}"
|
||||||
|
local reserved user port
|
||||||
|
local ports=""
|
||||||
|
|
||||||
|
reserved=$(getReservedPorts "all")
|
||||||
|
user=$(normalizePorts "$HOST_PORTS" "all")
|
||||||
|
|
||||||
|
for port in ${user//,/ }; do
|
||||||
|
[[ ",$reserved," == *",$port,"* ]] && continue
|
||||||
|
ports+="$port,"
|
||||||
|
done
|
||||||
|
|
||||||
|
normalizePorts "$ports" "$mode"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
getHostPorts() {
|
||||||
|
|
||||||
|
local mode="${1:-tcp}"
|
||||||
|
local reserved custom
|
||||||
|
|
||||||
|
# Merge internal reservations with user-defined host ports without mutating HOST_PORTS.
|
||||||
|
# User entries already covered by an internal reservation are silently ignored.
|
||||||
|
reserved=$(getReservedPorts "all")
|
||||||
|
custom=$(getCustomHostPorts "all")
|
||||||
|
normalizePorts "$reserved,$custom" "$mode"
|
||||||
|
|
||||||
echo "$ports"
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,8 +610,9 @@ getUserPorts() {
|
|||||||
local list="$defaults,${USER_PORTS// /},"
|
local list="$defaults,${USER_PORTS// /},"
|
||||||
|
|
||||||
local ports=""
|
local ports=""
|
||||||
local userport hostport exclude
|
local userport hostport exclude reserved
|
||||||
|
|
||||||
|
reserved=$(getReservedPorts "all")
|
||||||
exclude=$(getHostPorts "all")
|
exclude=$(getHostPorts "all")
|
||||||
|
|
||||||
for userport in ${list//,/ }; do
|
for userport in ${list//,/ }; do
|
||||||
@@ -611,7 +634,9 @@ getUserPorts() {
|
|||||||
|
|
||||||
if [[ "$num/$proto" == "$hostport" ]]; then
|
if [[ "$num/$proto" == "$hostport" ]]; then
|
||||||
|
|
||||||
if [[ "$hostport" != "${WEB_PORT:-}/tcp" ]]; then
|
if [[ ",$reserved," == *",$hostport,"* ]]; then
|
||||||
|
warn "Could not assign port $hostport to \"USER_PORTS\" because it is reserved by the container!"
|
||||||
|
elif [[ "$hostport" != "${WEB_PORT:-}/tcp" ]]; then
|
||||||
warn "Could not assign port $hostport to \"USER_PORTS\" because it is already in \"HOST_PORTS\"!"
|
warn "Could not assign port $hostport to \"USER_PORTS\" because it is already in \"HOST_PORTS\"!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -659,7 +684,6 @@ getSlirp() {
|
|||||||
getPasst() {
|
getPasst() {
|
||||||
|
|
||||||
local list port
|
local list port
|
||||||
local bind="$UPLINK"
|
|
||||||
local tcp="" udp="" args=""
|
local tcp="" udp="" args=""
|
||||||
|
|
||||||
list=$(getUserPorts)
|
list=$(getUserPorts)
|
||||||
@@ -689,12 +713,8 @@ getPasst() {
|
|||||||
tcp="${tcp%,}"
|
tcp="${tcp%,}"
|
||||||
udp="${udp%,}"
|
udp="${udp%,}"
|
||||||
|
|
||||||
if canBindToDevice "$DEV"; then
|
[ -n "$tcp" ] && args+=" -t $tcp"
|
||||||
bind="%$DEV"
|
[ -n "$udp" ] && args+=" -u $udp"
|
||||||
fi
|
|
||||||
|
|
||||||
[ -n "$tcp" ] && args+=" -t $bind/$tcp"
|
|
||||||
[ -n "$udp" ] && args+=" -u $bind/$udp"
|
|
||||||
|
|
||||||
echo "$args"
|
echo "$args"
|
||||||
return 0
|
return 0
|
||||||
@@ -1901,7 +1921,10 @@ validateHost() {
|
|||||||
|
|
||||||
validateHostPorts() {
|
validateHostPorts() {
|
||||||
|
|
||||||
if isNAT && [[ "${HOST_PORTS,,}" == *"/udp"* ]]; then
|
local custom
|
||||||
|
custom=$(getCustomHostPorts "all")
|
||||||
|
|
||||||
|
if isNAT && [[ "$custom" == *"/udp"* ]]; then
|
||||||
warn "UDP ports in \"HOST_PORTS\" are not yet implemented for NAT networking."
|
warn "UDP ports in \"HOST_PORTS\" are not yet implemented for NAT networking."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
+8
-18
@@ -67,16 +67,8 @@ displayReason() {
|
|||||||
|
|
||||||
readQemuPid() {
|
readQemuPid() {
|
||||||
|
|
||||||
local -n _pid="$1"
|
readPidFile "$1" "$QEMU_START_PID" && return 0
|
||||||
local file
|
readPidFile "$1" "$QEMU_PID"
|
||||||
|
|
||||||
for file in "$QEMU_START_PID" "$QEMU_PID"; do
|
|
||||||
if [ -s "$file" ] && read -r _pid < "$file"; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qemuPidFile() {
|
qemuPidFile() {
|
||||||
@@ -100,16 +92,14 @@ waitQemuExit() {
|
|||||||
|
|
||||||
waitQemuPid() {
|
waitQemuPid() {
|
||||||
|
|
||||||
local -n _pid="$1"
|
local cnt=0
|
||||||
local cnt=0 value
|
|
||||||
|
|
||||||
while ! readQemuPid value; do
|
while ! readQemuPid "$1"; do
|
||||||
sleep 0.02
|
sleep 0.02
|
||||||
cnt=$((cnt + 1))
|
cnt=$((cnt + 1))
|
||||||
(( cnt >= 50 )) && return 1
|
(( cnt >= 50 )) && return 1
|
||||||
done
|
done
|
||||||
|
|
||||||
_pid="$value"
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,8 +108,8 @@ forceKillQemu() {
|
|||||||
local reason="$1"
|
local reason="$1"
|
||||||
local pid display
|
local pid display
|
||||||
|
|
||||||
! readQemuPid pid && return 0
|
readQemuPid pid || return 0
|
||||||
! isAlive "$pid" && return 0
|
isAlive "$pid" || return 0
|
||||||
|
|
||||||
display=$(displayReason "$reason")
|
display=$(displayReason "$reason")
|
||||||
error "Forcefully terminating $(app), reason: $display..."
|
error "Forcefully terminating $(app), reason: $display..."
|
||||||
@@ -315,7 +305,7 @@ waitForShutdown() {
|
|||||||
local slp=$!
|
local slp=$!
|
||||||
|
|
||||||
# Stop waiting if the process has exited
|
# Stop waiting if the process has exited
|
||||||
! isAlive "$pid" && break
|
isAlive "$pid" || break
|
||||||
|
|
||||||
# Workaround for stale/zombie QEMU pid file
|
# Workaround for stale/zombie QEMU pid file
|
||||||
[ ! -s "$QEMU_START_PID" ] && [ ! -s "$QEMU_PID" ] && break
|
[ ! -s "$QEMU_START_PID" ] && [ ! -s "$QEMU_PID" ] && break
|
||||||
@@ -382,7 +372,7 @@ graceful_shutdown() {
|
|||||||
finish "$code"
|
finish "$code"
|
||||||
}
|
}
|
||||||
|
|
||||||
! enabled "$SHUTDOWN" && return 0
|
enabled "$SHUTDOWN" || return 0
|
||||||
[ -n "${QEMU_TIMEOUT:-}" ] && TIMEOUT="$QEMU_TIMEOUT"
|
[ -n "${QEMU_TIMEOUT:-}" ] && TIMEOUT="$QEMU_TIMEOUT"
|
||||||
|
|
||||||
if interactive; then
|
if interactive; then
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@ checkSse42() {
|
|||||||
|
|
||||||
if ! hasFlag "sse4_2"; then
|
if ! hasFlag "sse4_2"; then
|
||||||
error "Your CPU does not have the SSE4 instruction set that Virtual DSM requires!"
|
error "Your CPU does not have the SSE4 instruction set that Virtual DSM requires!"
|
||||||
! enabled "$DEBUG" && exit 88
|
enabled "$DEBUG" || exit 88
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
+3
-3
@@ -209,7 +209,7 @@ normalizeRamSize() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
RAM_SIZE=$(echo "${RAM_SIZE^^}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
|
RAM_SIZE=$(echo "${RAM_SIZE^^}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
|
||||||
! numfmt --from=iec "$RAM_SIZE" &>/dev/null && error "Invalid RAM_SIZE: $RAM_SIZE" && exit 16
|
numfmt --from=iec "$RAM_SIZE" &>/dev/null || { error "Invalid RAM_SIZE: $RAM_SIZE" && exit 16; }
|
||||||
wanted=$(numfmt --from=iec "$RAM_SIZE")
|
wanted=$(numfmt --from=iec "$RAM_SIZE")
|
||||||
[ "$wanted" -lt "$RAM_MINIMUM" ] && error "RAM_SIZE is too low: $RAM_SIZE" && exit 16
|
[ "$wanted" -lt "$RAM_MINIMUM" ] && error "RAM_SIZE is too low: $RAM_SIZE" && exit 16
|
||||||
|
|
||||||
@@ -254,7 +254,7 @@ checkKvm() {
|
|||||||
fi
|
fi
|
||||||
if ! grep -qw "sse4_2" <<< "$flags"; then
|
if ! grep -qw "sse4_2" <<< "$flags"; then
|
||||||
error "Your CPU does not have the SSE4 instruction set that Virtual DSM requires!"
|
error "Your CPU does not have the SSE4 instruction set that Virtual DSM requires!"
|
||||||
! enabled "$DEBUG" && exit 88
|
enabled "$DEBUG" || exit 88
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -275,7 +275,7 @@ checkKvm() {
|
|||||||
error "KVM acceleration is not available $KVM_ERR, this will cause the machine to run about 10 times slower."
|
error "KVM acceleration is not available $KVM_ERR, this will cause the machine to run about 10 times slower."
|
||||||
error "See the FAQ for possible causes, or disable acceleration by adding the \"KVM=N\" variable (not recommended)." ;;
|
error "See the FAQ for possible causes, or disable acceleration by adding the \"KVM=N\" variable (not recommended)." ;;
|
||||||
esac
|
esac
|
||||||
! enabled "$DEBUG" && exit 88
|
enabled "$DEBUG" || exit 88
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
+6
-7
@@ -73,7 +73,7 @@ startHostBinary() {
|
|||||||
pid=$!
|
pid=$!
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$pid" > "$HOST_PID"
|
printf '%s\n' "$pid" > "$HOST_PID"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -82,23 +82,22 @@ waitForSocket() {
|
|||||||
|
|
||||||
local socket="$1"
|
local socket="$1"
|
||||||
local exit_code="$2"
|
local exit_code="$2"
|
||||||
local pid cnt=0
|
local timeout=5 pid
|
||||||
|
local deadline=$((SECONDS + timeout))
|
||||||
|
|
||||||
while [ ! -S "$socket" ]; do
|
while [ ! -S "$socket" ]; do
|
||||||
|
|
||||||
if ! read -r pid < "$HOST_PID" || ! isAlive "$pid"; then
|
if ! readPidFile pid "$HOST_PID" || ! isAlive "$pid"; then
|
||||||
error "qemu-host exited unexpectedly!"
|
error "qemu-host exited unexpectedly!"
|
||||||
exit "$exit_code"
|
exit "$exit_code"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep 0.1
|
if (( SECONDS >= deadline )); then
|
||||||
cnt=$((cnt + 1))
|
|
||||||
|
|
||||||
if (( cnt > 50 )); then
|
|
||||||
error "Failed to create qemu-host socket: $socket"
|
error "Failed to create qemu-host socket: $socket"
|
||||||
exit "$exit_code"
|
exit "$exit_code"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
sleep 0.1
|
||||||
done
|
done
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
+2
-2
@@ -64,7 +64,7 @@ stopWebServer() {
|
|||||||
|
|
||||||
local pid
|
local pid
|
||||||
|
|
||||||
if [ -s "$WEB_PID" ] && read -r pid < "$WEB_PID" && [ -n "$pid" ]; then
|
if readPidFile pid "$WEB_PID"; then
|
||||||
pKill "$pid" 2
|
pKill "$pid" 2
|
||||||
|
|
||||||
if isAlive "$pid"; then
|
if isAlive "$pid"; then
|
||||||
@@ -88,7 +88,7 @@ stopWebsocketServer() {
|
|||||||
|
|
||||||
local pid
|
local pid
|
||||||
|
|
||||||
if [ -s "$WSD_PID" ] && read -r pid < "$WSD_PID" && [ -n "$pid" ]; then
|
if readPidFile pid "$WSD_PID"; then
|
||||||
pKill "$pid" 2
|
pKill "$pid" 2
|
||||||
|
|
||||||
if isAlive "$pid"; then
|
if isAlive "$pid"; then
|
||||||
|
|||||||
+31
-18
@@ -7,6 +7,24 @@ info () { printf "%b%s%b" "\E[1;34m❯ \E[1;36m" "${1:-}" "\E[0m\n"; }
|
|||||||
error () { printf "%b%s%b" "\E[1;31m❯ " "ERROR: ${1:-}" "\E[0m\n" >&2; }
|
error () { printf "%b%s%b" "\E[1;31m❯ " "ERROR: ${1:-}" "\E[0m\n" >&2; }
|
||||||
warn () { printf "%b%s%b" "\E[1;31m❯ " "Warning: ${1:-}" "\E[0m\n" >&2; }
|
warn () { printf "%b%s%b" "\E[1;31m❯ " "Warning: ${1:-}" "\E[0m\n" >&2; }
|
||||||
|
|
||||||
|
readPidFile() {
|
||||||
|
|
||||||
|
local -n _pid="$1"
|
||||||
|
_pid=""
|
||||||
|
|
||||||
|
if ! _pid=$(cat -- "$2" 2>/dev/null); then
|
||||||
|
_pid=""
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! "$_pid" =~ ^[1-9][0-9]*$ ]]; then
|
||||||
|
_pid=""
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
hasFlag() {
|
hasFlag() {
|
||||||
|
|
||||||
# Match a whitespace-delimited token in /proc/cpuinfo
|
# Match a whitespace-delimited token in /proc/cpuinfo
|
||||||
@@ -118,14 +136,13 @@ isAlive() {
|
|||||||
|
|
||||||
waitPid() {
|
waitPid() {
|
||||||
|
|
||||||
local i=0
|
|
||||||
local pid="$1"
|
local pid="$1"
|
||||||
local timeout="${2:-10}"
|
local timeout="${2:-10}"
|
||||||
|
local deadline=$((SECONDS + timeout))
|
||||||
|
|
||||||
while [ -n "$pid" ] && isAlive "$pid"; do
|
while [ -n "$pid" ] && isAlive "$pid"; do
|
||||||
|
(( SECONDS >= deadline )) && return 1
|
||||||
sleep 0.2
|
sleep 0.2
|
||||||
i=$((i + 1))
|
|
||||||
(( i >= timeout * 5 )) && return 1
|
|
||||||
done
|
done
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@@ -133,18 +150,16 @@ waitPid() {
|
|||||||
|
|
||||||
waitPidFile() {
|
waitPidFile() {
|
||||||
|
|
||||||
local i=0 pid
|
local pid
|
||||||
local file="$1"
|
local file="$1"
|
||||||
local timeout="${2:-10}"
|
local timeout="${2:-10}"
|
||||||
|
local deadline=$((SECONDS + timeout))
|
||||||
|
|
||||||
[ ! -s "$file" ] && return 0
|
readPidFile pid "$file" || return 0
|
||||||
! read -r pid <"$file" && return 0
|
|
||||||
[ -z "$pid" ] && return 0
|
|
||||||
|
|
||||||
while [ -s "$file" ] && isAlive "$pid"; do
|
while [ -s "$file" ] && isAlive "$pid"; do
|
||||||
|
(( SECONDS >= deadline )) && return 1
|
||||||
sleep 0.2
|
sleep 0.2
|
||||||
i=$((i + 1))
|
|
||||||
(( i >= timeout * 5 )) && return 1
|
|
||||||
done
|
done
|
||||||
|
|
||||||
rm -f -- "$file"
|
rm -f -- "$file"
|
||||||
@@ -167,19 +182,19 @@ pKill() {
|
|||||||
|
|
||||||
fWait() {
|
fWait() {
|
||||||
|
|
||||||
local i=0
|
|
||||||
local name="$1"
|
local name="$1"
|
||||||
local timeout="${2:-10}"
|
local timeout="${2:-10}"
|
||||||
|
local deadline=$((SECONDS + timeout))
|
||||||
|
|
||||||
[ -z "$name" ] && return 0
|
[ -z "$name" ] && return 0
|
||||||
|
|
||||||
while pgrep -f -l "$name" >/dev/null; do
|
while pgrep -f -l "$name" >/dev/null; do
|
||||||
sleep 0.2
|
if (( SECONDS >= deadline )); then
|
||||||
i=$((i + 1))
|
|
||||||
if (( i >= timeout * 5 )); then
|
|
||||||
warn "Timed out while waiting for process: $name"
|
warn "Timed out while waiting for process: $name"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
sleep 0.2
|
||||||
done
|
done
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@@ -203,9 +218,7 @@ sKill() {
|
|||||||
local pid
|
local pid
|
||||||
local file="$1"
|
local file="$1"
|
||||||
|
|
||||||
[ ! -s "$file" ] && return 0
|
readPidFile pid "$file" || return 0
|
||||||
! read -r pid <"$file" && return 0
|
|
||||||
[ -z "$pid" ] && return 0
|
|
||||||
|
|
||||||
if isAlive "$pid"; then
|
if isAlive "$pid"; then
|
||||||
{ kill -15 -- "$pid" || :; } 2>/dev/null
|
{ kill -15 -- "$pid" || :; } 2>/dev/null
|
||||||
@@ -243,7 +256,7 @@ setOwner() {
|
|||||||
uid=$(stat -c '%u' "$dir") || return 1
|
uid=$(stat -c '%u' "$dir") || return 1
|
||||||
gid=$(stat -c '%g' "$dir") || return 1
|
gid=$(stat -c '%g' "$dir") || return 1
|
||||||
|
|
||||||
! chown "$uid:$gid" "$file" && return 1
|
chown "$uid:$gid" "$file" || return 1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -254,7 +267,7 @@ makeDir() {
|
|||||||
local dir uid gid
|
local dir uid gid
|
||||||
|
|
||||||
[ -d "$path" ] && return 0
|
[ -d "$path" ] && return 0
|
||||||
! mkdir -p "$path" && return 1
|
mkdir -p "$path" || return 1
|
||||||
|
|
||||||
dir=$(dirname -- "$path")
|
dir=$(dirname -- "$path")
|
||||||
|
|
||||||
|
|||||||
+10
-3
@@ -71,6 +71,13 @@ function processInfo() {
|
|||||||
var response = request;
|
var response = request;
|
||||||
request = null;
|
request = null;
|
||||||
|
|
||||||
|
var status = response.status;
|
||||||
|
|
||||||
|
if (status == 502 || status == 503 || status == 504) {
|
||||||
|
schedule();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var msg = response.responseText;
|
var msg = response.responseText;
|
||||||
if (msg == null || msg.length == 0) {
|
if (msg == null || msg.length == 0) {
|
||||||
|
|
||||||
@@ -83,9 +90,9 @@ function processInfo() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var notFound = (response.status == 404);
|
var notFound = (status == 404);
|
||||||
|
|
||||||
if (response.status == 200) {
|
if (status == 200) {
|
||||||
if (msg.toLowerCase().indexOf("<html>") !== -1) {
|
if (msg.toLowerCase().indexOf("<html>") !== -1) {
|
||||||
notFound = true;
|
notFound = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -103,7 +110,7 @@ function processInfo() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
setError("Error: Received statuscode " + response.status);
|
setError("Error: Received statuscode " + status);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user