Compare commits

...

2 Commits

Author SHA1 Message Date
Yann Autissier 2aa1186b69 check 2022-12-26 22:24:52 +00:00
fred b4686b48b6 ♥BOX Edition 2022-12-26 22:05:32 +01:00
6 changed files with 60 additions and 65 deletions

View File

@ -97,7 +97,7 @@ while true; do
############### ############### ############### ############### templates/index.http ############### ############### ############### ############### templates/index.http
# REPLACE myHOST in http response template (fixing next API meeting point) # REPLACE myHOST in http response template (fixing next API meeting point)
echo "$HTTPCORS" > ~/.zen/tmp/coucou/${MOATS}.myHOST.http 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" \ sed -i -e "s~\"${myIPFS}/\"~\"$(myIpfs)\"~g" \
-e "s~http://${myHOST}:12345~http://${myHOST}:${PORT}~g" \ -e "s~http://${myHOST}:12345~http://${myHOST}:${PORT}~g" \
~/.zen/tmp/coucou/${MOATS}.myHOST.http ~/.zen/tmp/coucou/${MOATS}.myHOST.http

View File

@ -148,16 +148,16 @@ if [[ ! ${TIDDLER} ]]; then
[[ ! -f "$HOME/.zen/tmp/yt-dlp/$ZFILE" ]] && echo "No FILE -- CONTINUE --" && continue [[ ! -f "$HOME/.zen/tmp/yt-dlp/$ZFILE" ]] && echo "No FILE -- CONTINUE --" && continue
echo echo
## LIMIT TO 12 MAXIMUM COPY PER DAY PER PLAYER
boucle=$((boucle+1))
espeak "Video Number $boucle" > /dev/null 1>&2
#################################################### ####################################################
echo "FOUND : ~/.zen/tmp/yt-dlp/$ZFILE" echo "FOUND : ~/.zen/tmp/yt-dlp/$ZFILE"
FILE_BSIZE=$(du -b "$HOME/.zen/tmp/yt-dlp/$ZFILE" | awk '{print $1}') FILE_BSIZE=$(du -b "$HOME/.zen/tmp/yt-dlp/$ZFILE" | awk '{print $1}')
FILE_SIZE=$(echo "${FILE_BSIZE}" | awk '{ split( "B KB MB GB TB PB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } printf "%.2f %s", $1, v[s] }') FILE_SIZE=$(echo "${FILE_BSIZE}" | awk '{ split( "B KB MB GB TB PB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } printf "%.2f %s", $1, v[s] }')
echo "FILE SIZE = $FILE_SIZE ($FILE_BSIZE octets)" echo "FILE SIZE = $FILE_SIZE ($FILE_BSIZE octets)"
## LIMIT TO 12 MAXIMUM COPY PER DAY PER PLAYER
boucle=$((boucle+1))
espeak "Video Number $boucle FILE SIZE = $FILE_SIZE" > /dev/null 1>&2
#~ ## PREPARE FOR new_file_in_astroport.sh #~ ## PREPARE FOR new_file_in_astroport.sh
#~ mkdir -p "$HOME/Astroport/youtube/$YID" #~ mkdir -p "$HOME/Astroport/youtube/$YID"
#~ REVSOURCE="$(echo "$ZYURL" | awk -F/ '{print $3}' | rev)_" #~ REVSOURCE="$(echo "$ZYURL" | awk -F/ '{print $3}' | rev)_"
@ -221,13 +221,13 @@ if [[ ! ${TIDDLER} ]]; then
] ]
' > "$HOME/.zen/tmp/$IPFSNODEID/G1CopierYoutube/$PLAYER/$YID.TW.json" ' > "$HOME/.zen/tmp/$IPFSNODEID/G1CopierYoutube/$PLAYER/$YID.TW.json"
else else
################################################################### ###################################################################
# TIDDLER WAS IN CACHE # TIDDLER WAS IN CACHE
################################################################### ###################################################################
## TODO : ADD EMAIL TO TAG ( TIMESTAMP & ADD SIGNATURE over existing ones) ## TODO : ADD EMAIL TO TAG ( TIMESTAMP & ADD SIGNATURE over existing ones)
[[ "${TIDDLER}" != "$HOME/.zen/tmp/$IPFSNODEID/G1CopierYoutube/$PLAYER/$YID.TW.json" ]] \ cp "${TIDDLER}" "$HOME/.zen/game/$PLAYER/G1CopierYoutube/"
&& cp "${TIDDLER}" "$HOME/.zen/tmp/$IPFSNODEID/G1CopierYoutube/$PLAYER/$YID.TW.json"
fi fi
@ -249,6 +249,9 @@ fi
# --deletetiddlers '[tag[CopierYoutube]]' ### REFRESH CHANNEL COPY # --deletetiddlers '[tag[CopierYoutube]]' ### REFRESH CHANNEL COPY
if [[ -s ~/.zen/tmp/$IPFSNODEID/newindex.html ]]; then if [[ -s ~/.zen/tmp/$IPFSNODEID/newindex.html ]]; then
## COPY JSON TIDDLER TO PLAYER
cp "$HOME/.zen/tmp/$IPFSNODEID/G1CopierYoutube/$PLAYER/$YID.TW.json" "$HOME/.zen/game/$PLAYER/G1CopierYoutube/"
ln -s "$HOME/.zen/game/$PLAYER/G1CopierYoutube/$YID.TW.json" "$HOME/.zen/game/$PLAYER/G1CopierYoutube/$ZFILE.json"
[[ $(diff ~/.zen/tmp/$IPFSNODEID/newindex.html ${INDEX} ) ]] && cp ~/.zen/tmp/$IPFSNODEID/newindex.html ${INDEX} && echo "===> Mise à jour ${INDEX}" [[ $(diff ~/.zen/tmp/$IPFSNODEID/newindex.html ${INDEX} ) ]] && cp ~/.zen/tmp/$IPFSNODEID/newindex.html ${INDEX} && echo "===> Mise à jour ${INDEX}"
else else
echo "Problem with tiddlywiki command. Missing ~/.zen/tmp/$IPFSNODEID/newindex.html" echo "Problem with tiddlywiki command. Missing ~/.zen/tmp/$IPFSNODEID/newindex.html"

View File

@ -1,5 +1,4 @@
#shellcheck shell=sh #shellcheck shell=sh
set -eu
Describe 'Dependency' Describe 'Dependency'
Describe 'ipfs:' Describe 'ipfs:'
@ -13,25 +12,21 @@ Describe 'Dependency'
End End
Describe 'Astroport' Describe 'Astroport'
Describe 'tools/myhost.sh' Describe 'tools/my.sh'
Include ./tools/myhost.sh Include ./tools/my.sh
myhost() {
echo $myHOST
echo $myIPFS
}
It 'does my env variables' It 'does my env variables'
myhost() {
echo $myHOST
echo $myIPFS
}
When call myhost When call myhost
The output should include astroport. The output should include astroport.
The output should include ipfs. The output should include ipfs.
The status should be success The status should be success
The stderr should equal "" The stderr should equal ""
End End
End
Describe 'tools/template.sh'
Include ./tools/myhost.sh
Include ./tools/template.sh
It 'does host html register page' It 'does host html register page'
When call template_register When call myTmpl
The stdout should include $(hostname) The stdout should include $(hostname)
The stdout should include $IPFSNODEID The stdout should include $IPFSNODEID
The stdout should include $myASTROPORT The stdout should include $myASTROPORT
@ -40,7 +35,8 @@ Describe 'Astroport'
The stderr should equal "" The stderr should equal ""
End End
It 'does localhost html register page' 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='salt' value=''"
The stdout should include "input name='pepper' value=''" The stdout should include "input name='pepper' value=''"
The status should be success The status should be success

File diff suppressed because one or more lines are too long

View File

@ -100,7 +100,7 @@ if [[ $SALT != "" && PEPPER != "" ]]; then
fi fi
################################################################################ ################################################################################
TWMODEL="/ipfs/bafybeiel2pidycxek6jxjwat5wt4estn2fm4phhvhmlmmhq7dcltbp7nsi" TWMODEL="/ipfs/bafybeibljznrdd6krwtwr4ot5vqovbz2ivnwojh74bqiu4oapeejx54ima"
# ipfs cat $TWMODEL > templates/twdefault.html # ipfs cat $TWMODEL > templates/twdefault.html
##################################################### # NEW PLAYER ############### ##################################################### # NEW PLAYER ###############
################################################################################ ################################################################################

View File

@ -1,4 +1,4 @@
#shellcheck shell=sh #shellcheck shell=sh disable=SC2034
ipfsNodeId() { ipfsNodeId() {
ipfsNodeId=$(jq -r .Identity.PeerID ~/.ipfs/config) ipfsNodeId=$(jq -r .Identity.PeerID ~/.ipfs/config)
@ -7,8 +7,9 @@ ipfsNodeId() {
isLan() { 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])/" \ 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])/") || 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" || true)
[ -n "$isLan" ] && echo "$isLan" ||:
} 2>/dev/null } 2>/dev/null
myDomainName() { myDomainName() {
@ -27,13 +28,11 @@ myHash() {
myHttp() { myHttp() {
[ -n "$(myHttpHeader)" ] \ [ -n "$(myHttpHeader)" ] \
&& myHttp="$(myHttpHeader)" \ && myHttp="$(myHttpHeader)
&& myHttp+="
" \ " || myHttp=""
|| myHttp=""
[ -n "$(myHttpContent)" ] \ [ -n "$(myHttpContent)" ] \
&& myHttp+="$(myHttpContent)" && myHttp="${myHttp}$(myHttpContent)"
[ -n "$myHttp" ] \ [ -n "$myHttp" ] \
&& echo "$myHttp" && echo "$myHttp"
} }
@ -41,7 +40,7 @@ myHttp() {
myHttpContent() { myHttpContent() {
[ -n "$(myHash)" ] \ [ -n "$(myHash)" ] \
&& myHttpContent="<html><head><title>302 Found</title></head><body><h1>Found</h1> && myHttpContent="<html><head><title>302 Found</title></head><body><h1>Found</h1>
<p>The document is <a href=\""ipfs/$(myHash)"\">here</a> in IPFS.</p></body></html>" \ <p>The document is <a href=\"ipfs/$(myHash)\">here</a> in IPFS.</p></body></html>" \
&& echo "$myHttpContent" && echo "$myHttpContent"
} }
@ -53,15 +52,14 @@ Content-Length: $(myHttpContent |wc -c)
Date: $(date -R) Date: $(date -R)
Location: ipfs/$(myHash) Location: ipfs/$(myHash)
Server: and" Server: and"
[ -n "$(myKey)" ] && myHttpHeader+=" [ -n "$(myKey)" ] && myHttpHeader="${myHttpHeader}
set-cookie: AND=$(myKey); expires=$(date -R -d "+1 month"); path=/; domain=.$(myDomainName); Secure; SameSite=lax" set-cookie: AND=$(myKey); expires=$(date -R -d "+1 month"); path=/; domain=.$(myDomainName); Secure; SameSite=lax"
[ -n "$myHttpHeader" ] && echo "$myHttpHeader" [ -n "$myHttpHeader" ] && echo "$myHttpHeader"
} }
myHostName() { myHostName() {
myHostName=$(hostname |sed 's/\.'$(myDomainName)'$//') myHostName=$(hostname |sed 's/\.'"$(myDomainName)"'$//')
[ -n "$(myDomainName)" ] && myHostName="${myHostName}.$(myDomainName)" || myDomainName=${myHostName#*.} [ -n "$(myDomainName)" ] && myHostName="${myHostName}.$(myDomainName)" || myDomainName=${myHostName#*.}
[ -z "$(myDomainName)" ] && myDomainName=localhost
[ -n "$myHostName" ] && echo "$myHostName" [ -n "$myHostName" ] && echo "$myHostName"
} }
@ -78,7 +76,7 @@ myIpfs() {
myIpns() { myIpns() {
[ -n "$(myKey)" ] \ [ -n "$(myKey)" ] \
&& myIpns="${myIPFS}/ipns/${myKey}" \ && myIpns="${myIPFS}/ipns/$(myKey)" \
&& echo "$myIpns" && echo "$myIpns"
} }
@ -88,15 +86,11 @@ myKey() {
} }
myPath() { myPath() {
myPath=$(cd "$(dirname \"$0\")" 2>/dev/null && pwd -P) myPath=$(cd "$(dirname "$0")" 2>/dev/null && pwd -P)
[ -n "$myPath" ] && echo "$myPath" [ -n "$myPath" ] && echo "$myPath"
} }
myTmpl() { myTmpl() {
[ -n "$isLAN" ] \
&& SED_SCRIPT='sed -e "s~<input type='"'hidden'"' name='"'salt'"' value='"'0'"'>~<input name='"'salt'"' value='"''"'>~g"
-e "s~<input type='"'hidden'"' name='"'pepper'"' value='"'0'"'>~<input name='"'pepper'"' value='"''"'>~g"' \
|| SED_SCRIPT='tee'
myTmpl=$($RUN sed \ myTmpl=$($RUN sed \
-e "s~\"http://127.0.0.1:1234/\"~\"${myIPFS}/\"~g" \ -e "s~\"http://127.0.0.1:1234/\"~\"${myIPFS}/\"~g" \
-e "s~\"http://127.0.0.1:1234\"~\"${myASTROPORT}\"~g" \ -e "s~\"http://127.0.0.1:1234\"~\"${myASTROPORT}\"~g" \
@ -104,9 +98,12 @@ myTmpl() {
-e "s~http://127.0.0.1:12345~http://${myHOST}:12345~g" \ -e "s~http://127.0.0.1:12345~http://${myHOST}:12345~g" \
-e "s~_IPFSNODEID_~${IPFSNODEID}~g" \ -e "s~_IPFSNODEID_~${IPFSNODEID}~g" \
-e "s~_HOSTNAME_~$(hostname)~g" \ -e "s~_HOSTNAME_~$(hostname)~g" \
-e "s~.000.~.$(printf '%03d' $(seq 0 17 |shuf -n 1)).~g" \ -e "s~.000.~.$(printf '%03d' "$(seq 0 17 |shuf -n 1)").~g" \
~/.zen/Astroport.ONE/templates/register.html | \ ~/.zen/Astroport.ONE/templates/register.html)
eval ${SED_SCRIPT:-tee}) [ -n "$isLAN" ] \
&& myTmpl=$($RUN echo "$myTmpl" | sed \
-e "s~<input type='"'hidden'"' name='"'salt'"' value='"'0'"'>~<input name='"'salt'"' value='"''"'>~g" \
-e "s~<input type='"'hidden'"' name='"'pepper'"' value='"'0'"'>~<input name='"'pepper'"' value='"''"'>~g")
[ -n "$myTmpl" ] && echo "$myTmpl" [ -n "$myTmpl" ] && echo "$myTmpl"
} }
@ -115,16 +112,15 @@ myTs() {
[ -n "$myTs" ] && echo "$myTs" [ -n "$myTs" ] && echo "$myTs"
} }
[ -n "$(myTs)" ] && MOATS="${myTs}" MOATS="$(myTs)"
[ -n "$(ipfsNodeId)" ] && IPFSNODEID="${ipfsNodeId}" IPFSNODEID="$(ipfsNodeId)"
[ -n "$(myIp)" ] && myIP="${myIp}" myIP="$(myIp)"
[ -n "$(isLan)" ] && isLAN="${isLan}" isLAN="$(isLan)"
[ -n "$(myDomainName)" ] \ myHOST="astroport.$(myDomainName)" \
&& myHOST="astroport.${myDomainName}" \ myIPFS="http://ipfs.$(myDomainName):8080" \
&& myIPFS="http://ipfs.${myDomainName}:8080" \ myASTROPORT="http://astroport.$(myDomainName):1234"
&& myASTROPORT="http://astroport.${myDomainName}:1234"
## WAN STATION ## WAN STATION
[ -n "$(myHostName)" ] && [ -z "$isLAN" ] \ [ -z "$isLAN" ] \
&& myHOST="astroport.${myHostName}" \ && myHOST="astroport.$(myHostName)" \
&& myIPFS="https://ipfs.${myDomainName}" \ && myIPFS="https://ipfs.$(myDomainName)" \
&& myASTROPORT="https://astroport.${myDomainName}" && myASTROPORT="https://astroport.$(myDomainName)"