astrXbian/zen/ipfs_SWARM_refresh.sh

352 lines
20 KiB
Bash
Raw Normal View History

2020-12-12 01:26:39 +01:00
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.03.24
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
2021-06-04 23:50:39 +02:00
countMErunning=$(ps auxf --sort=+utime | grep -w $ME | grep -v -E 'color=auto|grep' | wc -l)
[[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0
2021-04-01 17:04:30 +02:00
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) && [[ ! $YOU ]] && echo "ipfs NOT RUNNING. EXIT" && exit 1
G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) && [[ ! $G1PUB ]] && echo "ERREUR G1PUB. EXIT" && exit 1
2021-07-10 14:04:16 +02:00
IPFSNODEID=$(ipfs --timeout=20s id -f='<id>\n')
[[ ! $IPFSNODEID ]] && echo 'ERROR missing IPFS Node id !! IPFS is not installed !?' && exit 1
2020-12-12 01:26:39 +01:00
########################################################################
########################################################################
# This script is controling IPFS swarm
# Sync friends peers ~/.zen/ipfs/ into ~/.zen/ipfs_swarm/.IPFSNODEID's/ directories
# add not friend_of_mine IPs to fail2ban
2021-09-04 16:01:37 +02:00
## CREATES index.html to web publish
2020-12-12 01:26:39 +01:00
########################################################################
########################################################################
2021-09-11 00:08:13 +02:00
[ ! -d ~/.zen/ipfs_swarm ] && mkdir -p ~/.zen/ipfs_swarm
2020-12-12 01:26:39 +01:00
echo '
2021-08-02 06:28:47 +02:00
___ _ _ __ __ _ _ _ _ _ _ __
| |_)|_(_ (_\ //\ |_)|\/| |_)|_|_|_)|_(_ |_|
_|_| | __) __)\/\//--\| \| | | \|_| | \|___)| |
2020-12-12 01:26:39 +01:00
'
2021-03-18 00:46:55 +01:00
echo "I am $IPFSNODEID CONTROLING MY SWARM"
2021-01-31 17:21:20 +01:00
timestamp=$(date -u +%s%N | cut -b1-13)
2020-12-12 01:26:39 +01:00
########################################################################
2021-03-11 22:56:12 +01:00
# Delete "ipfs" & "ipfs_swarm" after reboot
2021-03-18 00:46:55 +01:00
# [[ ! -f /tmp/swarm_cleaned ]] && rm -Rf ~/.zen/ipfs/* && rm -Rf ~/.zen/ipfs_swarm/ && mkdir -p ~/.zen/ipfs_swarm && echo "IPFS CLEANING OK" > /tmp/swarm_cleaned
########################################################################
2021-04-07 23:01:20 +02:00
[[ "$1" == "quick" ]] && echo "" > /tmp/A_swarm || cat ~/.zen/A_swarm_map.txt > /tmp/A_swarm
2021-02-16 23:53:09 +01:00
rm /tmp/treated.ipfs.swarm
touch /tmp/treated.ipfs.swarm
2020-12-12 01:26:39 +01:00
2021-04-02 23:26:47 +02:00
## RESET BOOTSTRAP LIST
2021-04-30 14:30:46 +02:00
# ipfs bootstrap rm --all > /dev/null 2>&1
2021-04-02 23:26:47 +02:00
########################################################################
########################################################################
echo "******************************************************************"
echo "REFRESHING MY OWN DATA FROM IPNS TO ~/.zen/ipfs_swarm"
2021-09-12 23:52:09 +02:00
find /home/$YOU/.zen/ipfs_swarm/.$IPFSNODEID/ -type f -mtime +8 -exec rm '{}' \;
2021-09-03 23:55:26 +02:00
find /home/$YOU/.zen/ipfs_swarm/.$IPFSNODEID/ -empty -type d -delete;
ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$IPFSNODEID
########################################################################
2020-12-12 01:26:39 +01:00
count=1
2021-05-23 01:00:51 +02:00
ipfs bootstrap > /tmp/ipfs_swarm_peers
ipfs swarm peers >> /tmp/ipfs_swarm_peers
2021-09-04 22:24:59 +02:00
rm ~/.zen/A_peering_peers.txt
[[ ! -f ~/.ipfs/config.bak ]] && cp ~/.ipfs/config ~/.ipfs/config.bak ## Backup previous original
cp ~/.ipfs/config ~/.ipfs/config.new ## Prepare Peering.Peers changes
2021-09-04 22:24:59 +02:00
2021-09-04 16:01:37 +02:00
# for ipfsnodeid in $( (cat /tmp/ipfs_swarm_peers | grep -o '[^/]*$' && cat /tmp/A_swarm | grep -o '[^/]*$' ) | sort | uniq); ## TODO ACTIVATE IN DEFCON 4
2021-09-06 11:11:12 +02:00
for ipfsnodeid in $(cat ~/.zen/ipfs_swarm/.*/tryme.addr | grep -o '[^/]*$' | sort | uniq);
2020-12-12 01:26:39 +01:00
do
## $ipfsnodeid already Treated ?
[[ "$ipfsnodeid" == "$IPFSNODEID" ]] && continue
2021-09-13 03:09:07 +02:00
[[ -f ~/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && XID=$(ipfs --timeout=20s cat /ipns/$ipfsnodeid/.$ipfsnodeid/_xbian.zuid) || XID=''
2021-09-11 00:08:13 +02:00
[[ -f ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title ]] && GZUID=$(cat ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title) || GZUID=''
2021-09-13 03:09:07 +02:00
# [[ "$XID" == "" ]] && ipfs swarm disconnect /ipfs/$ipfsnodeid ## NOT COMPLIANT FRIEND STATION
2021-09-07 14:02:19 +02:00
# [[ $(cat /tmp/treated.ipfs.swarm | grep "$ipfsnodeid") ]] && continue ## TODO ACTIVATE IN DEFCON 4
# [[ $(cat ~/.zen/A_dead_swarm.txt | grep "$ipfsnodeid") ]] && echo "DEAD SWARM" && continue ## TODO ACTIVATE IN DEFCON 4
2021-05-20 15:55:45 +02:00
2021-08-02 06:28:47 +02:00
# control ip isLAN?
2021-09-11 00:08:13 +02:00
peerline=$(cat ~/.zen/A_swarm_map.txt | grep "$ipfsnodeid" | grep '/quic/' | head -n 1) ## Prefer quic protocol addresses
[[ ! $peerline ]] && peerline=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | tail -n 1)
2021-09-11 00:08:13 +02:00
ip=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | grep '/quic/' | head -n 1 | awk -F '/' '{print $3}') && [[ ! $ip ]] && continue
2020-12-12 01:26:39 +01:00
isLAN=$(echo $ip | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
2020-12-25 18:27:47 +01:00
nowdate=$(date)
2021-05-20 15:55:45 +02:00
2021-09-07 14:02:19 +02:00
# Convert ipfsnodeid into g1pub (only for 12D adresses, others are not Astroport)
2021-06-04 03:22:37 +02:00
[[ "${ipfsnodeid:0:2}" != "Qm" ]] && whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) || echo "$ipfsnodeid" >> ~/.zen/A_dead_swarm.txt
2021-08-02 06:28:47 +02:00
echo "#############################################################"
2021-09-11 00:08:13 +02:00
echo "### ANALYZING $ipfsnodeid ($ip) $XID $GZUID ###"
2021-04-02 19:48:16 +02:00
echo "$peerline"
myfriendpeer=$(cat ~/.zen/A_my_swarm.txt | grep $ipfsnodeid )
2021-08-02 08:05:02 +02:00
if [[ "$myfriendpeer" != "" ]];
then
2021-08-02 06:28:47 +02:00
# _____ ____ ___ _____ _ _ ____
# | ___| _ \|_ _| ____| \ | | _ \
2021-06-05 02:43:02 +02:00
# | |_ | |_) || || _| | \| | | | |
# | _| | _ < | || |___| |\ | |_| |
2021-08-02 06:28:47 +02:00
# |_| |_| \_\___|_____|_| \_|____/
#
#
2021-08-02 08:05:02 +02:00
if [[ ! $(cat /tmp/ipfs_swarm_peers | grep $ipfsnodeid) ]];
then
ipfs swarm connect "$peerline"
if [ $? != 0 ]; then
grep -vEi $ip ~/.zen/A_my_swarm.txt
echo $ipfsnodeid >> ~/.zen/A_dead_swarm.txt
2021-09-11 00:08:13 +02:00
echo "SEND MESSAGE ABOUT UNREACHABLE FRIEND $whoisg1 ($XID) ($GZUID)"
~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $G1PUB -t "ALERT" -m "Impossible de se synchroniser avec $whoisg1 ($XID) ($GZUID)"
# KEEPING LAST 10 ALERT MESSAGES
nbmessage=0
for messageid in $(~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$G1PUB" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ALERT")' | jq -r '.id')
do
nbmessage=$((nbmessage+1))
[ $nbmessage -gt 10 ] && echo "Delete $nbmessage OLD 'ALERT' messages from $G1PUB" && ~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" delete -i $messageid && sleep 0.5
done
continue
fi
fi
2021-09-07 14:02:19 +02:00
################################################################
## Refresh bootstrap if XID exists
2021-09-13 03:09:07 +02:00
if [[ "$XID" != "" ]]; then
ipfs bootstrap rm "/ipfs/$ipfsnodeid" && ipfs bootstrap add "$peerline" || ipfs bootstrap rm "$peerline"
2021-09-12 23:52:09 +02:00
################################################################
2021-09-11 01:44:15 +02:00
################################################################
2021-09-13 03:09:07 +02:00
echo "Removing 8 days older data from ~/.zen/ipfs_swarm/.$ipfsnodeid/"
find /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/ -type f -mtime +8 -exec rm '{}' \;
find /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/ -empty -type d -delete;
2021-09-11 01:44:15 +02:00
################################################################
2021-09-13 03:09:07 +02:00
echo "OK Friend SWARM REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/"
2021-09-20 02:48:58 +02:00
ipfs --timeout=120s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
################################################################
2021-09-13 03:09:07 +02:00
if [ $? != 0 ];
then
echo "TIMEOUT REACHED ___ REMOVE FROM .Peering.Peers ";
# jq '.Peering.Peers |= map( if .ID=="'$ipfsnodeid'" then del(.) else . end )' ~/.ipfs/config.new > ~/.ipfs/config.wew && cp ~/.ipfs/config.wew ~/.ipfs/config.new
else
################################################################
echo "@@ CREATING Peering.Peer @@"
echo ".Peering.Peers += { \"Addrs\": [], \"ID\": \"'$ipfsnodeid'\" }"
################################################################
Addr=$(echo "$peerline" | rev | cut -d '/' -f 2- | rev )
IsAlreadythere=$(cat ~/.ipfs/config.new | grep \"$ipfsnodeid\") && echo $IsAlreadythere
if [[ ! $IsAlreadythere ]]; then
echo '{ "ID": "'$ipfsnodeid'", "Addrs": [] }' >> ~/.zen/A_peering_peers.txt
#jq '.Peering.Peers? += { "Addrs": [], "ID": "'$ipfsnodeid'" }' ~/.ipfs/config.new > ~/.ipfs/config.wew && cp ~/.ipfs/config.wew ~/.ipfs/config.new
jq '.Peering.Peers[.Peering.Peers| length] |= . + { "Addrs": [], "ID": "'$ipfsnodeid'" }' ~/.ipfs/config.new > ~/.ipfs/config.wew && cp ~/.ipfs/config.wew ~/.ipfs/config.new
fi
################################################################
echo "## REFRESH stargates keys from my friend"
################################################################
mkdir -p ~/.zen/key/stargates/$whoisg1
ipfs --timeout=60s get --output=$HOME/.zen/key/stargates/$whoisg1/ /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/
## DECRYPT STARGATE KEYS
if [[ $? == 0 ]]; then
[[ -f $HOME/.zen/key/stargates/$whoisg1/stargate1.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate1.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate1"
[[ -f $HOME/.zen/key/stargates/$whoisg1/stargate2.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate2.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate2"
[[ -f $HOME/.zen/key/stargates/$whoisg1/stargate3.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate3.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate3"
[[ -f $HOME/.zen/key/stargates/$whoisg1/stargate4.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate4.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate4"
[[ -f $HOME/.zen/key/stargates/$whoisg1/stargate5.encrypt ]] && $MY_PATH/tools/natools.py decrypt -f pubsec -k "$HOME/.zen/secret.dunikey" -i "$HOME/.zen/key/stargates/$whoisg1/stargate5.encrypt" -o "$HOME/.zen/key/stargates/$whoisg1/stargate5"
## KEYS COULD BE ADDED TO ~/.ipfs/keystore/ ?
fi
2021-07-07 22:44:32 +02:00
fi
fi
2021-08-02 08:05:02 +02:00
else # if [[ "$myfriendpeer" != "" ]];
2021-08-02 06:28:47 +02:00
# ____ _____ _____ ____ ___ _ _
2021-06-05 02:43:02 +02:00
# | _ \| ____| ___/ ___/ _ \| \ | |
# | | | | _| | |_ | | | | | | \| |
# | |_| | |___| _|| |__| |_| | |\ |
# |____/|_____|_| \____\___/|_| \_|
2021-08-02 06:28:47 +02:00
#
[[ -f ~/.zen/DEFCON ]] && export DEFCON=$(cat ~/.zen/DEFCON) || export DEFCON=$(cat ~/.zen/astrXbian/DEFCON) # like in crom_MINUTE.sh
echo "!!! UNKNOWN FRIEND !!! $ip ___ $ipfsnodeid ________ # DEFCON : $DEFCON "
2021-09-04 14:46:36 +02:00
[[ -d ~/.zen/ipfs_swarm/.$ipfsnodeid ]] && rm -Rf ~/.zen/ipfs_swarm/.$ipfsnodeid && echo "REMOVE ipfs_swarm DIRECTORY"
2021-06-04 03:22:37 +02:00
ip=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | awk -F '/' '{print $3}' | head -n 1)
2021-06-04 03:22:37 +02:00
isLAN=$(echo $ip | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
[[ $ip ]] && anybodyelseipfsid=$(cat /tmp/ipfs_swarm_peers | grep "$ip" | grep -Ev "$ipfsnodeid" | head -n 1 | rev | cut -d '/' -f 1 | rev )
2021-06-04 03:22:37 +02:00
[[ $anybodyelseipfsid ]] && isanybodyelseipmyfriend=$(cat ~/.zen/A_my_swarm.txt | grep $anybodyelseipfsid) ## AVOID BANNING IP IF A FRIEND IS IN SAME LAN WITH PUBLIC IP
[[ $isanybodyelseipmyfriend ]] && echo "TODO: SEND MESSAGE TO $isanybodyelseipmyfriend WARNING ABOUT $ipfsnodeid SAME SEEN IP $ip"
if [[ $ip && ! $isanybodyelseipmyfriend && ( $DEFCON < 5 ) && ! $isLAN ]]
then
2021-06-05 02:43:02 +02:00
if [[ $DEFCON -eq 4 ]]; then ## DEFCON 4
### SECURITY CHOICE TO MAKE IN /etc/sudoers ###
# $USER ALL=(ALL:ALL) NOPASSWD:ALL
# $USER ALL=(ALL:ALL) NOPASSWD:/usr/bin/fail2ban-client
sudo fail2ban-client add recidive 2>/dev/null 1>&2
sudo fail2ban-client start recidive
2021-06-16 22:55:19 +02:00
sudo fail2ban-client set recidive bantime 36000 # 10 Hours bantime
sudo fail2ban-client set recidive banip $ip
2021-08-02 06:28:47 +02:00
# Show ALL banned IP
sudo fail2ban-client status recidive
fi
2021-08-02 06:28:47 +02:00
2021-08-02 08:05:02 +02:00
## DEFCON 2
# nmap NOT FRIEND
## DEFCON 1
# DDOS NOT FRIEND
fi
if [[ ! $isLAN ]]; then
ipfs swarm disconnect "$peerline"
fi
ipfs bootstrap rm "$peerline"
fi
echo "$ipfsnodeid" >> /tmp/treated.ipfs.swarm
done
2021-08-02 06:28:47 +02:00
2021-09-05 21:15:16 +02:00
########################################################################
## FIND LOCAL IPFS NODE - SERACH FOR FOAF stargate replications
########################################################################
2021-09-18 20:45:58 +02:00
# SUBNET=$(ip route | head -n 3 | tail -n 1 | cut -d ' ' -f 1)
# [[ ! $(which nmap) ]] && sudo apt-get install nmap -y && nmap --open -p 4001 $SUBNET
########################################################################
########################################################################
2021-09-05 21:15:16 +02:00
2021-09-06 17:25:22 +02:00
2021-09-05 21:15:16 +02:00
########################################################################
if [[ $DEFCON -eq 3 ]];#########################################################
########################################################################
2021-08-02 08:07:21 +02:00
then ## DEFCON 3
# ACTIVATE PRIVATE SMARM !! 1ST BOOTSRAP creates and send a key to every level3 friends he knows (PUB)
# RUN ONCE ONLY
if [[ ! -f ~/.ipfs/swarm.key.defcon3 ]];
then
2021-08-11 04:08:10 +02:00
SWARMKEYnode=$(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#" | head -n 1) ## FIRST BOOTSTRAP EMIT AND SEND swarm.key
2021-08-02 08:07:21 +02:00
nodeid=${SWARMKEYnode##*/}
KEYnode=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $nodeid)
# I $G1PUB am designed to launch defcon3
if [[ "$KEYnode" == "$G1PUB" ]];
then
## CREATE swarm.key
echo -e "/key/swarm/psk/1.0.0/\n/base16/\n `tr -dc 'a-f09' < /dev/urandom | head -c64`" > ~/.ipfs/swarm.key.defcon3
## IDENTIFY LEVEL 3 FRIENDS
## CONTACT FRIENDS AND MAKE APPOINTEMENT !!
for g1id in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS); do
[[ "$g1id" == "index.html" ]] && continue
ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1id)
[[ "$ipfsnodeid" == "" ]] && continue
echo "BLOB-Brain Friend RENEW /ipns/$ipfsnodeid TO ~/.zen/ipfs_swarm/"
rm - Rf /home/$YOU/.zen/ipfs_swarm/$ipfsnodeid
2021-08-26 16:41:38 +02:00
ipfs --timeout=60s get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
2021-08-02 08:07:21 +02:00
[[ -f /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && zuid=$(cat /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid) || continue
stars=$(cat ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/$g1id/stars.level);
G1BALANCE=$(~/.zen/astrXbian/zen/jaklis/jaklis.py balance -p $g1pub) && [[ "$G1BALANCE" == "null" ]] && G1BALANCE=0 || G1BALANCE=$(echo "$G1BALANCE" | cut -d '.' -f 1)
echo "DEFCON3 $stars STARS $g1pub ($G1BALANCE G1) /ipns/$ipfsnodeid" >> ~/.zen/alert
## MESSAGE SENT ONLY TO ONLINE LEVEL 3 FRIENDS
[ $stars -gt 3 ] && ~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $g1id -t "DEFCON3" -f ~/.ipfs/swarm.key.defcon3
done
## SEULE LA STATION SOURCE DU CODE PEUT ACTIVER DEFON3.
## LE SWARM EST ALORS MANUELLEMENT PASSE EN PRIVE
## Chaque ami prévenu reçoit le fichier à placer dans ~/.ipfs/swarm.key
## Le premier BOOTSTRAP ~/.zen/astrXbian/A_boostrap_nodes.txt
## lance un RDV sur FRAMADATE, ou autre...
fi
fi
fi
2021-09-05 21:15:16 +02:00
2021-02-01 02:43:19 +01:00
########################################################################
# REFRESH Film Serie Anime Youtube ${PREFIX}ASTRXBIAN index
2021-02-01 02:43:19 +01:00
########################################################################
2021-04-02 23:26:47 +02:00
echo "******************************************************************"
echo "### REFRESH Film Serie Anime Youtube ${PREFIX}ASTRXBIAN ###"
2021-05-18 01:16:51 +02:00
[[ ! -d ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream ]] && mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/astroport/kodi/vstream/
2021-04-02 19:48:16 +02:00
AXID=$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid);
2021-02-13 11:30:52 +01:00
2021-04-02 19:48:16 +02:00
for PREFIX in F S A Y
2021-03-07 19:41:59 +01:00
do
echo "CAT;TMDB;YEAR;TITLE;SAISON;GENRES;GROUPES;RES;URLS=http://127.0.0.1:8181" > ~/.zen/ipfs/.${IPFSNODEID}/${PREFIX}ASTRXBIAN
cat ~/.zen/ipfs_swarm/.12D*/astroport/kodi/vstream/${PREFIX}ASTRXBIAN | sed "s/anime;/film;/g" | sed '/^[[:space:]]*$/d' | grep -Ev "CAT;TMDB" | sort | uniq >> ~/.zen/ipfs/.${IPFSNODEID}/${PREFIX}ASTRXBIAN
done
## ACCESS TO www-data FOR www/boris ACCESS
chown $YOU:www-data ~/.zen/ipfs/.$IPFSNODEID/*ASTRXBIAN
chmod 664 ~/.zen/ipfs/.$IPFSNODEID/*ASTRXBIAN
## CORRECT SWARM FILE ACCESS RIGHTS to www-data
2021-09-21 20:38:33 +02:00
chmod 644 /home/$YOU/.zen/{ipfs_swarm}/.*/astroport/kodi/vstream/*ASTRXBIAN
2021-08-02 06:28:47 +02:00
# Remove old database
# rm ~/.kodi/userdata/addon_data/plugin.video.vstream/astroport_cache.db
2021-02-20 17:34:01 +01:00
########################################################################
2021-09-05 21:15:16 +02:00
## RENEW LIST OF FRIENDS index.html
########################################################################
# REFRESH tiddlywiki WALL OF FRIENDS /ipns/${IPFSNODEID}/.${IPFSNODEID}/FRIENDS/index.html
2021-02-24 22:32:26 +01:00
########################################################################
2021-08-11 04:08:10 +02:00
zuid="$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid)"
updated="$(date +"%Y-%m-%d_%H:%M")"
2021-08-11 04:08:10 +02:00
2021-04-02 23:26:47 +02:00
echo "******************************************************************"
echo "### PUBLISH tiddlywiki WALL OF FRIENDS ###"
echo "<html>
<head>
2021-09-03 23:55:26 +02:00
<title> - $zuid Friends - ${IPFSNODEID}</title>
<link rel='stylesheet' href='https://tube.copylaradio.com/crowdbunker.css' type='text/css' />
<link rel='icon' type='image/png' href='https://tube.copylaradio.com/astrocrowdbunker.png' />
</head>
<body><header>
<h1>
2021-09-03 23:55:26 +02:00
<a href='https://astroport.com'><span>Astroport</span> × <span>WIKI des Amis de $zuid $updated</span></a>
</h1>
</header>
<main>
<ul id='videosList'>" > ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/index.html
for wiki in $(ls ~/.zen/ipfs_swarm/.12D*/index.html | grep -Ev "${IPFSNODEID}" 2>/dev/null); do
ipfsnodeid=$(echo $wiki | cut -d '.' -f 3- | cut -d '/' -f 1)
whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid)
echo "<li>
<a target=\"gchange\" href=\"https://www.gchange.fr/#/app/user/$whoisg1/\">
2021-09-02 15:00:55 +02:00
<img src=\"https://tube.copylaradio.com/ipns/$ipfsnodeid/.$ipfsnodeid/QR.png\" alt=\"$whoisg1\" />
</a>
<p class='video-title'>
2021-09-03 20:38:29 +02:00
<a href=\"https://tube.copylaradio.com/ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/index.html\">
2021-09-04 16:01:37 +02:00
$ipfsnodeid
</a>
</p>
<iframe id=\"$ipfsnodeid\"
title='tiddlywiki $whoisg1'
width='600'
src=\"http://127.0.0.1:8181/ipns/$ipfsnodeid/.$ipfsnodeid/index.html\">
</iframe>
</li>" >> ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/index.html
2021-03-18 00:46:55 +01:00
done
2021-08-02 08:05:02 +02:00
echo "</main></body></html>" >> ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/index.html
2021-02-24 22:32:26 +01:00
2021-04-08 04:02:56 +02:00
########################################################################
2021-08-02 06:28:47 +02:00
# ACTIVATE WORDPRESS CHANNEL ## TODO DEBUG (creates WP duplicates)
2021-04-08 04:02:56 +02:00
########################################################################
## [[ $(which wp) ]] && ~/.zen/astrXbian/zen/wordpress_channel.sh
2021-04-08 04:02:56 +02:00
2021-09-13 03:42:03 +02:00
## CLEAN RUN p4n.swarmscraper.sh
2021-09-13 02:34:17 +02:00
~/.zen/astrXbian/actions/p4n.swarmscraper.sh
2021-09-04 22:24:59 +02:00
2021-09-05 21:15:16 +02:00
# IPNS SELF PUBLISH = mise à jour balise Station
2021-02-01 02:43:19 +01:00
########################################################################
2021-09-13 02:34:17 +02:00
~/.zen/astrXbian/zen/ipns_self_publish.sh
########################################################################
2021-02-01 02:43:19 +01:00
2020-12-12 01:26:39 +01:00
exit 0