Loading src/check.sh +4 −45 Original line number Diff line number Diff line #!/usr/bin/env bash set -Eeuo pipefail file="/run/dsm.url" active="/run/qemu.pid" shutdown="/run/qemu.count" url="http://127.0.0.1:2210/read?command=10" active_msg="QEMU not running yet.." shutdown_msg="QEMU is shutting down.." resp_err="Guest returned an invalid response:" jq_err="Failed to parse response from guest: jq error" [ ! -f "$active" ] && echo "$active_msg" && exit 0 [ -f "$shutdown" ] && echo "$shutdown_msg" && exit 1 if [ ! -f "$file" ]; then [ ! -f "/run/qemu.pid" ] && echo "QEMU not running yet.." && exit 0 [ -f "/run/qemu.count" ] && echo "QEMU is shutting down.." && exit 1 # Retrieve IP from guest VM for Docker healthcheck { json=$(curl -m 20 -sk "$url"); rc=$?; } || : [ -f "$shutdown" ] && echo "$shutdown_msg" && exit 1 (( rc != 0 )) && echo "Failed to connect to guest: curl error $rc" && exit 1 { result=$(echo "$json" | jq -r '.status'); rc=$?; } || : (( rc != 0 )) && echo "$jq_err $rc ( $json )" && exit 1 [[ "$result" == "null" ]] && echo "$resp_err $json" && exit 1 if [[ "$result" != "success" ]] ; then { msg=$(echo "$json" | jq -r '.message'); rc=$?; } || : echo "Guest replied $result: $msg" && exit 1 fi { port=$(echo "$json" | jq -r '.data.data.dsm_setting.data.http_port'); rc=$?; } || : (( rc != 0 )) && echo "$jq_err $rc ( $json )" && exit 1 [[ "$port" == "null" ]] && echo "$resp_err $json" && exit 1 [ -z "$port" ] && echo "Guest has not set a portnumber yet.." && exit 1 { ip=$(echo "$json" | jq -r '.data.data.ip.data[] | select((.name=="eth0") and has("ip")).ip'); rc=$?; } || : (( rc != 0 )) && echo "$jq_err $rc ( $json )" && exit 1 [[ "$ip" == "null" ]] && echo "$resp_err $json" && exit 1 [ -z "$ip" ] && echo "Guest has not received an IP yet.." && exit 1 echo "$ip:$port" > $file fi [ -f "$shutdown" ] && echo "$shutdown_msg" && exit 1 file="/run/dsm.url" [ ! -f "$file" ] && echo "DSM has not enabled networking yet.." && exit 1 location=$(cat "$file") if ! curl -m 20 -ILfSs "http://$location/" > /dev/null; then [ -f "$shutdown" ] && echo "$shutdown_msg" && exit 1 echo "Failed to reach page at http://$location" && exit 1 fi Loading src/install.sh +3 −2 Original line number Diff line number Diff line Loading @@ -141,12 +141,13 @@ if [ -f "$RDC" ]; then if [[ "$DEV" == [Nn]* ]]; then # Exclude dev/ from cpio extract { (cd "$TMP" && cpio -it < "$TMP/rd" | grep -Ev 'dev/' | while read -r entry; do cpio -idm "$entry" < "$TMP/rd" 2>/dev/null; done); rc=$?; } || : (( rc != 0 )) && error "Failed to extract $RDC, reason $rc" && exit 92 else { (cd "$TMP" && cpio -idm <"$TMP/rd" 2>/dev/null); rc=$?; } || : (( rc != 0 )) && error "Failed to extract $RDC, reason $rc" (( rc != 0 )) && error "If the container runs unprivileged, please set DEV=N to exclude device nodes." && exit 92 fi (( rc != 0 )) && error "Failed to extract $RDC, reason $rc" && exit 92 mkdir -p /run/extract for file in $TMP/usr/lib/libcurl.so.4 \ $TMP/usr/lib/libmbedcrypto.so.5 \ Loading Loading
src/check.sh +4 −45 Original line number Diff line number Diff line #!/usr/bin/env bash set -Eeuo pipefail file="/run/dsm.url" active="/run/qemu.pid" shutdown="/run/qemu.count" url="http://127.0.0.1:2210/read?command=10" active_msg="QEMU not running yet.." shutdown_msg="QEMU is shutting down.." resp_err="Guest returned an invalid response:" jq_err="Failed to parse response from guest: jq error" [ ! -f "$active" ] && echo "$active_msg" && exit 0 [ -f "$shutdown" ] && echo "$shutdown_msg" && exit 1 if [ ! -f "$file" ]; then [ ! -f "/run/qemu.pid" ] && echo "QEMU not running yet.." && exit 0 [ -f "/run/qemu.count" ] && echo "QEMU is shutting down.." && exit 1 # Retrieve IP from guest VM for Docker healthcheck { json=$(curl -m 20 -sk "$url"); rc=$?; } || : [ -f "$shutdown" ] && echo "$shutdown_msg" && exit 1 (( rc != 0 )) && echo "Failed to connect to guest: curl error $rc" && exit 1 { result=$(echo "$json" | jq -r '.status'); rc=$?; } || : (( rc != 0 )) && echo "$jq_err $rc ( $json )" && exit 1 [[ "$result" == "null" ]] && echo "$resp_err $json" && exit 1 if [[ "$result" != "success" ]] ; then { msg=$(echo "$json" | jq -r '.message'); rc=$?; } || : echo "Guest replied $result: $msg" && exit 1 fi { port=$(echo "$json" | jq -r '.data.data.dsm_setting.data.http_port'); rc=$?; } || : (( rc != 0 )) && echo "$jq_err $rc ( $json )" && exit 1 [[ "$port" == "null" ]] && echo "$resp_err $json" && exit 1 [ -z "$port" ] && echo "Guest has not set a portnumber yet.." && exit 1 { ip=$(echo "$json" | jq -r '.data.data.ip.data[] | select((.name=="eth0") and has("ip")).ip'); rc=$?; } || : (( rc != 0 )) && echo "$jq_err $rc ( $json )" && exit 1 [[ "$ip" == "null" ]] && echo "$resp_err $json" && exit 1 [ -z "$ip" ] && echo "Guest has not received an IP yet.." && exit 1 echo "$ip:$port" > $file fi [ -f "$shutdown" ] && echo "$shutdown_msg" && exit 1 file="/run/dsm.url" [ ! -f "$file" ] && echo "DSM has not enabled networking yet.." && exit 1 location=$(cat "$file") if ! curl -m 20 -ILfSs "http://$location/" > /dev/null; then [ -f "$shutdown" ] && echo "$shutdown_msg" && exit 1 echo "Failed to reach page at http://$location" && exit 1 fi Loading
src/install.sh +3 −2 Original line number Diff line number Diff line Loading @@ -141,12 +141,13 @@ if [ -f "$RDC" ]; then if [[ "$DEV" == [Nn]* ]]; then # Exclude dev/ from cpio extract { (cd "$TMP" && cpio -it < "$TMP/rd" | grep -Ev 'dev/' | while read -r entry; do cpio -idm "$entry" < "$TMP/rd" 2>/dev/null; done); rc=$?; } || : (( rc != 0 )) && error "Failed to extract $RDC, reason $rc" && exit 92 else { (cd "$TMP" && cpio -idm <"$TMP/rd" 2>/dev/null); rc=$?; } || : (( rc != 0 )) && error "Failed to extract $RDC, reason $rc" (( rc != 0 )) && error "If the container runs unprivileged, please set DEV=N to exclude device nodes." && exit 92 fi (( rc != 0 )) && error "Failed to extract $RDC, reason $rc" && exit 92 mkdir -p /run/extract for file in $TMP/usr/lib/libcurl.so.4 \ $TMP/usr/lib/libmbedcrypto.so.5 \ Loading