diff --git a/12345.sh b/12345.sh index 949608db..a9b27d3f 100755 --- a/12345.sh +++ b/12345.sh @@ -97,7 +97,7 @@ while true; do ############### ############### ############### ############### templates/index.http # REPLACE myHOST in http response template (fixing next API meeting point) echo "$HTTPCORS" > ~/.zen/tmp/coucou/${MOATS}.myHOST.http - template_register >> ~/.zen/tmp/coucou/${MOATS}.myHOST.http + myTmpl >> ~/.zen/tmp/coucou/${MOATS}.myHOST.http sed -i -e "s~\"${myIPFS}/\"~\"$(myIpfs)\"~g" \ -e "s~http://${myHOST}:12345~http://${myHOST}:${PORT}~g" \ ~/.zen/tmp/coucou/${MOATS}.myHOST.http diff --git a/specs/astroport_spec.sh b/specs/astroport_spec.sh index 442beacf..df1bef52 100644 --- a/specs/astroport_spec.sh +++ b/specs/astroport_spec.sh @@ -1,5 +1,4 @@ #shellcheck shell=sh -set -eu Describe 'Dependency' Describe 'ipfs:' @@ -13,25 +12,21 @@ Describe 'Dependency' End Describe 'Astroport' - Describe 'tools/myhost.sh' - Include ./tools/myhost.sh - myhost() { - echo $myHOST - echo $myIPFS - } + Describe 'tools/my.sh' + Include ./tools/my.sh It 'does my env variables' + myhost() { + echo $myHOST + echo $myIPFS + } When call myhost The output should include astroport. The output should include ipfs. The status should be success The stderr should equal "" End - End - Describe 'tools/template.sh' - Include ./tools/myhost.sh - Include ./tools/template.sh It 'does host html register page' - When call template_register + When call myTmpl The stdout should include $(hostname) The stdout should include $IPFSNODEID The stdout should include $myASTROPORT @@ -40,7 +35,8 @@ Describe 'Astroport' The stderr should equal "" End It 'does localhost html register page' - When call template_register_localhost + isLAN=true + When call myTmpl The stdout should include "input name='salt' value=''" The stdout should include "input name='pepper' value=''" The status should be success diff --git a/tools/my.sh b/tools/my.sh index 775fa8c2..c171e0cc 100755 --- a/tools/my.sh +++ b/tools/my.sh @@ -1,4 +1,4 @@ -#shellcheck shell=sh +#shellcheck shell=sh disable=SC2034 ipfsNodeId() { ipfsNodeId=$(jq -r .Identity.PeerID ~/.ipfs/config) @@ -7,8 +7,9 @@ ipfsNodeId() { isLan() { isLan=$(ip route |awk '$1 == "default" {print $3}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/" \ - || route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") - [ -n "$isLan" ] && echo "$isLan" + || route -n |awk '$1 == "0.0.0.0" {print $2}' | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/" \ + || true) + [ -n "$isLan" ] && echo "$isLan" ||: } 2>/dev/null myDomainName() { @@ -27,13 +28,11 @@ myHash() { myHttp() { [ -n "$(myHttpHeader)" ] \ - && myHttp="$(myHttpHeader)" \ - && myHttp+=" + && myHttp="$(myHttpHeader) -" \ - || myHttp="" +" || myHttp="" [ -n "$(myHttpContent)" ] \ - && myHttp+="$(myHttpContent)" + && myHttp="${myHttp}$(myHttpContent)" [ -n "$myHttp" ] \ && echo "$myHttp" } @@ -41,7 +40,7 @@ myHttp() { myHttpContent() { [ -n "$(myHash)" ] \ && myHttpContent="
The document is here in IPFS.
" \ +The document is here in IPFS.