Unverified Commit d190b3ba authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Use websocket for status messages (#1051)

parent 554f3295
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -37,13 +37,15 @@ RUN set -eu && \
        xz-utils \
        iptables \
        iproute2 \
        apt-utils \
        dnsmasq \
        fakeroot \
        apt-utils \        
        net-tools \
        e2fsprogs \
        qemu-utils \
        websocketd \
        iputils-ping \
        inotify-tools \
        ca-certificates \
        netcat-openbsd \
        qemu-system-x86 && \
+3 −1
Original line number Diff line number Diff line
#!/usr/bin/env bash
set -Eeuo pipefail

: "${PLATFORM:="x64"}"
: "${APP:="Virtual DSM"}"
: "${SUPPORT:="https://github.com/vdsm/virtual-dsm"}"

cd /run

. start.sh      # Placeholder
. start.sh      # Startup hook
. utils.sh      # Load functions
. reset.sh      # Initialize system
. server.sh     # Start webserver
. install.sh    # Run installation
. disk.sh       # Initialize disks
. display.sh    # Initialize graphics
+0 −3
Original line number Diff line number Diff line
@@ -301,7 +301,4 @@ fi
mv -f "$BOOT" "$STORAGE/$BASE.boot.img"
rm -rf "$TMP"

html "Booting DSM instance..."
sleep 1.2

return 0
+23 −15
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ configureDNS() {
  fi

  if [[ "$DNSMASQ_DEBUG" == [Yy1]* ]]; then
    tail -fn +0 "$log" &
    tail -fn +0 "$log" --pid=$$ &
  fi

  return 0
@@ -231,6 +231,7 @@ getHostPorts() {

    [ -z "$list" ] && list="$COM_PORT" || list+=",$COM_PORT"
    [ -z "$list" ] && list="$CHR_PORT" || list+=",$CHR_PORT"
    [ -z "$list" ] && list="$WSD_PORT" || list+=",$WSD_PORT"

  fi

@@ -327,7 +328,7 @@ configurePasst() {
  fi

  if [[ "$PASST_DEBUG" == [Yy1]* ]]; then
    tail -fn +0 "$log" &
    tail -fn +0 "$log" --pid=$$ &
  else
    if [[ "$DEBUG" == [Yy1]* ]]; then
      [ -f "$log" ] && cat "$log" && echo ""
@@ -502,14 +503,24 @@ closeBridge() {
  return 0
}

closeNetwork() {

  if [[ "${WEB:-}" != [Nn]* && "$DHCP" == [Yy1]* ]]; then
closeWeb() {

  # Shutdown nginx
  nginx -s stop 2> /dev/null
  fWait "nginx"

  # Shutdown websocket
  local pid="/var/run/websocketd.pid"
  [ -s "$pid" ] && pKill "$(<"$pid")"
  rm -f "$pid"

  return 0
}

closeNetwork() {

  if [[ "${WEB:-}" != [Nn]* && "$DHCP" == [Yy1]* ]]; then
    closeWeb
  fi

  [[ "$NETWORK" == [Nn]* ]] && return 0
@@ -718,22 +729,19 @@ if [[ "$IP" == "172.17."* ]]; then
  warn "your container IP starts with 172.17.* which will cause conflicts when you install the Container Manager package inside DSM!"
fi

MSG="Booting DSM instance..."
html "$MSG"

if [[ "$DHCP" == [Yy1]* ]]; then

  # Configure for macvtap interface
  configureDHCP || exit 20

  MSG="Booting DSM instance..."
  html "$MSG"

else

  if [[ "${WEB:-}" != [Nn]* ]]; then

    # Shutdown nginx
    nginx -s stop 2> /dev/null
    fWait "nginx"

    sleep 1.2
    closeWeb
  fi

  case "${NETWORK,,}" in
+1 −47
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@ set -Eeuo pipefail

# Docker environment variables

: "${KVM:="Y"}"
: "${HOST_CPU:=""}"
: "${CPU_FLAGS:=""}"
: "${CPU_MODEL:=""}"
@@ -26,52 +25,7 @@ else
  esac
fi

if [[ "$KVM" == [Nn]* ]]; then
  warn "KVM acceleration is disabled, this will cause the machine to run about 10 times slower!"
else
  if [[ "${ARCH,,}" != "amd64" ]]; then
    KVM="N"
    warn "your CPU architecture is ${ARCH^^} and cannot provide KVM acceleration for x64 instructions, so the machine will run about 10 times slower."
  fi
fi

if [[ "$KVM" != [Nn]* ]]; then

  KVM_ERR=""

  if [ ! -e /dev/kvm ]; then
    KVM_ERR="(/dev/kvm is missing)"
  else
    if ! sh -c 'echo -n > /dev/kvm' &> /dev/null; then
      KVM_ERR="(/dev/kvm is unwriteable)"
    else
flags=$(sed -ne '/^flags/s/^.*: //p' /proc/cpuinfo)
      if ! grep -qw "vmx\|svm" <<< "$flags"; then
        KVM_ERR="(not enabled in BIOS)"
      fi
    fi
  fi

  if [ -n "$KVM_ERR" ]; then
    KVM="N"
    if [[ "$OSTYPE" =~ ^darwin ]]; then
      warn "you are using macOS which has no KVM support, so the machine will run about 10 times slower."
    else
      kernel=$(uname -a)
      case "${kernel,,}" in
        *"microsoft"* )
          error "Please bind '/dev/kvm' as a volume in the optional container settings when using Docker Desktop." ;;
        *"synology"* )
          error "Please make sure that Synology VMM (Virtual Machine Manager) is installed and that '/dev/kvm' is binded to this container." ;;
        *)
          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)." ;;
      esac
      [[ "$DEBUG" != [Yy1]* ]] && exit 88
    fi
  fi

fi

if [[ "$KVM" != [Nn]* ]]; then

Loading