function myhost

This commit is contained in:
fred 2022-12-25 15:39:47 +01:00
parent d1e590b787
commit 514cdeed2b
2 changed files with 18 additions and 3 deletions

View File

@ -13,7 +13,22 @@ Describe 'Dependency'
End
Describe 'Astroport'
Describe 'template_register'
Describe 'tools/myhost.sh'
Include ./tools/myhost.sh
myhost() {
echo $myHOST
echo $myIPFS
}
It 'hydrates host env variables'
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 'creates host html register page'
When call template_register

View File

@ -9,7 +9,7 @@ IPFSNODEID=$(jq -r .Identity.PeerID ~/.ipfs/config)
myIP=$(hostname -I | awk '{print $1}' | head -n 1)
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])/")
myDOMAINName=$(hostname -d 2>/dev/null) && [ -z "$myDOMAINName" ] && myDOMAINName=$(domainname 2>/dev/null) && [[ "$myDOMAINName" == "(none)" ]] && myDOMAINName="localhost"
myDOMAINName=$(hostname -d 2>/dev/null) && [ -z "$myDOMAINName" ] && myDOMAINName=$(domainname 2>/dev/null) && [ "$myDOMAINName" = "(none)" ] && myDOMAINName="localhost"
myHOSTName=$(hostname |sed 's/\.'${myDOMAINName}'$//')
[ -n "$myDOMAINName" ] && myHOSTName="${myHOSTName}.${myDOMAINName}" || myDOMAINName=${myHOSTName#*.}
[ -z "$myDOMAINName" ] && myDOMAINName=localhost
@ -17,4 +17,4 @@ myHOST="astroport.${myDOMAINName}"
myIPFS="http://ipfs.${myDOMAINName}:8080"
myASTROPORT="http://astroport.${myDOMAINName}:1234"
[[ ! $isLAN || $USER == "zen" ]] && myIPFS="https://ipfs.${myDOMAINName}" && myASTROPORT="https://astroport.${myDOMAINName}" ## WAN STATION
[ -z "$isLAN" ] && myIPFS="https://ipfs.${myDOMAINName}" && myASTROPORT="https://astroport.${myDOMAINName}" ||: ## WAN STATION