Upgrade TW to latest version when moving PLAYER

This commit is contained in:
fred 2024-03-26 02:33:10 +01:00
parent 62aa6cd563
commit bbbc4174f6
1 changed files with 43 additions and 37 deletions

View File

@ -55,30 +55,36 @@ if [[ $SALT != "" && PEPPER != "" ]]; then
echo "SCANNING /ipns/${ASTRONAUTENS} for 180s"
## GETTING LAST TW via IPFS or HTTP GW
[[ $YOU ]] \
&& ipfs --timeout 180s cat /ipns/${ASTRONAUTENS} > ~/.zen/tmp/${MOATS}/TW/index.html
[[ $XDG_SESSION_TYPE == 'x11' || $XDG_SESSION_TYPE == 'wayland' ]] \
&& [[ -s ~/.zen/tmp/${MOATS}/TW/index.html ]] \
&& echo "TW FOUND ENTER 'yes' TO RESET TW. HIT ENTER TO KEEP IT." \
&& read ENTER
if [[ $ENTER != "" ]]; then
ipfs --timeout 180s cat /ipns/${ASTRONAUTENS} > ~/.zen/tmp/${MOATS}/TW/index.html
if [[ -s ~/.zen/tmp/${MOATS}/TW/index.html ]]; then
echo "TW FOUND... BACKUP TIDDLERS"
# BACKUP tiddlers
tiddlywiki --load ~/.zen/tmp/${MOATS}/TW/index.html --output ~/.zen/tmp \
tiddlywiki --load ~/.zen/tmp/${MOATS}/TW/index.html --output ~/.zen/tmp/${MOATS} \
--render '.' 'backup.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[!is[system]]'
rm ~/.zen/tmp/${MOATS}/TW/index.html
echo ">> Tiddlers Backup : ~/.zen/tmp/backup.json"
[[ -s ~/.zen/tmp/${MOATS}/backup.json ]] \
&& rm ~/.zen/tmp/${MOATS}/TW/index.html \
&& echo ">> Tiddlers Backup : ~/.zen/tmp/${MOATS}/backup.json" \
|| echo "ERROR EXTRACTING TIDDLERS"
fi
#############################################
## AUCUN RESULTAT
if [ ! -s ~/.zen/tmp/${MOATS}/TW/index.html ]; then
## CREATE NEW TW FROM TEMPLATE
cp ${MY_PATH}/../templates/twuplanet.html ~/.zen/tmp/${MOATS}/TW/index.html
else
#### REFILL WITH BACKUP
if [[ -s ~/.zen/tmp/${MOATS}/backup.json ]]; then
tiddlywiki --load ~/.zen/tmp/${MOATS}/TW/index.html \
--import ~/.zen/tmp/backup.json "application/json" \
--output ~/.zen/tmp/${MOATS} --render "$:/core/save/all" "tw.html" "text/plain"
[[ -s ~/.zen/tmp/${MOATS}/tw.html ]] \
&& cp -f ~/.zen/tmp/${MOATS}/tw.html ~/.zen/tmp/${MOATS}/TW/index.html
echo "BACKUP RESTORED"
fi
#############################################
# EXISTING TW : DATA TESTING & CACHE
rm -f ~/.zen/tmp/${MOATS}/Astroport.json
@ -107,7 +113,7 @@ if [[ $SALT != "" && PEPPER != "" ]]; then
fi
fi
ipfs key rm ${MOATS} 2>/dev/null ## CLEANING MOATS KEY