From faa6f09bd2d3136af2c59d5012280c6d634669c9 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 5 May 2023 17:24:06 +0200 Subject: [PATCH 01/25] Comment --- run/power.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/power.sh b/run/power.sh index ba97874..08cfd03 100644 --- a/run/power.sh +++ b/run/power.sh @@ -32,7 +32,7 @@ _graceful_shutdown() { # Don't send the powerdown signal because vDSM ignores ACPI signals # echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}" > /dev/null - # Send shutdown command to host via serial port + # Send shutdown command to guest agent via serial port RESPONSE=$(curl -s -m 2 -S http://127.0.0.1:2210/write?command=6 2>&1) if [[ ! "${RESPONSE}" =~ "\"success\"" ]] ; then From dcd6ba348b115b0ab06235c15b62cc5322bd1203 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 5 May 2023 20:20:11 +0200 Subject: [PATCH 02/25] Background color --- run/server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/server.sh b/run/server.sh index 953ff2b..9f51517 100644 --- a/run/server.sh +++ b/run/server.sh @@ -5,7 +5,7 @@ trap 'kill 0' EXIT trap exit SIGINT SIGTERM # Serve the page -HTML="\ +HTML="\

$2

" LENGTH="${#HTML}" From 6e0b787a66e5f91c706a31bc537c0c8848193569 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 5 May 2023 20:30:28 +0200 Subject: [PATCH 03/25] Add Synology Assistant --- run/network.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run/network.sh b/run/network.sh index c608315..28c56b9 100644 --- a/run/network.sh +++ b/run/network.sh @@ -229,7 +229,8 @@ else configureDHCP # Display the received IP on port 5000 - HTML="DSM is using another IP address.

(Check the logfile to see which one was assigned.)" + HTML="DSM is using another IP address.

(Check the Docker logfile to see which one was assigned,
or download\ + Synology Assistant.)" pkill -f server.sh || true /run/server.sh 80 "${HTML}" > /dev/null & From cb003d798ab220dd8851454d70eef634e5f93055 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 5 May 2023 20:32:35 +0200 Subject: [PATCH 04/25] Add Synology Assistant --- run/network.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/run/network.sh b/run/network.sh index 28c56b9..46ef5bb 100644 --- a/run/network.sh +++ b/run/network.sh @@ -229,8 +229,9 @@ else configureDHCP # Display the received IP on port 5000 - HTML="DSM is using another IP address.

(Check the Docker logfile to see which one was assigned,
or download\ - Synology Assistant.)" + HTML="DSM is using another IP address.

(Check the Docker logfile to see which one was assigned,
or download the\ + \ + Synology Assistant utility.)" pkill -f server.sh || true /run/server.sh 80 "${HTML}" > /dev/null & From 23d9c43cb0b64a1d25902b57d7ba0d2c61e01fd6 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 5 May 2023 20:34:43 +0200 Subject: [PATCH 05/25] Set font to Verdana --- run/server.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run/server.sh b/run/server.sh index 9f51517..f26749f 100644 --- a/run/server.sh +++ b/run/server.sh @@ -5,8 +5,8 @@ trap 'kill 0' EXIT trap exit SIGINT SIGTERM # Serve the page -HTML="\ -

$2

" +HTML="

$2

" LENGTH="${#HTML}" From 59d0338c8e6601244ce2443e6059023d18089e88 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 5 May 2023 20:38:32 +0200 Subject: [PATCH 06/25] White links --- run/server.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run/server.sh b/run/server.sh index f26749f..ca7bdcb 100644 --- a/run/server.sh +++ b/run/server.sh @@ -5,8 +5,8 @@ trap 'kill 0' EXIT trap exit SIGINT SIGTERM # Serve the page -HTML="

$2

" +HTML="

$2

" LENGTH="${#HTML}" From e0fc215ac66a584e15b5705d3aaf3d70dffbd4d7 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 5 May 2023 20:39:17 +0200 Subject: [PATCH 07/25] Line break --- run/network.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/network.sh b/run/network.sh index 46ef5bb..411d9ff 100644 --- a/run/network.sh +++ b/run/network.sh @@ -229,7 +229,7 @@ else configureDHCP # Display the received IP on port 5000 - HTML="DSM is using another IP address.

(Check the Docker logfile to see which one was assigned,
or download the\ + HTML="DSM is using another IP address.

(Check the Docker logfile to see which one was
assigned, or download the\ \ Synology Assistant utility.)" From 50646396e780c9daabbb147258946fec46ad4f17 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 5 May 2023 20:47:57 +0200 Subject: [PATCH 08/25] Add Title --- run/server.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run/server.sh b/run/server.sh index ca7bdcb..ae3c6ae 100644 --- a/run/server.sh +++ b/run/server.sh @@ -5,8 +5,8 @@ trap 'kill 0' EXIT trap exit SIGINT SIGTERM # Serve the page -HTML="

$2

" +HTML="VirtualDSM

$2

" LENGTH="${#HTML}" From 90c613ce04066fb20cf0cb839f0653db24c2a2d2 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 00:24:44 +0200 Subject: [PATCH 09/25] action-pack --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7de8c90..e027ef8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,7 +72,7 @@ jobs: - uses: actions/checkout@v3 - name: Create a release - uses: kroese/github-release@v6 + uses: action-pack/github-release@v6 env: GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} with: @@ -81,7 +81,7 @@ jobs: body: "Release v${{ vars.MAJOR }}.${{ vars.MINOR }}" - name: Increment minor version - uses: kroese/increment@v1 + uses: action-pack/increment@v1 with: name: 'MINOR' token: ${{ secrets.REPO_ACCESS_TOKEN }} @@ -97,7 +97,7 @@ jobs: fetch-depth: 0 - name: Push to Gitlab mirror - uses: kroese/gitlab-sync@v2 + uses: action-pack/gitlab-sync@v2 with: url: ${{ secrets.GITLAB_URL }} token: ${{ secrets.GITLAB_TOKEN }} From 9bf5bf44af89a736a96bfbf3a70378d2e9391d0c Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 12:55:48 +0200 Subject: [PATCH 10/25] Synology Assistant --- run/network.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run/network.sh b/run/network.sh index 411d9ff..d04c140 100644 --- a/run/network.sh +++ b/run/network.sh @@ -229,9 +229,9 @@ else configureDHCP # Display the received IP on port 5000 - HTML="DSM is using another IP address.

(Check the Docker logfile to see which one was
assigned, or download the\ + HTML="DSM is using another IP address.

Check the Docker logfile to see which one was
assigned, or download the\ \ - Synology Assistant utility.)" + Synology Assistant utility." pkill -f server.sh || true /run/server.sh 80 "${HTML}" > /dev/null & From 8568f34a58ef862362c123ebdddd2d16de12f3b8 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 13:23:34 +0200 Subject: [PATCH 11/25] Ignore case --- run/check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/check.sh b/run/check.sh index 3c2d69a..0b74eb7 100644 --- a/run/check.sh +++ b/run/check.sh @@ -5,7 +5,7 @@ set -u : ${DHCP:='N'} -if [ "$DHCP" = "Y" ]; then +if [[ "${DHCP}" == [Yy1]* ]]; then PORT=5555 IP="127.0.0.1" else From f893b34f6725c9bb40a3e04fef02abade88f449f Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 13:26:46 +0200 Subject: [PATCH 12/25] Ignore case --- run/disk.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/run/disk.sh b/run/disk.sh index 6b7fd7b..2c1be79 100644 --- a/run/disk.sh +++ b/run/disk.sh @@ -36,7 +36,7 @@ if [ -f "${DATA}" ]; then echo "INFO: Resizing data disk from $OLD_SIZE to $DATA_SIZE bytes.." - if [ "$ALLOCATE" = "N" ]; then + if [[ "${ALLOCATE}" == [Nn]* ]]; then # Resize file by changing its length truncate -s "${DATA_SIZE}" "${DATA}"; @@ -58,7 +58,7 @@ if [ -f "${DATA}" ]; then echo "ERROR: Could not allocate a file for the virtual disk." && exit 85 fi - if [ "$ALLOCATE" = "Z" ]; then + if [[ "${ALLOCATE}" == [Zz]* ]]; then GB=$(( (REQ + 1073741823)/1073741824 )) @@ -81,7 +81,7 @@ fi if [ ! -f "${DATA}" ]; then - if [ "$ALLOCATE" = "N" ]; then + if [[ "${ALLOCATE}" == [Nn]* ]]; then # Create an empty file truncate -s "${DATA_SIZE}" "${DATA}" @@ -102,7 +102,7 @@ if [ ! -f "${DATA}" ]; then echo "ERROR: Could not allocate a file for the virtual disk." && exit 87 fi - if [ "$ALLOCATE" = "Z" ]; then + if [[ "${ALLOCATE}" == [Zz]* ]]; then echo "INFO: Preallocating ${DISK_SIZE} of diskspace, please wait..." dd if=/dev/urandom of="${DATA}" count="${DATA_SIZE}" bs=1M iflag=count_bytes status=none From 93f7c6fa2993b8d83cef66a39ebbccd56af1610d Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 13:31:00 +0200 Subject: [PATCH 13/25] Ignore case --- run/install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/run/install.sh b/run/install.sh index 830680f..80479ad 100644 --- a/run/install.sh +++ b/run/install.sh @@ -33,7 +33,7 @@ TMP="$STORAGE/tmp" RD="$TMP/rd.gz" rm -rf "$TMP" && mkdir -p "$TMP" -[ "$DEBUG" = "Y" ] && set -x +[[ "${DEBUG}" == [Yy]* ]] && set -x LOC="$DL/release/7.0.1/42218/DSM_VirtualDSM_42218.pat" @@ -113,7 +113,7 @@ BOOT=$(find "$TMP" -name "*.bin.zip") BOOT=$(echo "$BOOT" | head -c -5) unzip -q -o "$BOOT".zip -d "$TMP" -[ "$ALLOCATE" != "Z" ] && echo "Install: Allocating diskspace..." +[[ "${ALLOCATE}" == [Zz]* ]] && echo "Install: Allocating diskspace..." SYSTEM="$TMP/sys.img" SYSTEM_SIZE=4954537983 @@ -130,7 +130,7 @@ if ! fallocate -l "${SYSTEM_SIZE}" "${SYSTEM}"; then echo "ERROR: Could not allocate a file for the system disk." && exit 88 fi - if [ "$ALLOCATE" = "Z" ]; then +if [[ "${ALLOCATE}" == [Zz]* ]]; then echo "Install: Preallocating 4 GB of diskspace..." dd if=/dev/urandom of="${SYSTEM}" count="${SYSTEM_SIZE}" bs=1M iflag=count_bytes status=none fi @@ -211,6 +211,6 @@ mv -f "$SYSTEM" "$STORAGE"/"$BASE".system.img rm -rf "$TMP" { set +x; } 2>/dev/null -[ "$DEBUG" = "Y" ] && echo +[[ "${DEBUG}" == [Yy]* ]] && echo return 0 From 658272eef056873a5fad91d17c2f51ae1ab7cab6 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 13:38:21 +0200 Subject: [PATCH 14/25] Ignore case --- run/network.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/run/network.sh b/run/network.sh index d04c140..e64cccd 100644 --- a/run/network.sh +++ b/run/network.sh @@ -25,7 +25,7 @@ configureDHCP() { NETWORK=$(ip -o route | grep "${VM_NET_DEV}" | grep -v default | awk '{print $1}') IP=$(ip address show dev "${VM_NET_DEV}" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/) - [ "$DEBUG" = "Y" ] && set -x + [[ "${DEBUG}" == [Yy]* ] && set -x { ip link add link "${VM_NET_DEV}" "${VM_NET_VLAN}" type macvlan mode bridge 2> /dev/null ; rc=$?; } || : if (( rc != 0 )); then @@ -99,7 +99,7 @@ configureDHCP() { configureNAT () { VM_NET_IP='20.20.20.21' - [ "$DEBUG" = "Y" ] && set -x + [[ "${DEBUG}" == [Yy]* ]] && set -x #Create bridge with static IP for the VM guest @@ -129,7 +129,7 @@ configureNAT () { fi { set +x; } 2>/dev/null - [ "$DEBUG" = "Y" ] && echo + [[ "${DEBUG}" == [Yy]* ]] && echo #Check port forwarding flag if [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then @@ -151,7 +151,7 @@ configureNAT () { # Build DNS options from container /etc/resolv.conf - if [ "$DEBUG" = "Y" ]; then + if [[ "${DEBUG}" == [Yy]* ]]; then echo "/etc/resolv.conf:" && echo && cat /etc/resolv.conf && echo fi @@ -178,7 +178,7 @@ configureNAT () { DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//') - [ "$DEBUG" = "Y" ] && set -x + [[ "${DEBUG}" == [Yy]* ]] && set -x $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS} @@ -204,7 +204,7 @@ update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy > /dev/null VM_NET_MAC="${VM_NET_MAC//-/:}" GATEWAY=$(ip r | grep default | awk '{print $3}') -if [ "$DEBUG" = "Y" ]; then +if [[ "${DEBUG}" == [Yy]* ]]; then IP=$(ip address show dev "${VM_NET_DEV}" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/) echo "INFO: Container IP is ${IP} with gateway ${GATEWAY}" && echo @@ -213,12 +213,7 @@ if [ "$DEBUG" = "Y" ]; then fi -if [ "$DHCP" != "Y" ]; then - - # Configuration for static IP - configureNAT - -else +if [[ "${DHCP}" == [Yy]* ]]; then if [[ "$GATEWAY" == "172."* ]]; then echo -n "ERROR: You cannot enable DHCP while the container is " @@ -237,16 +232,21 @@ else /run/server.sh 80 "${HTML}" > /dev/null & /run/server.sh 5000 "${HTML}" > /dev/null & +else + + # Configuration for static IP + configureNAT + fi NET_OPTS="${NET_OPTS} -device virtio-net-pci,romfile=,netdev=hostnet0,mac=${VM_NET_MAC},id=net0" -if [ "$DHCP" = "Y" ]; then +if [[ "${DHCP}" == [Yy]* ]]; then # Add extra LAN interface for Docker Healthcheck script NET_OPTS="${NET_OPTS} -netdev user,id=hostnet1,restrict=y,hostfwd=tcp::5555-:5000" NET_OPTS="${NET_OPTS} -device virtio-net-pci,romfile=,netdev=hostnet1,id=net1" fi -[ "$DEBUG" = "Y" ] && echo && echo "Finished network setup.." && echo +[[ "${DEBUG}" == [Yy]* ]] && echo && echo "Finished network setup.." && echo return 0 From 1b46f6ec7a6aa49ddd0b2fa948da5c519069d7c3 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 13:48:27 +0200 Subject: [PATCH 15/25] Ignore case --- run/run.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/run/run.sh b/run/run.sh index 2d20f12..f5b0fa2 100755 --- a/run/run.sh +++ b/run/run.sh @@ -11,14 +11,15 @@ set -Eeuo pipefail : ${RAM_SIZE:='512M'} # Maximum RAM amount echo "Starting Virtual DSM for Docker v${VERSION}..." +trap 'echo >&2 "Error status $? for: ${BASH_COMMAND} (line $LINENO/$BASH_LINENO)"' ERR + +[ ! -f "/run/run.sh" ] && echo "ERROR: Script must run inside Docker container!" && exit 11 +[ "$(id -u)" -ne "$ROOTUID" ] && echo "ERROR: Script must be executed with root privileges." && exit 12 STORAGE="/storage" KERNEL=$(uname -r | cut -b 1) -trap 'echo >&2 "Error status $? for: ${BASH_COMMAND} (line $LINENO/$BASH_LINENO)"' ERR - -[ ! -d "$STORAGE" ] && echo "Storage folder (${STORAGE}) not found!" && exit 69 -[ ! -f "/run/run.sh" ] && echo "Script must run inside Docker container!" && exit 60 +[ ! -d "$STORAGE" ] && echo "ERROR: Storage folder (${STORAGE}) not found!" && exit 13 if [ -f "$STORAGE"/dsm.ver ]; then BASE=$(cat "${STORAGE}/dsm.ver") @@ -58,7 +59,7 @@ fi if [ -n "${KVM_ERR}" ]; then echo "ERROR: KVM acceleration not detected ${KVM_ERR}, please enable it." - [ "$DEBUG" != "Y" ] && exit 88 + [[ "${DEBUG}" == [Yy]* ]] && exit 88 else KVM_OPTS=",accel=kvm -enable-kvm -cpu host" fi @@ -78,7 +79,7 @@ trap - ERR set -m ( - [ "$DEBUG" = "Y" ] && set -x + [[ "${DEBUG}" == [Yy]* ]] && set -x qemu-system-x86_64 ${ARGS:+ $ARGS} & echo $! > "${_QEMU_PID}" { set +x; } 2>/dev/null ) From 390ad651c5c697dc1b42a2886b699786e4bb9fe5 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 13:50:34 +0200 Subject: [PATCH 16/25] Ignore case --- run/serial.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/serial.sh b/run/serial.sh index 8766875..708b7ad 100644 --- a/run/serial.sh +++ b/run/serial.sh @@ -31,7 +31,7 @@ HOST_ARGS+=("-cpu_arch=${HOST_CPU}") [ -n "$HOST_VERSION" ] && HOST_ARGS+=("-version=${HOST_VERSION}") [ -n "$HOST_TIMESTAMP" ] && HOST_ARGS+=("-ts=${HOST_TIMESTAMP}") -if [ "$HOST_DEBUG" = "Y" ]; then +if [[ "${HOST_DEBUG}" == [Yy]* ]]; then set -x ./run/host.bin "${HOST_ARGS[@]}" & { set +x; } 2>/dev/null From b0fc2e0528f4a7f06f65de568d104cb972760a1e Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 13:58:54 +0200 Subject: [PATCH 17/25] Ignore case --- run/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run/install.sh b/run/install.sh index 80479ad..f59b1d4 100644 --- a/run/install.sh +++ b/run/install.sh @@ -33,7 +33,7 @@ TMP="$STORAGE/tmp" RD="$TMP/rd.gz" rm -rf "$TMP" && mkdir -p "$TMP" -[[ "${DEBUG}" == [Yy]* ]] && set -x +[[ "${DEBUG}" == [Yy1]* ]] && set -x LOC="$DL/release/7.0.1/42218/DSM_VirtualDSM_42218.pat" @@ -211,6 +211,6 @@ mv -f "$SYSTEM" "$STORAGE"/"$BASE".system.img rm -rf "$TMP" { set +x; } 2>/dev/null -[[ "${DEBUG}" == [Yy]* ]] && echo +[[ "${DEBUG}" == [Yy1]* ]] && echo return 0 From aac111619789b8100e2dfcd3a1773a007947e582 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 13:59:14 +0200 Subject: [PATCH 18/25] Ignore case --- run/serial.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/serial.sh b/run/serial.sh index 708b7ad..148178a 100644 --- a/run/serial.sh +++ b/run/serial.sh @@ -31,7 +31,7 @@ HOST_ARGS+=("-cpu_arch=${HOST_CPU}") [ -n "$HOST_VERSION" ] && HOST_ARGS+=("-version=${HOST_VERSION}") [ -n "$HOST_TIMESTAMP" ] && HOST_ARGS+=("-ts=${HOST_TIMESTAMP}") -if [[ "${HOST_DEBUG}" == [Yy]* ]]; then +if [[ "${HOST_DEBUG}" == [Yy1]* ]]; then set -x ./run/host.bin "${HOST_ARGS[@]}" & { set +x; } 2>/dev/null From 5f3345796566f9e8fb2888836822577dbf75de09 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 13:59:48 +0200 Subject: [PATCH 19/25] Ignore case --- run/run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run/run.sh b/run/run.sh index f5b0fa2..df5ead1 100755 --- a/run/run.sh +++ b/run/run.sh @@ -59,7 +59,7 @@ fi if [ -n "${KVM_ERR}" ]; then echo "ERROR: KVM acceleration not detected ${KVM_ERR}, please enable it." - [[ "${DEBUG}" == [Yy]* ]] && exit 88 + [[ "${DEBUG}" == [Yy1]* ]] && exit 88 else KVM_OPTS=",accel=kvm -enable-kvm -cpu host" fi @@ -79,7 +79,7 @@ trap - ERR set -m ( - [[ "${DEBUG}" == [Yy]* ]] && set -x + [[ "${DEBUG}" == [Yy1]* ]] && set -x qemu-system-x86_64 ${ARGS:+ $ARGS} & echo $! > "${_QEMU_PID}" { set +x; } 2>/dev/null ) From a732cebe90c2fb4333a05c9008817e21b7931844 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 14:02:29 +0200 Subject: [PATCH 20/25] Ignore case --- run/network.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/run/network.sh b/run/network.sh index e64cccd..1a94b3e 100644 --- a/run/network.sh +++ b/run/network.sh @@ -25,7 +25,7 @@ configureDHCP() { NETWORK=$(ip -o route | grep "${VM_NET_DEV}" | grep -v default | awk '{print $1}') IP=$(ip address show dev "${VM_NET_DEV}" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/) - [[ "${DEBUG}" == [Yy]* ] && set -x + [[ "${DEBUG}" == [Yy1]* ] && set -x { ip link add link "${VM_NET_DEV}" "${VM_NET_VLAN}" type macvlan mode bridge 2> /dev/null ; rc=$?; } || : if (( rc != 0 )); then @@ -99,7 +99,7 @@ configureDHCP() { configureNAT () { VM_NET_IP='20.20.20.21' - [[ "${DEBUG}" == [Yy]* ]] && set -x + [[ "${DEBUG}" == [Yy1]* ]] && set -x #Create bridge with static IP for the VM guest @@ -129,7 +129,7 @@ configureNAT () { fi { set +x; } 2>/dev/null - [[ "${DEBUG}" == [Yy]* ]] && echo + [[ "${DEBUG}" == [Yy1]* ]] && echo #Check port forwarding flag if [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then @@ -151,7 +151,7 @@ configureNAT () { # Build DNS options from container /etc/resolv.conf - if [[ "${DEBUG}" == [Yy]* ]]; then + if [[ "${DEBUG}" == [Yy1]* ]]; then echo "/etc/resolv.conf:" && echo && cat /etc/resolv.conf && echo fi @@ -178,7 +178,7 @@ configureNAT () { DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//') - [[ "${DEBUG}" == [Yy]* ]] && set -x + [[ "${DEBUG}" == [Yy1]* ]] && set -x $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS} @@ -204,7 +204,7 @@ update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy > /dev/null VM_NET_MAC="${VM_NET_MAC//-/:}" GATEWAY=$(ip r | grep default | awk '{print $3}') -if [[ "${DEBUG}" == [Yy]* ]]; then +if [[ "${DEBUG}" == [Yy1]* ]]; then IP=$(ip address show dev "${VM_NET_DEV}" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/) echo "INFO: Container IP is ${IP} with gateway ${GATEWAY}" && echo @@ -213,7 +213,7 @@ if [[ "${DEBUG}" == [Yy]* ]]; then fi -if [[ "${DHCP}" == [Yy]* ]]; then +if [[ "${DHCP}" == [Yy1]* ]]; then if [[ "$GATEWAY" == "172."* ]]; then echo -n "ERROR: You cannot enable DHCP while the container is " @@ -241,12 +241,12 @@ fi NET_OPTS="${NET_OPTS} -device virtio-net-pci,romfile=,netdev=hostnet0,mac=${VM_NET_MAC},id=net0" -if [[ "${DHCP}" == [Yy]* ]]; then +if [[ "${DHCP}" == [Yy1]* ]]; then # Add extra LAN interface for Docker Healthcheck script NET_OPTS="${NET_OPTS} -netdev user,id=hostnet1,restrict=y,hostfwd=tcp::5555-:5000" NET_OPTS="${NET_OPTS} -device virtio-net-pci,romfile=,netdev=hostnet1,id=net1" fi -[[ "${DEBUG}" == [Yy]* ]] && echo && echo "Finished network setup.." && echo +[[ "${DEBUG}" == [Yy1]* ]] && echo && echo "Finished network setup.." && echo return 0 From 3553f11e167bd351406687a7d2316bdec1338c7e Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 14:05:42 +0200 Subject: [PATCH 21/25] Check for root --- run/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/run.sh b/run/run.sh index df5ead1..9557ae0 100755 --- a/run/run.sh +++ b/run/run.sh @@ -14,7 +14,7 @@ echo "Starting Virtual DSM for Docker v${VERSION}..." trap 'echo >&2 "Error status $? for: ${BASH_COMMAND} (line $LINENO/$BASH_LINENO)"' ERR [ ! -f "/run/run.sh" ] && echo "ERROR: Script must run inside Docker container!" && exit 11 -[ "$(id -u)" -ne "$ROOTUID" ] && echo "ERROR: Script must be executed with root privileges." && exit 12 +[ "$(id -u)" -ne "0" ] && echo "ERROR: Script must be executed with root privileges." && exit 12 STORAGE="/storage" KERNEL=$(uname -r | cut -b 1) From f83c884ee92deeb20c2bb448ac7fe243b9aaba10 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 14:32:10 +0200 Subject: [PATCH 22/25] Enable vhost support in NAT mode --- run/network.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/run/network.sh b/run/network.sh index 1a94b3e..8d2820d 100644 --- a/run/network.sh +++ b/run/network.sh @@ -80,12 +80,6 @@ configureDHCP() { echo "container: --device-cgroup-rule='c ${MAJOR}:* rwm' --device=/dev/vhost-net" && exit 21 fi - # Create /dev/vhost-net - if [ ! -c /dev/vhost-net ]; then - mknod /dev/vhost-net c 10 238 - chmod 660 /dev/vhost-net - fi - { exec 40>>/dev/vhost-net; rc=$?; } || : if (( rc != 0 )); then @@ -149,6 +143,12 @@ configureNAT () { NET_OPTS="-netdev tap,ifname=${VM_NET_TAP},script=no,downscript=no,id=hostnet0" + { exec 40>>/dev/vhost-net; rc=$?; } || : + + if (( rc == 0 )); then + NET_OPTS="$NET_OPTS,vhost=on,vhostfd=40" + fi + # Build DNS options from container /etc/resolv.conf if [[ "${DEBUG}" == [Yy1]* ]]; then @@ -198,6 +198,12 @@ fi [ ! -c /dev/net/tun ] && echo "ERROR: TUN network interface not available..." && exit 85 +# Create the necessary file structure for /dev/vhost-net +if [ ! -c /dev/vhost-net ]; then + mknod /dev/vhost-net c 10 238 + chmod 660 /dev/vhost-net +fi + update-alternatives --set iptables /usr/sbin/iptables-legacy > /dev/null update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy > /dev/null From 69f0e7110d99f15db747a88a6306bb285c71fd43 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 14:38:02 +0200 Subject: [PATCH 23/25] Bracket --- run/network.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/network.sh b/run/network.sh index 8d2820d..ca1c147 100644 --- a/run/network.sh +++ b/run/network.sh @@ -25,7 +25,7 @@ configureDHCP() { NETWORK=$(ip -o route | grep "${VM_NET_DEV}" | grep -v default | awk '{print $1}') IP=$(ip address show dev "${VM_NET_DEV}" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/) - [[ "${DEBUG}" == [Yy1]* ] && set -x + [[ "${DEBUG}" == [Yy1]* ]] && set -x { ip link add link "${VM_NET_DEV}" "${VM_NET_VLAN}" type macvlan mode bridge 2> /dev/null ; rc=$?; } || : if (( rc != 0 )); then From 8c295356535874c27604dd83d8c4d957db2530cf Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 15:05:36 +0200 Subject: [PATCH 24/25] Add vhost --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 7e75af0..7591b4d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,7 @@ services: RAM_SIZE: "512M" devices: - /dev/kvm + - /dev/vhost-net cap_add: - NET_ADMIN ports: From 2de74557ce3056639fda85e656b5412f0c85ef08 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 6 May 2023 15:08:03 +0200 Subject: [PATCH 25/25] Add vhost --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index f714108..4513ceb 100644 --- a/readme.md +++ b/readme.md @@ -40,6 +40,7 @@ services: DISK_SIZE: "16G" devices: - /dev/kvm + - /dev/vhost-net cap_add: - NET_ADMIN ports: