forked from STI/Astroport.ONE
58 lines
2.1 KiB
Bash
58 lines
2.1 KiB
Bash
#!/bin/bash
|
|
################################################################################
|
|
# Author: Fred (support@qo-op.com)
|
|
# Version: 0.1
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
################################################################################
|
|
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
|
|
mkdir -p ~/.zen/tmp/${MOATS}
|
|
################################################################################
|
|
# Capture l'image cryptée
|
|
# https://as2.ftcdn.net/v2/jpg/00/57/93/35/1000_F_57933566_kr4mIE2qkjK12ZusVLdOkJmyBNPuW0o6.jpg
|
|
|
|
MY_PATH="`dirname \"$0\"`" # relative
|
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
|
ME="${0##*/}"
|
|
|
|
## TEST IPFS
|
|
[[ ! $(which ipfs) ]] && echo "Missing IPFS. Please install... https://ipfs.tech" && exit 1
|
|
|
|
## PREPARE FILE SYSTEM CACHE
|
|
mkdir -p ~/.zen/adventure/meteo.anim.eu
|
|
rm -f ~/.zen/adventure/meteo.anim.eu/meteo.png
|
|
|
|
## SCRAPING meteo.png
|
|
curl -m 20 --output ~/.zen/adventure/meteo.anim.eu/meteo.png https://as2.ftcdn.net/v2/jpg/00/57/93/35/1000_F_57933566_kr4mIE2qkjK12ZusVLdOkJmyBNPuW0o6.jpg
|
|
|
|
if [[ ! -f ~/.zen/adventure/meteo.anim.eu/meteo.png ]]; then
|
|
|
|
echo "Impossible d'accéder à la photo"
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Chiffrage de la photo : ${MOATS}"
|
|
echo ${MOATS} > ~/.zen/adventure/meteo.anim.eu/.moats
|
|
|
|
OLDID=$(cat ~/.zen/adventure/.meteo.index 2>/dev/null)
|
|
# TODO : COMPARE SIMILAR OR NOT
|
|
# ipfs get "/ipfs/$OLDID/meteo.anim.eu/meteo.png"
|
|
|
|
## PREPARE NEW index.html
|
|
sed "s/_OLDID_/$OLDID/g" ${MY_PATH}/../templates/meteo_chain.html > /tmp/index.html
|
|
sed -i "s/_IPFSID_/$IPFSID/g" /tmp/index.html
|
|
sed -i "s/_DATE_/$(date -u "+%Y-%m-%d#%H:%M:%S")/g" /tmp/index.html
|
|
sed "s/_PSEUDO_/${USER}/g" /tmp/index.html > ~/.zen/adventure/index.html
|
|
|
|
# Copy style css
|
|
cp -r ${MY_PATH}/../templates/styles ~/.zen/adventure/
|
|
|
|
INDEXID=$(ipfs add -rHq ~/.zen/adventure/* | tail -n 1)
|
|
echo $INDEXID > ~/.zen/adventure/.meteo.index
|
|
echo "METEO INDEX : http://127.0.0.1:8080/ipfs/$INDEXID"
|
|
|
|
IPFS=$(ipfs add -q ~/.zen/adventure/meteo.anim.eu/meteo.png | tail -n 1)
|
|
echo $IPFS > ~/.zen/adventure/meteo.anim.eu/.chain
|
|
|
|
fi
|