Loading .github/workflows/check.yml +1 −1 Original line number Diff line number Diff line Loading @@ -11,4 +11,4 @@ jobs: - name: Run ShellCheck uses: ludeeus/action-shellcheck@master env: SHELLCHECK_OPTS: -x -e SC2001 -e SC2002 -e SC2223 -e SC2034 -e SC2064 -e SC2317 SHELLCHECK_OPTS: -x -e SC2001 -e SC2002 -e SC2223 -e SC2034 -e SC2064 -e SC2317 -e SC2028 Dockerfile +2 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,8 @@ RUN apt-get update && apt-get -y upgrade && \ net-tools \ btrfs-progs \ ca-certificates \ netcat-openbsd \ qemu-system-x86 \ netcat-traditional \ && apt-get clean COPY run/*.sh /run/ Loading Loading @@ -65,6 +65,6 @@ LABEL org.opencontainers.image.version=${VERSION_ARG} LABEL org.opencontainers.image.source=https://github.com/kroese/virtual-dsm/ LABEL org.opencontainers.image.url=https://hub.docker.com/r/kroese/virtual-dsm/ HEALTHCHECK --interval=30s --retries=3 CMD /run/check.sh HEALTHCHECK --interval=30s --retries=2 CMD /run/check.sh ENTRYPOINT ["/run/run.sh"] run/check.sh +39 −8 Original line number Diff line number Diff line #!/usr/bin/env bash set -u # Docker Healthcheck # Retrieve guest info for Docker healthcheck RESPONSE=$(curl -s -m 6 -S http://127.0.0.1:2210/read?command=10 2>&1) : ${DHCP:='N'} if [[ ! "${RESPONSE}" =~ "\"success\"" ]] ; then echo "Failed to connect to guest: $RESPONSE" exit 1 fi # Retrieve the HTTP port number if [[ ! "${RESPONSE}" =~ "\"http_port\"" ]] ; then echo "Failed to parse response from guest: $RESPONSE" exit 1 fi rest=${RESPONSE#*http_port} rest=${rest#*:} rest=${rest%%,*} PORT=${rest%%\"*} if [ -z "${PORT}" ]; then echo "Guest has not set a portnumber yet.." exit 1 fi # Retrieve the IP address if [[ ! "${RESPONSE}" =~ "eth0" ]] ; then echo "Failed to parse response from guest: $RESPONSE" exit 1 fi if [[ "${DHCP}" == [Yy1]* ]]; then PORT=5555 IP="127.0.0.1" else PORT=5000 IP="20.20.20.21" rest=${RESPONSE#*eth0} rest=${rest#*ip} rest=${rest#*:} rest=${rest#*\"} IP=${rest%%\"*} if [ -z "${IP}" ]; then echo "Guest has not received an IP yet.." exit 1 fi if ! curl -m 3 -ILfSs "http://${IP}:${PORT}/" > /dev/null; then Loading run/install.sh +4 −3 Original line number Diff line number Diff line Loading @@ -5,9 +5,10 @@ set -Eeuo pipefail HTML="Please wait while Virtual DSM is installing...<script>\ setTimeout(() => { document.location.reload(); }, 9999);</script>" pkill -f server.sh || true /run/server.sh 80 "${HTML}" > /dev/null & /run/server.sh 5000 "${HTML}" > /dev/null & { pkill -f server.sh || true; } 2>/dev/null /run/server.sh 80 "${HTML}" & /run/server.sh 5000 "${HTML}" & # Download the required files from the Synology website DL="https://global.synologydownload.com/download/DSM" Loading run/network.sh +21 −20 Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ configureDHCP() { { ip link add link "${VM_NET_DEV}" "${VM_NET_VLAN}" type macvlan mode bridge ; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: Cannot create macvlan interface. Please make sure the network type is 'macvlan' and not 'ipvlan'." echo " And that the NET_ADMIN capability has been added to the container config: --cap-add NET_ADMIN" && exit 15 echo "ERROR: Cannot create macvlan interface. Please make sure the network type is 'macvlan' and not 'ipvlan'," echo "ERROR: and that the NET_ADMIN capability has been added to the container config: --cap-add NET_ADMIN" && exit 15 fi ip address add "${IP}" dev "${VM_NET_VLAN}" Loading Loading @@ -226,14 +226,26 @@ if [[ "${DHCP}" == [Yy1]* ]]; then # Configuration for DHCP IP configureDHCP # Display the received IP on port 5000 HTML="DSM is using another IP address.<br><br>Check the Docker logfile to see which one was<br> assigned, or download the\ <a href='https://global.synologydownload.com/download/Utility/Assistant/7.0.4-50051/Windows/synology-assistant-7.0.4-50051.exe'>\ Synology Assistant</a> utility." { pkill -f server.sh || true; } 2>/dev/null pkill -f server.sh || true /run/server.sh 80 "${HTML}" > /dev/null & /run/server.sh 5000 "${HTML}" > /dev/null & SH_SCRIPT="/run/ipinfo.sh" { echo "#!/bin/bash" echo "INFO=\$(curl -s -m 5 -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 "BODY=\"The location of DSM is <a href=\"http://\${IP}:\${PORT}\">http://\${IP}:\${PORT}</a><script>\\" echo "setTimeout(function(){ window.location.assign('http://\${IP}:\${PORT}'); }, 3000);</script>\"" echo "HTML=\"<!DOCTYPE html><HTML><HEAD><TITLE>VirtualDSM</TITLE><STYLE>body { color: white; background-color: #125bdb; font-family: Verdana,\\" echo "Arial,sans-serif; } a, a:hover, a:active, a:visited { color: white; }</STYLE></HEAD><BODY><BR><BR><H1><CENTER>\$BODY</CENTER></H1></BODY></HTML>\"" echo "LENGTH=\"\${#HTML}\"; RESPONSE=\"HTTP/1.1 200 OK\\nContent-Length: \${LENGTH}\\nConnection: close\\n\\n\$HTML\\n\\n\"" echo "echo -e \"\$RESPONSE\"" } > "$SH_SCRIPT" chmod +x "$SH_SCRIPT" /run/server.sh 80 "$SH_SCRIPT" & /run/server.sh 5000 "$SH_SCRIPT" & else Loading @@ -244,17 +256,6 @@ fi NET_OPTS="${NET_OPTS} -device virtio-net-pci,romfile=,netdev=hostnet0,mac=${VM_NET_MAC},id=net0" if [[ "${DHCP}" == [Yy1]* ]]; then # Add extra LAN interface for Docker Healthcheck script : ${MAC2:='02:11:32:CC:BB:AA'} 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,mac=${MAC2},id=net1" fi [[ "${DEBUG}" == [Yy1]* ]] && echo && echo "Finished network setup.." && echo return 0 Loading
.github/workflows/check.yml +1 −1 Original line number Diff line number Diff line Loading @@ -11,4 +11,4 @@ jobs: - name: Run ShellCheck uses: ludeeus/action-shellcheck@master env: SHELLCHECK_OPTS: -x -e SC2001 -e SC2002 -e SC2223 -e SC2034 -e SC2064 -e SC2317 SHELLCHECK_OPTS: -x -e SC2001 -e SC2002 -e SC2223 -e SC2034 -e SC2064 -e SC2317 -e SC2028
Dockerfile +2 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,8 @@ RUN apt-get update && apt-get -y upgrade && \ net-tools \ btrfs-progs \ ca-certificates \ netcat-openbsd \ qemu-system-x86 \ netcat-traditional \ && apt-get clean COPY run/*.sh /run/ Loading Loading @@ -65,6 +65,6 @@ LABEL org.opencontainers.image.version=${VERSION_ARG} LABEL org.opencontainers.image.source=https://github.com/kroese/virtual-dsm/ LABEL org.opencontainers.image.url=https://hub.docker.com/r/kroese/virtual-dsm/ HEALTHCHECK --interval=30s --retries=3 CMD /run/check.sh HEALTHCHECK --interval=30s --retries=2 CMD /run/check.sh ENTRYPOINT ["/run/run.sh"]
run/check.sh +39 −8 Original line number Diff line number Diff line #!/usr/bin/env bash set -u # Docker Healthcheck # Retrieve guest info for Docker healthcheck RESPONSE=$(curl -s -m 6 -S http://127.0.0.1:2210/read?command=10 2>&1) : ${DHCP:='N'} if [[ ! "${RESPONSE}" =~ "\"success\"" ]] ; then echo "Failed to connect to guest: $RESPONSE" exit 1 fi # Retrieve the HTTP port number if [[ ! "${RESPONSE}" =~ "\"http_port\"" ]] ; then echo "Failed to parse response from guest: $RESPONSE" exit 1 fi rest=${RESPONSE#*http_port} rest=${rest#*:} rest=${rest%%,*} PORT=${rest%%\"*} if [ -z "${PORT}" ]; then echo "Guest has not set a portnumber yet.." exit 1 fi # Retrieve the IP address if [[ ! "${RESPONSE}" =~ "eth0" ]] ; then echo "Failed to parse response from guest: $RESPONSE" exit 1 fi if [[ "${DHCP}" == [Yy1]* ]]; then PORT=5555 IP="127.0.0.1" else PORT=5000 IP="20.20.20.21" rest=${RESPONSE#*eth0} rest=${rest#*ip} rest=${rest#*:} rest=${rest#*\"} IP=${rest%%\"*} if [ -z "${IP}" ]; then echo "Guest has not received an IP yet.." exit 1 fi if ! curl -m 3 -ILfSs "http://${IP}:${PORT}/" > /dev/null; then Loading
run/install.sh +4 −3 Original line number Diff line number Diff line Loading @@ -5,9 +5,10 @@ set -Eeuo pipefail HTML="Please wait while Virtual DSM is installing...<script>\ setTimeout(() => { document.location.reload(); }, 9999);</script>" pkill -f server.sh || true /run/server.sh 80 "${HTML}" > /dev/null & /run/server.sh 5000 "${HTML}" > /dev/null & { pkill -f server.sh || true; } 2>/dev/null /run/server.sh 80 "${HTML}" & /run/server.sh 5000 "${HTML}" & # Download the required files from the Synology website DL="https://global.synologydownload.com/download/DSM" Loading
run/network.sh +21 −20 Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ configureDHCP() { { ip link add link "${VM_NET_DEV}" "${VM_NET_VLAN}" type macvlan mode bridge ; rc=$?; } || : if (( rc != 0 )); then echo -n "ERROR: Cannot create macvlan interface. Please make sure the network type is 'macvlan' and not 'ipvlan'." echo " And that the NET_ADMIN capability has been added to the container config: --cap-add NET_ADMIN" && exit 15 echo "ERROR: Cannot create macvlan interface. Please make sure the network type is 'macvlan' and not 'ipvlan'," echo "ERROR: and that the NET_ADMIN capability has been added to the container config: --cap-add NET_ADMIN" && exit 15 fi ip address add "${IP}" dev "${VM_NET_VLAN}" Loading Loading @@ -226,14 +226,26 @@ if [[ "${DHCP}" == [Yy1]* ]]; then # Configuration for DHCP IP configureDHCP # Display the received IP on port 5000 HTML="DSM is using another IP address.<br><br>Check the Docker logfile to see which one was<br> assigned, or download the\ <a href='https://global.synologydownload.com/download/Utility/Assistant/7.0.4-50051/Windows/synology-assistant-7.0.4-50051.exe'>\ Synology Assistant</a> utility." { pkill -f server.sh || true; } 2>/dev/null pkill -f server.sh || true /run/server.sh 80 "${HTML}" > /dev/null & /run/server.sh 5000 "${HTML}" > /dev/null & SH_SCRIPT="/run/ipinfo.sh" { echo "#!/bin/bash" echo "INFO=\$(curl -s -m 5 -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 "BODY=\"The location of DSM is <a href=\"http://\${IP}:\${PORT}\">http://\${IP}:\${PORT}</a><script>\\" echo "setTimeout(function(){ window.location.assign('http://\${IP}:\${PORT}'); }, 3000);</script>\"" echo "HTML=\"<!DOCTYPE html><HTML><HEAD><TITLE>VirtualDSM</TITLE><STYLE>body { color: white; background-color: #125bdb; font-family: Verdana,\\" echo "Arial,sans-serif; } a, a:hover, a:active, a:visited { color: white; }</STYLE></HEAD><BODY><BR><BR><H1><CENTER>\$BODY</CENTER></H1></BODY></HTML>\"" echo "LENGTH=\"\${#HTML}\"; RESPONSE=\"HTTP/1.1 200 OK\\nContent-Length: \${LENGTH}\\nConnection: close\\n\\n\$HTML\\n\\n\"" echo "echo -e \"\$RESPONSE\"" } > "$SH_SCRIPT" chmod +x "$SH_SCRIPT" /run/server.sh 80 "$SH_SCRIPT" & /run/server.sh 5000 "$SH_SCRIPT" & else Loading @@ -244,17 +256,6 @@ fi NET_OPTS="${NET_OPTS} -device virtio-net-pci,romfile=,netdev=hostnet0,mac=${VM_NET_MAC},id=net0" if [[ "${DHCP}" == [Yy1]* ]]; then # Add extra LAN interface for Docker Healthcheck script : ${MAC2:='02:11:32:CC:BB:AA'} 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,mac=${MAC2},id=net1" fi [[ "${DEBUG}" == [Yy1]* ]] && echo && echo "Finished network setup.." && echo return 0