Loading run/check.sh +2 −2 Original line number Diff line number Diff line #!/usr/bin/env bash set -u # Retrieve guest info for Docker healthcheck # Retrieve IP from guest for Docker healthcheck RESPONSE=$(curl -s -m 6 -S http://127.0.0.1:2210/read?command=10 2>&1) if [[ ! "${RESPONSE}" =~ "\"success\"" ]] ; then Loading Loading @@ -49,5 +49,5 @@ if ! curl -m 3 -ILfSs "http://${IP}:${PORT}/" > /dev/null; then exit 1 fi echo "Healthcheck OK" echo "Healthcheck OK ($IP)" exit 0 run/network.sh +9 −10 Original line number Diff line number Diff line Loading @@ -47,8 +47,8 @@ configureDHCP() { { ip link add link "${VM_NET_DEV}" name "${VM_NET_TAP}" address "${VM_NET_MAC}" type macvtap mode bridge ; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: Capability NET_ADMIN has not been set most likely. Please add the " echo "following docker setting to your container: --cap-add NET_ADMIN" && exit 16 echo "ERROR: Capability NET_ADMIN has not been set most likely. Please add the " echo "ERROR: following docker setting to your container: --cap-add NET_ADMIN" && exit 16 fi ip link set "${VM_NET_TAP}" up Loading Loading @@ -78,15 +78,15 @@ configureDHCP() { { exec 30>>"$TAP_PATH"; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: Cannot create TAP interface ($rc). Please add the following docker settings to your " echo "container: --device-cgroup-rule='c ${MAJOR}:* rwm' --device=/dev/vhost-net" && exit 21 echo "ERROR: Cannot create TAP interface ($rc). Please add the following docker settings to your " echo "ERROR: container: --device-cgroup-rule='c ${MAJOR}:* rwm' --device=/dev/vhost-net" && exit 21 fi { exec 40>>/dev/vhost-net; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: VHOST can not be found ($rc). Please add the following " echo "docker setting to your container: --device=/dev/vhost-net" && exit 22 echo "ERROR: VHOST can not be found ($rc). Please add the following " echo "ERROR: docker setting to your container: --device=/dev/vhost-net" && exit 22 fi NET_OPTS="-netdev tap,id=hostnet0,vhost=on,vhostfd=40,fd=30" Loading @@ -102,8 +102,8 @@ configureNAT () { { ip link add dev dockerbridge type bridge ; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: Capability NET_ADMIN has not been set most likely. Please add the " echo "following docker setting to your container: --cap-add NET_ADMIN" && exit 23 echo "ERROR: Capability NET_ADMIN has not been set most likely. Please add the " echo "ERROR: following docker setting to your container: --cap-add NET_ADMIN" && exit 23 fi ip address add ${VM_NET_IP%.*}.1/24 broadcast ${VM_NET_IP%.*}.255 dev dockerbridge Loading Loading @@ -131,8 +131,7 @@ configureNAT () { if [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then { sysctl -w net.ipv4.ip_forward=1 ; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: IP forwarding is disabled ($rc). Please add the following " echo "docker setting to your container: --sysctl net.ipv4.ip_forward=1" && exit 24 echo "ERROR: Please add the following docker setting to your container: --sysctl net.ipv4.ip_forward=1" && exit 24 fi fi Loading run/server.sh +7 −5 Original line number Diff line number Diff line Loading @@ -14,8 +14,8 @@ trap 'stop' EXIT SIGINT SIGTERM SIGHUP html() { local h="<!DOCTYPE html><HTML><HEAD><TITLE>VirtualDSM</TITLE>" h="${h} <STYLE>body { color: white; background-color: #125bdb; font-family: Verdana,Arial,sans-serif; }" h="${h} a, a:hover, a:active, a:visited { color: white; }</STYLE></HEAD>" h="${h} <STYLE>body { color: white; background-color: #125bdb; font-family: Verdana," h="${h} Arial,sans-serif; } a, a:hover, a:active, a:visited { color: white; }</STYLE></HEAD>" h="${h}<BODY><BR><BR><H1><CENTER>$1</CENTER></H1></BODY></HTML>" echo "$h" Loading @@ -26,7 +26,8 @@ if [[ "$2" != "/"* ]]; then BODY="$2" if [[ "$BODY" == "install" ]]; then BODY="Please wait while Virtual DSM is installing...<script>setTimeout(() => { document.location.reload(); }, 9999);</script>" BODY="Please wait while Virtual DSM is being installed..." BODY="$BODY<script>setTimeout(() => { document.location.reload(); }, 9999);</script>" fi HTML=$(html "$BODY") Loading @@ -44,14 +45,15 @@ else BODY="The location of DSM is <a href='http://\${IP}:\${PORT}'>http://\${IP}:\${PORT}</a><script>" BODY="${BODY}setTimeout(function(){ window.location.assign('http://\${IP}:\${PORT}'); }, 3000);</script>" WAIT="Please wait while discovering IP...<script>setTimeout(() => { document.location.reload(); }, 4999);</script>" HTML=$(html "xxx") { echo "#!/bin/bash" echo "INFO=\$(curl -s -m 5 -S http://127.0.0.1:2210/read?command=10 2>/dev/null)" echo "INFO=\$(curl -s -m 2 -S http://127.0.0.1:2210/read?command=10 2>/dev/null)" echo "rest=\${INFO#*http_port}; rest=\${rest#*:}; rest=\${rest%%,*}; PORT=\${rest%%\\\"*}" echo "rest=\${INFO#*eth0}; rest=\${rest#*ip}; rest=\${rest#*:}; rest=\${rest#*\\\"}; IP=\${rest%%\\\"*}" echo "HTML=\"$HTML\"; BODY=\"$BODY\"; HTML=\${HTML/xxx/\$BODY}" echo "HTML=\"$HTML\"; [ -z \"\${IP}\" ] && BODY=\"$WAIT\" || BODY=\"$BODY\"; HTML=\${HTML/xxx/\$BODY}" echo "printf '%b' \"HTTP/1.1 200 OK\\nContent-Length: \${#HTML}\\nConnection: close\\n\\n\$HTML\"" } > "$TMP_FILE" Loading Loading
run/check.sh +2 −2 Original line number Diff line number Diff line #!/usr/bin/env bash set -u # Retrieve guest info for Docker healthcheck # Retrieve IP from guest for Docker healthcheck RESPONSE=$(curl -s -m 6 -S http://127.0.0.1:2210/read?command=10 2>&1) if [[ ! "${RESPONSE}" =~ "\"success\"" ]] ; then Loading Loading @@ -49,5 +49,5 @@ if ! curl -m 3 -ILfSs "http://${IP}:${PORT}/" > /dev/null; then exit 1 fi echo "Healthcheck OK" echo "Healthcheck OK ($IP)" exit 0
run/network.sh +9 −10 Original line number Diff line number Diff line Loading @@ -47,8 +47,8 @@ configureDHCP() { { ip link add link "${VM_NET_DEV}" name "${VM_NET_TAP}" address "${VM_NET_MAC}" type macvtap mode bridge ; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: Capability NET_ADMIN has not been set most likely. Please add the " echo "following docker setting to your container: --cap-add NET_ADMIN" && exit 16 echo "ERROR: Capability NET_ADMIN has not been set most likely. Please add the " echo "ERROR: following docker setting to your container: --cap-add NET_ADMIN" && exit 16 fi ip link set "${VM_NET_TAP}" up Loading Loading @@ -78,15 +78,15 @@ configureDHCP() { { exec 30>>"$TAP_PATH"; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: Cannot create TAP interface ($rc). Please add the following docker settings to your " echo "container: --device-cgroup-rule='c ${MAJOR}:* rwm' --device=/dev/vhost-net" && exit 21 echo "ERROR: Cannot create TAP interface ($rc). Please add the following docker settings to your " echo "ERROR: container: --device-cgroup-rule='c ${MAJOR}:* rwm' --device=/dev/vhost-net" && exit 21 fi { exec 40>>/dev/vhost-net; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: VHOST can not be found ($rc). Please add the following " echo "docker setting to your container: --device=/dev/vhost-net" && exit 22 echo "ERROR: VHOST can not be found ($rc). Please add the following " echo "ERROR: docker setting to your container: --device=/dev/vhost-net" && exit 22 fi NET_OPTS="-netdev tap,id=hostnet0,vhost=on,vhostfd=40,fd=30" Loading @@ -102,8 +102,8 @@ configureNAT () { { ip link add dev dockerbridge type bridge ; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: Capability NET_ADMIN has not been set most likely. Please add the " echo "following docker setting to your container: --cap-add NET_ADMIN" && exit 23 echo "ERROR: Capability NET_ADMIN has not been set most likely. Please add the " echo "ERROR: following docker setting to your container: --cap-add NET_ADMIN" && exit 23 fi ip address add ${VM_NET_IP%.*}.1/24 broadcast ${VM_NET_IP%.*}.255 dev dockerbridge Loading Loading @@ -131,8 +131,7 @@ configureNAT () { if [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then { sysctl -w net.ipv4.ip_forward=1 ; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: IP forwarding is disabled ($rc). Please add the following " echo "docker setting to your container: --sysctl net.ipv4.ip_forward=1" && exit 24 echo "ERROR: Please add the following docker setting to your container: --sysctl net.ipv4.ip_forward=1" && exit 24 fi fi Loading
run/server.sh +7 −5 Original line number Diff line number Diff line Loading @@ -14,8 +14,8 @@ trap 'stop' EXIT SIGINT SIGTERM SIGHUP html() { local h="<!DOCTYPE html><HTML><HEAD><TITLE>VirtualDSM</TITLE>" h="${h} <STYLE>body { color: white; background-color: #125bdb; font-family: Verdana,Arial,sans-serif; }" h="${h} a, a:hover, a:active, a:visited { color: white; }</STYLE></HEAD>" h="${h} <STYLE>body { color: white; background-color: #125bdb; font-family: Verdana," h="${h} Arial,sans-serif; } a, a:hover, a:active, a:visited { color: white; }</STYLE></HEAD>" h="${h}<BODY><BR><BR><H1><CENTER>$1</CENTER></H1></BODY></HTML>" echo "$h" Loading @@ -26,7 +26,8 @@ if [[ "$2" != "/"* ]]; then BODY="$2" if [[ "$BODY" == "install" ]]; then BODY="Please wait while Virtual DSM is installing...<script>setTimeout(() => { document.location.reload(); }, 9999);</script>" BODY="Please wait while Virtual DSM is being installed..." BODY="$BODY<script>setTimeout(() => { document.location.reload(); }, 9999);</script>" fi HTML=$(html "$BODY") Loading @@ -44,14 +45,15 @@ else BODY="The location of DSM is <a href='http://\${IP}:\${PORT}'>http://\${IP}:\${PORT}</a><script>" BODY="${BODY}setTimeout(function(){ window.location.assign('http://\${IP}:\${PORT}'); }, 3000);</script>" WAIT="Please wait while discovering IP...<script>setTimeout(() => { document.location.reload(); }, 4999);</script>" HTML=$(html "xxx") { echo "#!/bin/bash" echo "INFO=\$(curl -s -m 5 -S http://127.0.0.1:2210/read?command=10 2>/dev/null)" echo "INFO=\$(curl -s -m 2 -S http://127.0.0.1:2210/read?command=10 2>/dev/null)" echo "rest=\${INFO#*http_port}; rest=\${rest#*:}; rest=\${rest%%,*}; PORT=\${rest%%\\\"*}" echo "rest=\${INFO#*eth0}; rest=\${rest#*ip}; rest=\${rest#*:}; rest=\${rest#*\\\"}; IP=\${rest%%\\\"*}" echo "HTML=\"$HTML\"; BODY=\"$BODY\"; HTML=\${HTML/xxx/\$BODY}" echo "HTML=\"$HTML\"; [ -z \"\${IP}\" ] && BODY=\"$WAIT\" || BODY=\"$BODY\"; HTML=\${HTML/xxx/\$BODY}" echo "printf '%b' \"HTTP/1.1 200 OK\\nContent-Length: \${#HTML}\\nConnection: close\\n\\n\$HTML\"" } > "$TMP_FILE" Loading