Loading src/check.sh +10 −7 Original line number Diff line number Diff line Loading @@ -4,9 +4,12 @@ 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.." url="http://127.0.0.1:2210/read?command=10" 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 Loading @@ -20,8 +23,8 @@ if [ ! -f "$file" ]; then (( rc != 0 )) && echo "Failed to connect to guest: curl error $rc" && exit 1 { result=$(echo "$json" | jq -r '.status'); rc=$?; } || : (( rc != 0 )) && echo "Failed to parse response from guest: jq error $rc ( $json )" && exit 1 [[ "$result" == "null" ]] && echo "Guest returned invalid response: $json" && exit 1 (( 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=$?; } || : Loading @@ -29,13 +32,13 @@ if [ ! -f "$file" ]; then fi { port=$(echo "$json" | jq -r '.data.data.dsm_setting.data.http_port'); rc=$?; } || : (( rc != 0 )) && echo "Failed to parse response from guest: jq error $rc ( $json )" && exit 1 [[ "$port" == "null" ]] && echo "Guest has not set a portnumber yet.." && exit 1 (( 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 "Failed to parse response from guest: jq error $rc ( $json )" && exit 1 [[ "$ip" == "null" ]] && echo "Guest returned invalid response: $json" && exit 1 (( 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 Loading src/install.sh +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ DL_GLOBAL="https://global.synologydownload.com/download/DSM" if [ -z "$DL" ]; then [ -z "$COUNTRY" ] && setCountry [ -z "$COUNTRY" ] && info "Warning: could not detect country to select mirror!" [[ "${COUNTRY^^}" == "CN" ]] && DL="$DL_CHINA" || DL="$DL_GLOBAL" fi Loading src/print.sh +8 −6 Original line number Diff line number Diff line Loading @@ -7,6 +7,8 @@ error () { printf "%b%s%b" "\E[1;31m❯ " "ERROR: $1" "\E[0m\n" >&2; } file="/run/dsm.url" shutdown="/run/qemu.count" url="http://127.0.0.1:2210/read?command=10" resp_err="Guest returned an invalid response:" jq_err="Failed to parse response from guest: jq error" while [ ! -f "$file" ] do Loading @@ -28,8 +30,8 @@ do (( rc != 0 )) && error "Failed to connect to guest: curl error $rc" && continue { result=$(echo "$json" | jq -r '.status'); rc=$?; } || : (( rc != 0 )) && error "Failed to parse response from guest: jq error $rc ( $json )" && continue [[ "$result" == "null" ]] && error "Guest returned invalid response: $json" && continue (( rc != 0 )) && error "$jq_err $rc ( $json )" && continue [[ "$result" == "null" ]] && error "$resp_err $json" && continue if [[ "$result" != "success" ]] ; then { msg=$(echo "$json" | jq -r '.message'); rc=$?; } || : Loading @@ -37,13 +39,13 @@ do fi { port=$(echo "$json" | jq -r '.data.data.dsm_setting.data.http_port'); rc=$?; } || : (( rc != 0 )) && error "Failed to parse response from guest: jq error $rc ( $json )" && continue [[ "$port" == "null" ]] && error "Guest returned invalid response: $json" && continue (( rc != 0 )) && error "$jq_err $rc ( $json )" && continue [[ "$port" == "null" ]] && error "$resp_err $json" && continue [ -z "$port" ] && continue { ip=$(echo "$json" | jq -r '.data.data.ip.data[] | select((.name=="eth0") and has("ip")).ip'); rc=$?; } || : (( rc != 0 )) && error "Failed to parse response from guest: jq error $rc ( $json )" && continue [[ "$ip" == "null" ]] && error "Guest returned invalid response: $json" && continue (( rc != 0 )) && error "$jq_err $rc ( $json )" && continue [[ "$ip" == "null" ]] && error "$resp_err $json" && continue [ -z "$ip" ] && continue echo "$ip:$port" > $file Loading Loading
src/check.sh +10 −7 Original line number Diff line number Diff line Loading @@ -4,9 +4,12 @@ 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.." url="http://127.0.0.1:2210/read?command=10" 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 Loading @@ -20,8 +23,8 @@ if [ ! -f "$file" ]; then (( rc != 0 )) && echo "Failed to connect to guest: curl error $rc" && exit 1 { result=$(echo "$json" | jq -r '.status'); rc=$?; } || : (( rc != 0 )) && echo "Failed to parse response from guest: jq error $rc ( $json )" && exit 1 [[ "$result" == "null" ]] && echo "Guest returned invalid response: $json" && exit 1 (( 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=$?; } || : Loading @@ -29,13 +32,13 @@ if [ ! -f "$file" ]; then fi { port=$(echo "$json" | jq -r '.data.data.dsm_setting.data.http_port'); rc=$?; } || : (( rc != 0 )) && echo "Failed to parse response from guest: jq error $rc ( $json )" && exit 1 [[ "$port" == "null" ]] && echo "Guest has not set a portnumber yet.." && exit 1 (( 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 "Failed to parse response from guest: jq error $rc ( $json )" && exit 1 [[ "$ip" == "null" ]] && echo "Guest returned invalid response: $json" && exit 1 (( 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 Loading
src/install.sh +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ DL_GLOBAL="https://global.synologydownload.com/download/DSM" if [ -z "$DL" ]; then [ -z "$COUNTRY" ] && setCountry [ -z "$COUNTRY" ] && info "Warning: could not detect country to select mirror!" [[ "${COUNTRY^^}" == "CN" ]] && DL="$DL_CHINA" || DL="$DL_GLOBAL" fi Loading
src/print.sh +8 −6 Original line number Diff line number Diff line Loading @@ -7,6 +7,8 @@ error () { printf "%b%s%b" "\E[1;31m❯ " "ERROR: $1" "\E[0m\n" >&2; } file="/run/dsm.url" shutdown="/run/qemu.count" url="http://127.0.0.1:2210/read?command=10" resp_err="Guest returned an invalid response:" jq_err="Failed to parse response from guest: jq error" while [ ! -f "$file" ] do Loading @@ -28,8 +30,8 @@ do (( rc != 0 )) && error "Failed to connect to guest: curl error $rc" && continue { result=$(echo "$json" | jq -r '.status'); rc=$?; } || : (( rc != 0 )) && error "Failed to parse response from guest: jq error $rc ( $json )" && continue [[ "$result" == "null" ]] && error "Guest returned invalid response: $json" && continue (( rc != 0 )) && error "$jq_err $rc ( $json )" && continue [[ "$result" == "null" ]] && error "$resp_err $json" && continue if [[ "$result" != "success" ]] ; then { msg=$(echo "$json" | jq -r '.message'); rc=$?; } || : Loading @@ -37,13 +39,13 @@ do fi { port=$(echo "$json" | jq -r '.data.data.dsm_setting.data.http_port'); rc=$?; } || : (( rc != 0 )) && error "Failed to parse response from guest: jq error $rc ( $json )" && continue [[ "$port" == "null" ]] && error "Guest returned invalid response: $json" && continue (( rc != 0 )) && error "$jq_err $rc ( $json )" && continue [[ "$port" == "null" ]] && error "$resp_err $json" && continue [ -z "$port" ] && continue { ip=$(echo "$json" | jq -r '.data.data.ip.data[] | select((.name=="eth0") and has("ip")).ip'); rc=$?; } || : (( rc != 0 )) && error "Failed to parse response from guest: jq error $rc ( $json )" && continue [[ "$ip" == "null" ]] && error "Guest returned invalid response: $json" && continue (( rc != 0 )) && error "$jq_err $rc ( $json )" && continue [[ "$ip" == "null" ]] && error "$resp_err $json" && continue [ -z "$ip" ] && continue echo "$ip:$port" > $file Loading