this is the head of a function register

This commit is contained in:
fred 2022-12-25 15:18:19 +01:00
parent 1d6849058b
commit d1e590b787
4 changed files with 66 additions and 6 deletions

View File

@ -37,16 +37,25 @@ player-%:
$(call make,stack-User-$*,$(MYOS),$(PLAYER_MAKE_VARS)) \
)
.PHONY: shellcheck
shellcheck:
.PHONY: upgrade
upgrade: migrate-home migrate-ipfs install
## TESTS
.PHONY: check
check:
shellcheck $(SHELL_FILES) ||:
.PHONY: shellcheck-%
shellcheck-%:
shellcheck $*/*.sh
.PHONY: tests
tests: shellcheck
.PHONY: shellspec
specs: shellspec-specs;
.PHONY: upgrade
upgrade: migrate-home migrate-ipfs install
.PHONY: shellspec-%
shellspec-%:
shellspec -f tap $*
.PHONY: tests
tests: check specs

25
specs/astroport_spec.sh Normal file
View File

@ -0,0 +1,25 @@
#shellcheck shell=sh
set -eu
Describe 'Dependency'
Describe 'ipfs:'
It 'is available'
When run ipfs --help
The output should include "ipfs"
The status should be success
The stderr should equal ""
End
End
End
Describe 'Astroport'
Describe 'template_register'
Include ./tools/template.sh
It 'creates host html register page'
When call template_register
The output should include $(hostname)
The status should be success
The stderr should equal ""
End
End
End

20
tools/myhost.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
set -eu
MY_PATH="$(pwd -P)" # absolute
ME="${0##*/}"
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
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"
myHOSTName=$(hostname |sed 's/\.'${myDOMAINName}'$//')
[ -n "$myDOMAINName" ] && myHOSTName="${myHOSTName}.${myDOMAINName}" || myDOMAINName=${myHOSTName#*.}
[ -z "$myDOMAINName" ] && myDOMAINName=localhost
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

6
tools/template.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
set -eu
template_register() {
echo $(hostname)
}