replace TAB with " " for testing code with copy/paste on console.

This commit is contained in:
qo-op 2021-06-04 01:44:36 +02:00
parent 12f9d1c8bd
commit fba22ba2e3
6 changed files with 349 additions and 349 deletions

View File

@ -31,14 +31,14 @@ mkdir -p ~/.zen/astrXbian && cd ~/.zen/astrXbian && git pull || exit 1
# CHECK IF CONFIG ALREADY DONE !! # CHECK IF CONFIG ALREADY DONE !!
# ~/.zen/ipfs ~/.zen/secret ~/.zen/ipfs.sync # ~/.zen/ipfs ~/.zen/secret ~/.zen/ipfs.sync
if [[ -f ~/.zen/ipfs.sync ]]; then if [[ -f ~/.zen/ipfs.sync ]]; then
echo "CONFIG ALREADY DONE.... logging init in /tmp/A_booting_log.txt" echo "CONFIG ALREADY DONE.... logging init in /tmp/A_booting_log.txt"
source ~/.zen/ipfs.sync source ~/.zen/ipfs.sync
# Wait for IPFS to connect SWARM # Wait for IPFS to connect SWARM
sleep 20 sleep 20
~/.zen/astrXbian/zen/gchange_INIT.sh >> /tmp/A_booting_log.txt ~/.zen/astrXbian/zen/gchange_INIT.sh >> /tmp/A_booting_log.txt
sleep 10 sleep 10
~/.zen/astrXbian/zen/gchange_IPFS_swarm.sh >> /tmp/A_booting_log.txt ~/.zen/astrXbian/zen/gchange_IPFS_swarm.sh >> /tmp/A_booting_log.txt
exit 0 exit 0
fi fi
@ -144,12 +144,12 @@ echo "BECOME FRIEND with A_boostrap_nodes.txt"
for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments
do do
if [[ $bootnode != "" ]]; then if [[ $bootnode != "" ]]; then
ipfsnodeid=${bootnode##*/} ipfsnodeid=${bootnode##*/}
g1node=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) g1node=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid)
echo "SENDING STAR TO BOOTSTRAP NODE : $g1node" echo "SENDING STAR TO BOOTSTRAP NODE : $g1node"
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $g1node -n 1 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $g1node -n 1
### DELETE ### DELETE
# ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" unstars -p $g1node # ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" unstars -p $g1node
fi fi
done done
@ -207,11 +207,11 @@ echo 'Sending \"ipfstryme\" message to BOOTSTRAP nodes' # Add bootstrap in A_boo
for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments
do do
if [[ $bootnode != "" ]]; then if [[ $bootnode != "" ]]; then
ipfsnodeid=${bootnode##*/} ipfsnodeid=${bootnode##*/}
g1node=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) g1node=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid)
echo "SENDING ipfstryme to BOOTSTRAP node : $g1node" echo "SENDING ipfstryme to BOOTSTRAP node : $g1node"
filelines=$(cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr | wc -l) filelines=$(cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr | wc -l)
[[ "$filelines" != "0" ]] && ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $g1node -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr [[ "$filelines" != "0" ]] && ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $g1node -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
fi fi
done done
@ -281,8 +281,8 @@ ipfs config --json Experimental.P2pHttpProxy true
ipfs bootstrap rm --all ipfs bootstrap rm --all
for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments
do do
## ADD $bootnode TO BOOTSTRAP ## ADD $bootnode TO BOOTSTRAP
ipfs bootstrap add $bootnode ipfs bootstrap add $bootnode
done done
# AVOID CONFLICT WITH KODI REMOTE # AVOID CONFLICT WITH KODI REMOTE

View File

@ -66,20 +66,20 @@ weeknumber=$(date +%V)
# WAKEUP TIME # WAKEUP TIME
if [[ ! -f /tmp/A_Station_ON ]]; then if [[ ! -f /tmp/A_Station_ON ]]; then
echo "onheure=$heure; onminute=$minute; ontimebar=$timebar" > /tmp/A_Station_ON echo "onheure=$heure; onminute=$minute; ontimebar=$timebar" > /tmp/A_Station_ON
else else
source /tmp/A_Station_ON source /tmp/A_Station_ON
old=$ontimebar old=$ontimebar
new=$timebar new=$timebar
# feeding variables by using read and splitting with IFS # feeding variables by using read and splitting with IFS
IFS=: read old_hour old_min <<< "$old" IFS=: read old_hour old_min <<< "$old"
IFS=: read hour min <<< "$new" IFS=: read hour min <<< "$new"
# convert hours to minutes # convert hours to minutes
# the 10# is there to avoid errors with leading zeros # the 10# is there to avoid errors with leading zeros
# by telling bash that we use base 10 # by telling bash that we use base 10
total_old_minutes=$((10#$old_hour*60 + 10#$old_min)) total_old_minutes=$((10#$old_hour*60 + 10#$old_min))
total_minutes=$((10#$hour*60 + 10#$min)) total_minutes=$((10#$hour*60 + 10#$min))
runtime=$((total_minutes - total_old_minutes)) runtime=$((total_minutes - total_old_minutes))
fi fi
# RUN TIME $runtime # RUN TIME $runtime
@ -109,36 +109,36 @@ if [[ $(($minute % 15)) == 0 ]]; then
git pull git pull
[[ ! $? == 0 ]] && echo "GIT.P2P.LEGAL IS UNREACHABLE" [[ ! $? == 0 ]] && echo "GIT.P2P.LEGAL IS UNREACHABLE"
# if [[ $(diff ~/.zen/astrXbian/.install/.kodi/userdata/addon_data/plugin.video.vstream/settings.xml ~/.kodi/userdata/addon_data/plugin.video.vstream/settings.xml) ]]; then # if [[ $(diff ~/.zen/astrXbian/.install/.kodi/userdata/addon_data/plugin.video.vstream/settings.xml ~/.kodi/userdata/addon_data/plugin.video.vstream/settings.xml) ]]; then
# cp ~/.zen/astrXbian/.install/.kodi/userdata/addon_data/plugin.video.vstream/settings.xml ~/.kodi/userdata/addon_data/plugin.video.vstream/settings.xml # cp ~/.zen/astrXbian/.install/.kodi/userdata/addon_data/plugin.video.vstream/settings.xml ~/.kodi/userdata/addon_data/plugin.video.vstream/settings.xml
# echo "MAJ Vstream settings" # echo "MAJ Vstream settings"
# fi # fi
# CLEAN AND REMOVE BAD DIRECTORIES # CLEAN AND REMOVE BAD DIRECTORIES
[[ -f ~/.zen/ipfs/index.html ]] && cp ~/.zen/ipfs/index.html /tmp/ipfsindex.html [[ -f ~/.zen/ipfs/index.html ]] && cp ~/.zen/ipfs/index.html /tmp/ipfsindex.html
[[ -d ~/.zen/ipfs/astroport ]] && rm -Rf ~/.zen/ipfs/astroport [[ -d ~/.zen/ipfs/astroport ]] && rm -Rf ~/.zen/ipfs/astroport
[[ -d ~/.zen/ipfs_swarm/astroport ]] && rm -Rf ~/.zen/ipfs_swarm/astroport [[ -d ~/.zen/ipfs_swarm/astroport ]] && rm -Rf ~/.zen/ipfs_swarm/astroport
[[ -d ~/.zen/ipfs/xbian ]] && rm -Rf ~/.zen/ipfs/xbian [[ -d ~/.zen/ipfs/xbian ]] && rm -Rf ~/.zen/ipfs/xbian
[[ -d ~/.zen/ipfs_swarm/xbian ]] && rm -Rf ~/.zen/ipfs_swarm/xbian [[ -d ~/.zen/ipfs_swarm/xbian ]] && rm -Rf ~/.zen/ipfs_swarm/xbian
[[ -d ~/.zen/ipfs/PIN ]] && rm -Rf ~/.zen/ipfs/PIN [[ -d ~/.zen/ipfs/PIN ]] && rm -Rf ~/.zen/ipfs/PIN
[[ -d ~/.zen/ipfs_swarm/PIN ]] && rm -Rf ~/.zen/ipfs_swarm/PIN [[ -d ~/.zen/ipfs_swarm/PIN ]] && rm -Rf ~/.zen/ipfs_swarm/PIN
## CLEANING OLD BAD FILES ## CLEANING OLD BAD FILES
rm ~/.zen/ipfs/* rm ~/.zen/ipfs/*
rm ~/.zen/ipfs/.* rm ~/.zen/ipfs/.*
rm ~/.zen/ipfs_swarm/* rm ~/.zen/ipfs_swarm/*
rm ~/.zen/ipfs_swarm/.* rm ~/.zen/ipfs_swarm/.*
[[ -f /tmp/ipfsindex.html ]] && mv /tmp/ipfsindex.html ~/.zen/ipfs/index.html [[ -f /tmp/ipfsindex.html ]] && mv /tmp/ipfsindex.html ~/.zen/ipfs/index.html
isIPFSRunning=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1) isIPFSRunning=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)
if [[ ! $isIPFSRunning ]]; then if [[ ! $isIPFSRunning ]]; then
[[ -f /etc/sudoers.d/systemctl && -f ~/.zen/ipfs/.$IPFSNODEID/.switch ]] && sudo systemctl restart ipfs [[ -f /etc/sudoers.d/systemctl && -f ~/.zen/ipfs/.$IPFSNODEID/.switch ]] && sudo systemctl restart ipfs
echo "ERROR! ipfs daemon is not running. EXIT" echo "ERROR! ipfs daemon is not running. EXIT"
exit 1 exit 1
fi fi
########## CHATON : OPEN OR CLOSE SSH ACCESS ################# ########## CHATON : OPEN OR CLOSE SSH ACCESS #################
# [[ "$(ipfs p2p ls | grep $G1PUB-ssh)" == "" ]] && sleep $((1 + RANDOM % 10)) && ~/.zen/astrXbian/zen/ssh_forward2onelove.sh # OPEN-SSH # [[ "$(ipfs p2p ls | grep $G1PUB-ssh)" == "" ]] && sleep $((1 + RANDOM % 10)) && ~/.zen/astrXbian/zen/ssh_forward2onelove.sh # OPEN-SSH
# [[ "$(ipfs p2p ls | grep $G1PUB-ssh)" != "" ]] && sleep $((1 + RANDOM % 10)) && ~/.zen/astrXbian/zen/ssh_forward2onelove.sh # CLOSE-SSH # [[ "$(ipfs p2p ls | grep $G1PUB-ssh)" != "" ]] && sleep $((1 + RANDOM % 10)) && ~/.zen/astrXbian/zen/ssh_forward2onelove.sh # CLOSE-SSH
fi fi
# __ __ _____ ____ # __ __ _____ ____
@ -166,13 +166,13 @@ fi
# ON Rpi/xbian files added in ~/astroport are monitored to activate "new_file_in_astroport.sh" # ON Rpi/xbian files added in ~/astroport are monitored to activate "new_file_in_astroport.sh"
# Transfert ~/astroport/*/files to IPFS and make Astroport/KODI indexes in IPNS # Transfert ~/astroport/*/files to IPFS and make Astroport/KODI indexes in IPNS
if [[ "$USER" == "xbian" ]]; then if [[ "$USER" == "xbian" ]]; then
[[ ! -e /home/$USER/astroport ]] && mkdir -p /home/$USER/astroport [[ ! -e /home/$USER/astroport ]] && mkdir -p /home/$USER/astroport
# VERIFY LAUNCH inotifywait ?! # VERIFY LAUNCH inotifywait ?!
inotifywaitRunning=$(ps auxf --sort=+utime | grep -w inotifywait | grep -w astroport | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1) inotifywaitRunning=$(ps auxf --sort=+utime | grep -w inotifywait | grep -w astroport | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)
if [[ "$inotifywaitRunning" != "xbian" ]] if [[ "$inotifywaitRunning" != "xbian" ]]
then then
/usr/bin/inotifywait -r -e close_write -m /home/$USER/astroport | while read dir flags file; do $MY_PATH/zen/new_file_in_astroport.sh "$dir" "$file"; done >> /tmp/astroport.inotify.log 2>&1 & /usr/bin/inotifywait -r -e close_write -m /home/$USER/astroport | while read dir flags file; do $MY_PATH/zen/new_file_in_astroport.sh "$dir" "$file"; done >> /tmp/astroport.inotify.log 2>&1 &
fi fi
fi fi
########################################################## ##########################################################
@ -190,13 +190,13 @@ if [[ "$timebar" == "12:12" || "$timebar" == "00:12" || $(($runtime % 720)) == 0
# Restarting IPFS daemon # Restarting IPFS daemon
[[ -f /etc/sudoers.d/systemctl || "$USER" == "xbian" ]] && sudo systemctl restart ipfs [[ -f /etc/sudoers.d/systemctl || "$USER" == "xbian" ]] && sudo systemctl restart ipfs
#### timebar DESYNC #### timebar DESYNC
sleep $((1 + RANDOM % 5)) sleep $((1 + RANDOM % 5))
#### Refresh & publish MEDIAKEYs #### Refresh & publish MEDIAKEYs
$MY_PATH/zen/ipns_TAG_refresh.sh $MY_PATH/zen/ipns_TAG_refresh.sh
## REINIT dead swarm ## REINIT dead swarm
rm -f ~/.zen/A_dead_swarm.txt rm -f ~/.zen/A_dead_swarm.txt
fi fi
@ -215,64 +215,64 @@ echo '
# #
# MAINTENANCE # MAINTENANCE
' '
sleep $((1 + RANDOM % 15)) ### Be careful if random sleep is not activated... sleep $((1 + RANDOM % 15)) ### Be careful if random sleep is not activated...
############################## That swarm could become an aggressive blob !! ############################## That swarm could become an aggressive blob !!
### PEACE & LOVE software is processing... We are HyperWeb people here. ### PEACE & LOVE software is processing... We are HyperWeb people here.
# DEFCON 5 quiet behaviour so Please keep cool, take care and be zen. # DEFCON 5 quiet behaviour so Please keep cool, take care and be zen.
# GOOD BYE GOOGLE, AMAZON, FACEBOOK, APPLE, MICROSOFT. LIBRE WE ARE. # GOOD BYE GOOGLE, AMAZON, FACEBOOK, APPLE, MICROSOFT. LIBRE WE ARE.
#################################################################### ####################################################################
# REFRESH & UPGRADE youtube-dl # REFRESH & UPGRADE youtube-dl
youtube-dl --rm-cache-dir youtube-dl --rm-cache-dir
youtube-dl -U youtube-dl -U
################################################################## ##################################################################
if [[ $dayoftheweek == 1 ]]; then if [[ $dayoftheweek == 1 ]]; then
# EVERY MONDAY # EVERY MONDAY
# _____ __ __ ___ # _____ __ __ ___
# / ___// /_____ _________ _____ ____ / |/ /___ __ __ # / ___// /_____ _________ _____ ____ / |/ /___ __ __
# \__ \/ __/ __ \/ ___/ __ `/ __ `/ _ \ / /|_/ / __ `/ |/_/ # \__ \/ __/ __ \/ ___/ __ `/ __ `/ _ \ / /|_/ / __ `/ |/_/
# ___/ / /_/ /_/ / / / /_/ / /_/ / __/ / / / / /_/ /> < # ___/ / /_/ /_/ / / / /_/ / /_/ / __/ / / / / /_/ /> <
# /____/\__/\____/_/ \__,_/\__, /\___/ /_/ /_/\__,_/_/|_| # /____/\__/\____/_/ \__,_/\__, /\___/ /_/ /_/\__,_/_/|_|
# /____/ # /____/
# 1/2 HDD for IPFS size - dicotomic adaptation 7th EVERY MONTH # 1/2 HDD for IPFS size - dicotomic adaptation 7th EVERY MONTH
availableDiskSize=$(df -P ~/ | awk 'NR>1{sum+=$4}END{print sum}') availableDiskSize=$(df -P ~/ | awk 'NR>1{sum+=$4}END{print sum}')
availableDiskSize="$(($availableDiskSize * 1024))" availableDiskSize="$(($availableDiskSize * 1024))"
diskSize="$((availableDiskSize / 2))" diskSize="$((availableDiskSize / 2))"
ipfs config Datastore.StorageMax $diskSize ipfs config Datastore.StorageMax $diskSize
echo "StorageMax = $diskSize" echo "StorageMax = $diskSize"
# New full test review in gchange_INIT.sh # New full test review in gchange_INIT.sh
rm -f ~/.ipfs/test.disk rm -f ~/.ipfs/test.disk
# LOG ROTATE # LOG ROTATE
[[ -f /tmp/astroport.log ]] && tar cvzf ~/.zen/astroport.$weeknumber.log.tgz /tmp/astroport.log && echo "" > /tmp/astroport.log [[ -f /tmp/astroport.log ]] && tar cvzf ~/.zen/astroport.$weeknumber.log.tgz /tmp/astroport.log && echo "" > /tmp/astroport.log
fi fi
################################################################## ##################################################################
## CHECK STARTGATE LEVEL KEYS ## CHECK STARTGATE LEVEL KEYS
# _ open _ # _ open _
# ___| |_ __ _ _ __ __ _ __ _| |_ ___ # ___| |_ __ _ _ __ __ _ __ _| |_ ___
#/ __| __/ _` | '__/ _` |/ _` | __/ _ \ #/ __| __/ _` | '__/ _` |/ _` | __/ _ \
#\__ \ || (_| | | | (_| | (_| | || __/ #\__ \ || (_| | | | (_| | (_| | || __/
#|___/\__\__,_|_| \__, |\__,_|\__\___| #|___/\__\__,_|_| \__, |\__,_|\__\___|
# |___/ # |___/
# IPNS KEYS used to publish with star friends (creates 5 levels of streaming / file sharing) # IPNS KEYS used to publish with star friends (creates 5 levels of streaming / file sharing)
# RESET # RESET
ipfs key rm star_1; ipfs key rm star_2; ipfs key rm star_3; ipfs key rm star_4; ipfs key rm star_5 ipfs key rm star_1; ipfs key rm star_2; ipfs key rm star_3; ipfs key rm star_4; ipfs key rm star_5
rm -Rf ~/.zen/key/ rm -Rf ~/.zen/key/
# RENEW & SEND STARS TO FRIENDS ~/.zen/astrXbian/zen/manage_stargates.sh # RENEW & SEND STARS TO FRIENDS ~/.zen/astrXbian/zen/manage_stargates.sh
$MY_PATH/zen/manage_stargates.sh $MY_PATH/zen/manage_stargates.sh
fi fi
### DISAPEAR ONE HOUR FROM IPFS SWARM ZOMBIES > 300 peers in swarm ### DISAPEAR ONE HOUR FROM IPFS SWARM ZOMBIES > 300 peers in swarm
if [[ $(cat /tmp/ipfs_swarm_peers | wc -l) -gt 300 ]]; then if [[ $(cat /tmp/ipfs_swarm_peers | wc -l) -gt 300 ]]; then
if [[ "$timebar" == "04:05" ]]; then if [[ "$timebar" == "04:05" ]]; then
~/.zen/astrXbian/zen/ipfs_SWARM_renew.sh 3600 ## CUT IPFS FOR ONE HOUR ~/.zen/astrXbian/zen/ipfs_SWARM_renew.sh 3600 ## CUT IPFS FOR ONE HOUR
## SWITCHING ON ## SWITCHING ON
echo "1" > ~/.zen/ipfs/.$IPFSNODEID/.switch echo "1" > ~/.zen/ipfs/.$IPFSNODEID/.switch
fi fi
fi fi

View File

@ -59,18 +59,18 @@ echo "Sécurisation DEFCON SUDOERS FAIL2BAN"
if [[ "$USER" == "xbian" ]] if [[ "$USER" == "xbian" ]]
then then
echo "enabling ipfs initV service autostart" echo "enabling ipfs initV service autostart"
cd /etc/rc2.d && sudo ln -s ../init.d/ipfs S02ipfs cd /etc/rc2.d && sudo ln -s ../init.d/ipfs S02ipfs
cd /etc/rc3.d && sudo ln -s ../init.d/ipfs S02ipfs cd /etc/rc3.d && sudo ln -s ../init.d/ipfs S02ipfs
cd /etc/rc4.d && sudo ln -s ../init.d/ipfs S02ipfs cd /etc/rc4.d && sudo ln -s ../init.d/ipfs S02ipfs
cd /etc/rc5.d && sudo ln -s ../init.d/ipfs S02ipfs cd /etc/rc5.d && sudo ln -s ../init.d/ipfs S02ipfs
cd /etc/rc0.d && sudo ln -s ../init.d/ipfs K01ipfs cd /etc/rc0.d && sudo ln -s ../init.d/ipfs K01ipfs
cd /etc/rc1.d && sudo ln -s ../init.d/ipfs K01ipfs cd /etc/rc1.d && sudo ln -s ../init.d/ipfs K01ipfs
cd /etc/rc6.d && sudo ln -s ../init.d/ipfs K01ipfs cd /etc/rc6.d && sudo ln -s ../init.d/ipfs K01ipfs
# Disable xbian-config auto launch # Disable xbian-config auto launch
echo 0 > ~/.xbian-config-start echo 0 > ~/.xbian-config-start
fi fi
@ -82,23 +82,23 @@ mkdir -p ~/astroport/anime
if [[ "$USER" != "xbian" ]] if [[ "$USER" != "xbian" ]]
then then
## Desktop install ## Desktop install
echo "INITIALISATIOn Astroport/KODI" echo "INITIALISATIOn Astroport/KODI"
echo "Appuyez sur la touche ENTREE pour créer votre nouvelle identité" echo "Appuyez sur la touche ENTREE pour créer votre nouvelle identité"
echo "sinon interrompez ici l'installation pour copier la restauration d'une sauvegarde" echo "sinon interrompez ici l'installation pour copier la restauration d'une sauvegarde"
read read
~/.zen/astrXbian/ISOconfig.sh ~/.zen/astrXbian/ISOconfig.sh
else else
## Rpi Xbian install. ## Rpi Xbian install.
cat /etc/rc.local | grep -Ev "exit 0" > /tmp/new.rc.local ## REMOVE "exit 0" cat /etc/rc.local | grep -Ev "exit 0" > /tmp/new.rc.local ## REMOVE "exit 0"
# PREPARE NEXT BOOT - Network config - NEXTBOOT - ISOConfig - NEXTBOOT - OK # PREPARE NEXT BOOT - Network config - NEXTBOOT - ISOConfig - NEXTBOOT - OK
echo "su - xbian -c '~/.zen/astrXbian/FirstBOOT.sh'" >> /tmp/new.rc.local echo "su - xbian -c '~/.zen/astrXbian/FirstBOOT.sh'" >> /tmp/new.rc.local
echo "exit 0" >> /tmp/new.rc.local echo "exit 0" >> /tmp/new.rc.local
sudo cp -f /tmp/new.rc.local /etc/rc.local sudo cp -f /tmp/new.rc.local /etc/rc.local
echo "STOP!! Redémarrer Xbian pour continuer la configuration de votre station Astroport/KODI" echo "STOP!! Redémarrer Xbian pour continuer la configuration de votre station Astroport/KODI"
echo "Faites une ISO : sudo xbian-config" echo "Faites une ISO : sudo xbian-config"
exit 0 exit 0
fi fi
# MAIN # -f ~/.zen/secret.june (ISOConfig déjà lancé) ## # MAIN # -f ~/.zen/secret.june (ISOConfig déjà lancé) ##

View File

@ -78,22 +78,22 @@ export LANG=C.UTF-8 #attipix
######################################################################## ########################################################################
# NODE DISK PERFORMANCE, manual remove ~/.ipfs/test.disk to run again # NODE DISK PERFORMANCE, manual remove ~/.ipfs/test.disk to run again
if [[ ! -f ~/.ipfs/test.disk ]]; then if [[ ! -f ~/.ipfs/test.disk ]]; then
diskperf=$(dd if=/dev/zero of=~/.ipfs/test.disk bs=10M count=1 oflag=dsync 2>&1 | tail -n 1 | sed s/\,\ /\ -/g | cut -d '-' -f 4) diskperf=$(dd if=/dev/zero of=~/.ipfs/test.disk bs=10M count=1 oflag=dsync 2>&1 | tail -n 1 | sed s/\,\ /\ -/g | cut -d '-' -f 4)
echo "DISK PERFORMANCE TESTING : $diskperf" echo "DISK PERFORMANCE TESTING : $diskperf"
# NODE disk.perf # NODE disk.perf
echo "$diskperf" > ~/.zen/ipfs/.${IPFSNODEID}/disk.perf echo "$diskperf" > ~/.zen/ipfs/.${IPFSNODEID}/disk.perf
# NODE disk.bytes # NODE disk.bytes
echo $(df ~/.ipfs/ | tail -n 1 | awk '{print $4}') > ~/.zen/ipfs/.${IPFSNODEID}/disk.bytes echo $(df ~/.ipfs/ | tail -n 1 | awk '{print $4}') > ~/.zen/ipfs/.${IPFSNODEID}/disk.bytes
# IPFS repo.stat # IPFS repo.stat
ipfs repo stat > ~/.zen/ipfs/.${IPFSNODEID}/repo.stat ipfs repo stat > ~/.zen/ipfs/.${IPFSNODEID}/repo.stat
########################################### ###########################################
# GEOLOC MUST BE SECURELY EXCHANGED (TODO) # GEOLOC MUST BE SECURELY EXCHANGED (TODO)
########################################### ###########################################
# CREATE "_g1.gchange_geoPoint.lat" AND "_g1.gchange_geoPoint.lon" # CREATE "_g1.gchange_geoPoint.lat" AND "_g1.gchange_geoPoint.lon"
# rm -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_geoPoint.lat # rm -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_geoPoint.lat
# echo $(curl -s ${GCHANGE}/user/profile/${G1PUB} | jq '._source.geoPoint.lat') > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_geoPoint.lat # echo $(curl -s ${GCHANGE}/user/profile/${G1PUB} | jq '._source.geoPoint.lat') > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_geoPoint.lat
# rm -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_geoPoint.lon # rm -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_geoPoint.lon
# echo $(curl -s ${GCHANGE}/user/profile/${G1PUB} | jq '._source.geoPoint.lon') > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_geoPoint.lon # echo $(curl -s ${GCHANGE}/user/profile/${G1PUB} | jq '._source.geoPoint.lon') > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_geoPoint.lon
fi fi
### ###
@ -118,55 +118,55 @@ rm -f /tmp/friend_of_mine
for liking_me in $(cat /tmp/liking_me); for liking_me in $(cat /tmp/liking_me);
do do
##### BOOTSTRAP AUTO LIKE BACK (NOT liking Myself) ##### BOOTSTRAP AUTO LIKE BACK (NOT liking Myself)
if [[ "$IamBOOTSTRAP" == "$G1PUB" ]]; then if [[ "$IamBOOTSTRAP" == "$G1PUB" ]]; then
echo "I AM A BOOTSTRAP AUTO LIKING $liking_me FRIEND" echo "I AM A BOOTSTRAP AUTO LIKING $liking_me FRIEND"
if [[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/tryme.addr && "$liking_me" != "$G1PUB" ]]; then if [[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/tryme.addr && "$liking_me" != "$G1PUB" ]]; then
echo "SENDING 1 STAR AUTO LIKE to $liking_me" echo "SENDING 1 STAR AUTO LIKE to $liking_me"
/home/$YOU/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" unstars -p $liking_me /home/$YOU/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" unstars -p $liking_me
sleep $((1 + RANDOM % 2)) # SLOW DOWN sleep $((1 + RANDOM % 2)) # SLOW DOWN
/home/$YOU/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $liking_me -n 1 /home/$YOU/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $liking_me -n 1
sleep $((1 + RANDOM % 2)) # SLOW DOWN sleep $((1 + RANDOM % 2)) # SLOW DOWN
fi fi
fi fi
##### CHECKING IF WE LIKE EACH OTHER (AVOID LIKING MYSELF) ##### CHECKING IF WE LIKE EACH OTHER (AVOID LIKING MYSELF)
~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $liking_me > /tmp/Gstars.json ~/.zen/astrXbian/zen/tools/timeout.sh -t 12 ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $liking_me > /tmp/Gstars.json
[[ ! -f /tmp/Gstars.json ]] && rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me && echo "$liking_me is a BUZZ FRIEND !!!" && continue [[ ! -f /tmp/Gstars.json ]] && rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me && echo "$liking_me is a BUZZ FRIEND !!!" && continue
friend_of_mine=$(cat /tmp/Gstars.json | jq -r '.yours'); friend_of_mine=$(cat /tmp/Gstars.json | jq -r '.yours');
if [[ "$friend_of_mine" != "null" && "$liking_me" != "$G1PUB" ]] if [[ "$friend_of_mine" != "null" && "$liking_me" != "$G1PUB" ]]
then then
# ADD $liking_me TO MY ipfs FRIENDS list # ADD $liking_me TO MY ipfs FRIENDS list
echo "$liking_me is my FRIEND" echo "$liking_me is my FRIEND"
mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me
# REFRESH & PUBLISH stars friends map # REFRESH & PUBLISH stars friends map
stars="$(cat /tmp/Gstars.json | jq -r '.yours.level')" stars="$(cat /tmp/Gstars.json | jq -r '.yours.level')"
[[ "$stars" == "null" ]] && rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me && echo "$friend_of_mine NO STAR !! Removing $liking_me" && continue ## REMOVE NO GOOD FRIENDS (no star) [[ "$stars" == "null" ]] && rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me && echo "$friend_of_mine NO STAR !! Removing $liking_me" && continue ## REMOVE NO GOOD FRIENDS (no star)
cp /tmp/Gstars.json ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/ cp /tmp/Gstars.json ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/ && rm -f /tmp/Gstars.json
echo "$stars" > ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/stars.level && echo "***** $stars STARS *****" echo "$stars" > ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/stars.level && echo "***** $stars STARS *****"
# SEND jaklis message if tryme.addr is different from last one # SEND jaklis message if tryme.addr is different from last one
if [[ $(diff ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/tryme.addr 2>&1) ]] if [[ $(diff ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/tryme.addr 2>&1) ]]
then then
echo "I AM $G1PUB" echo "I AM $G1PUB"
echo "Sending IPFSTRYME message to $liking_me" echo "Sending IPFSTRYME message to $liking_me"
if [[ -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ]]; then if [[ -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ]]; then
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
else else
echo 'MISSING ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr' echo 'MISSING ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr'
fi fi
echo "$friend_of_mine" >> /tmp/friend_of_mine echo "$friend_of_mine" >> /tmp/friend_of_mine
else else
echo "tryme.addr MESSAGE ALREADY SENT TO $liking_me" echo "tryme.addr MESSAGE ALREADY SENT TO $liking_me"
fi fi
# MEMORIZE actual tryme.addr # MEMORIZE actual tryme.addr
cp -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/ cp -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/
fi fi
sleep $((1 + RANDOM % 2)) # SLOW DOWN sleep $((1 + RANDOM % 2)) # SLOW DOWN
done done
# REMOVE NOT ANYMORE FRIENDS ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/ # REMOVE NOT ANYMORE FRIENDS ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/

View File

@ -13,8 +13,8 @@ IPFSNODEID=$(ipfs --timeout=5s id -f='<id>\n') && [[ "$IPFSNODEID" == "" ]] && e
# CLEAN "A_my_swarm.txt" and "A_swarm_map.txt" # CLEAN "A_my_swarm.txt" and "A_swarm_map.txt"
if [[ $(cat ~/.zen/A_swarm_map.txt | wc -l) -gt 300 ]]; then if [[ $(cat ~/.zen/A_swarm_map.txt | wc -l) -gt 300 ]]; then
rm -f ~/.zen/A_my_swarm.txt && touch ~/.zen/A_my_swarm.txt rm -f ~/.zen/A_my_swarm.txt && touch ~/.zen/A_my_swarm.txt
rm -f ~/.zen/A_swarm_map.txt && touch ~/.zen/A_swarm_map.txt rm -f ~/.zen/A_swarm_map.txt && touch ~/.zen/A_swarm_map.txt
fi fi
######################################################################## ########################################################################
@ -26,71 +26,71 @@ echo $(date)
######################################################################## ########################################################################
# Let's look for Friends and "IPFS swarm connect" with them # Let's look for Friends and "IPFS swarm connect" with them
######################################################################## ########################################################################
# 1. Get Gchange "liking_me" people list # 1. Get Gchange "liking_me" people list (made by gchange_INIT.sh)
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' > /tmp/liking_me [[ ! -f /tmp/liking_me ]] && ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' > /tmp/liking_me
for liking_me in $(cat /tmp/liking_me); for liking_me in $(cat /tmp/liking_me);
do do
[[ "$liking_me" == "" || "$liking_me" == "$G1PUB" ]] && continue [[ "$liking_me" == "" || "$liking_me" == "$G1PUB" ]] && continue
# DE TOUS CEUX QUI M'AIMENT JE VAIS LIRE LES MESSAGES pour collecter leurs ipfstryme vers ~/.zen/A_swarm_map.txt # DE TOUS CEUX QUI M'AIMENT JE VAIS LIRE LES MESSAGES pour collecter leurs ipfstryme vers ~/.zen/A_swarm_map.txt
# SI JE SUIS LEUR AMI EN RETOUR, je conserve leur ID dans ~/.zen/A_my_swarm.txt # SI JE SUIS LEUR AMI EN RETOUR, je conserve leur ID dans ~/.zen/A_my_swarm.txt
# Check if my like is reverse # Check if my like is reverse
liking_me_count=$((liking_me_count+1)) liking_me_count=$((liking_me_count+1))
echo ">>>>>> CHECKING liking_me n° $liking_me_count : READING 'ipfstryme' message from $liking_me" echo ">>>>>> CHECKING liking_me n° $liking_me_count : READING 'ipfstryme' message from $liking_me"
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content' > /tmp/ipfstryme.$liking_me ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content' > /tmp/ipfstryme.$liking_me
[[ $(cat /tmp/ipfstryme.$liking_me | wc -l) -gt 300 ]] && echo "## THIS NODE IS CONTAMINATED !!" && rm -f /tmp/ipfstryme.$liking_me && continue ## ZOMBIE NODE [[ $(cat /tmp/ipfstryme.$liking_me | wc -l) -gt 300 ]] && echo "## THIS NODE IS CONTAMINATED !!" && rm -f /tmp/ipfstryme.$liking_me && continue ## ZOMBIE NODE
for peerline in $(cat /tmp/ipfstryme.$liking_me); for peerline in $(cat /tmp/ipfstryme.$liking_me);
do do
echo "======================================================" echo "======================================================"
# GET $ipfsnodeid FROM $peerline # GET $ipfsnodeid FROM $peerline
echo "PEERLINE: $peerline" echo "PEERLINE: $peerline"
ipfsnodeid=${peerline##*/} # http://mywiki.wooledge.org/BashFAQ/100 ipfsnodeid=${peerline##*/} # http://mywiki.wooledge.org/BashFAQ/100
[[ "$ipfsnodeid" == "" ]] && continue [[ "$ipfsnodeid" == "" ]] && continue
[[ $(cat ~/.zen/A_my_swarm.txt | grep $ipfsnodeid ) ]] && continue # ALREADY in my SWARM [[ $(cat ~/.zen/A_my_swarm.txt | grep $ipfsnodeid ) ]] && continue # ALREADY in my SWARM
# GET $whoisg1 FROM $peerline # GET $whoisg1 FROM $peerline
## Remove Qm ipfs nodes ## Remove Qm ipfs nodes
[[ ! "${ipfsnodeid:0:2}" == "Qm" ]] && whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) || echo "$ipfsnodeid" >> ~/.zen/A_Qm_swarm.txt && continue [[ ! "${ipfsnodeid:0:2}" == "Qm" ]] && whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) || echo "$ipfsnodeid" >> ~/.zen/A_Qm_swarm.txt && continue
# KEEPING LAST ipfstryme MESSAGES only # KEEPING LAST ipfstryme MESSAGES only
nbmessage=0 nbmessage=0
for messageid in $(~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$whoisg1" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.id') for messageid in $(~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$whoisg1" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.id')
do do
nbmessage=$((nbmessage+1)) nbmessage=$((nbmessage+1))
[ $nbmessage -gt 1 ] && echo "Delete $nbmessage OLD 'ipfstryme' messages from $whoisg1" && ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" delete -i $messageid [ $nbmessage -gt 1 ] && echo "Delete $nbmessage OLD 'ipfstryme' messages from $whoisg1" && ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" delete -i $messageid
sleep 0.5 sleep 0.5
done done
[[ $nbmessage == 0 ]] && echo "NO ipfstryme MESSAGE from $whoisg1" && echo "$ipfsnodeid" >> ~/.zen/A_dead_swarm.txt && continue [[ $nbmessage == 0 ]] && echo "NO ipfstryme MESSAGE from $whoisg1" && echo "$ipfsnodeid" >> ~/.zen/A_dead_swarm.txt && continue
# SEND MESSAGE ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $whoisg1 -t 'Astroport' -m 'Aucun message de ta part https://copylaradio.com'" # SEND MESSAGE ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $whoisg1 -t 'Astroport' -m 'Aucun message de ta part https://copylaradio.com'"
# REFRESH A_swarm_map.txt # REFRESH A_swarm_map.txt
echo $peerline >> ~/.zen/A_swarm_map.txt echo $peerline >> ~/.zen/A_swarm_map.txt
cat ~/.zen/A_swarm_map.txt | sort | uniq > /tmp/A_swarm_map.txt cat ~/.zen/A_swarm_map.txt | sort | uniq > /tmp/A_swarm_map.txt
cp -f /tmp/A_swarm_map.txt ~/.zen/A_swarm_map.txt cp -f /tmp/A_swarm_map.txt ~/.zen/A_swarm_map.txt
# FRIEND ADDRESS DISCOVERY # FRIEND ADDRESS DISCOVERY
echo "Am I friend with my FRIEND friend $whoisg1 ?" echo "Am I friend with my FRIEND friend $whoisg1 ?"
friend_of_mine=$(~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $whoisg1 | jq -r '.yours.pseudo'); # must contains my XZUID friend_of_mine=$(~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars -p $whoisg1 | jq -r '.yours.pseudo'); # must contains my XZUID
if [[ "$friend_of_mine" != "null" ]]; then if [[ "$friend_of_mine" != "null" ]]; then
if [[ ! $(grep "$ipfsnodeid" ~/.zen/A_my_swarm.txt) ]] if [[ ! $(grep "$ipfsnodeid" ~/.zen/A_my_swarm.txt) ]]
then then
echo "OK FRIEND" echo "OK FRIEND"
# COUNT UNIQ FRIENDS # COUNT UNIQ FRIENDS
friend_of_mine_count=$((friend_of_mine_count+1)) friend_of_mine_count=$((friend_of_mine_count+1))
echo "$peerline" >> ~/.zen/A_my_swarm.txt echo "$peerline" >> ~/.zen/A_my_swarm.txt
ipfs bootstrap add "$peerline" ipfs bootstrap add "$peerline"
else else
echo "ALREADY RECORDED FRIEND" echo "ALREADY RECORDED FRIEND"
fi fi
else else
echo "NOT FULL FRIEND $ipfsnodeid / $whoisg1" echo "NOT FULL FRIEND $ipfsnodeid / $whoisg1"
[[ "$liking_me" != "" ]] && rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me [[ "$liking_me" != "" ]] && rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me
# SEND ME A MESSAGE TO DECIDE WHAT TO DO ? # SEND ME A MESSAGE TO DECIDE WHAT TO DO ?
# SEND MESSAGE ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $whoisg1 -t 'Astroport' -m 'Rejoins mon #Swarm0 https://copylaradio.com'" # SEND MESSAGE ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $whoisg1 -t 'Astroport' -m 'Rejoins mon #Swarm0 https://copylaradio.com'"
fi fi
done; done;
echo "__________________________________________" echo "__________________________________________"
done done
@ -120,21 +120,21 @@ ipfs bootstrap > /tmp/ipfs_bootstrap
[[ $(cat /tmp/ipfs_bootstrap | wc -l) -lt 2 ]] && ipfs bootstrap rm --all [[ $(cat /tmp/ipfs_bootstrap | wc -l) -lt 2 ]] && ipfs bootstrap rm --all
for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments
do do
ipfsnodeid=${bootnode##*/} ipfsnodeid=${bootnode##*/}
[[ "$ipfsnodeid" != "$IPFSNODEID" ]] && sleep 20 ## RALENTIR DEMARRAGE STATIONS NON BOOTSTRAP [[ "$ipfsnodeid" != "$IPFSNODEID" ]] && sleep 20 ## RALENTIR DEMARRAGE STATIONS NON BOOTSTRAP
## ADD $bootnode TO BOOTSTRAP ## ADD $bootnode TO BOOTSTRAP
ipfs bootstrap add $bootnode ipfs bootstrap add $bootnode
echo "$bootnode" >> ~/.zen/A_my_swarm.txt echo "$bootnode" >> ~/.zen/A_my_swarm.txt
done done
## RECONNECT WITH FRIENDS ## RECONNECT WITH FRIENDS
for g1id in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS); for g1id in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS);
do do
if [[ -d ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/$g1id ]]; then if [[ -d ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/$g1id ]]; then
ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1id) ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1id)
ipfs swarm connect /ipfs/$ipfsnodeid ipfs swarm connect /ipfs/$ipfsnodeid
[[ $? == 0 ]] && ipfs swarm peers | grep $ipfsnodeid | tail -n 1 >> ~/.zen/A_my_swarm.txt [[ $? == 0 ]] && ipfs swarm peers | grep $ipfsnodeid | tail -n 1 >> ~/.zen/A_my_swarm.txt
fi fi
done done
# UNIQ file # UNIQ file
cat ~/.zen/A_my_swarm.txt | sort | uniq > /tmp/A_my_swarm.txt cat ~/.zen/A_my_swarm.txt | sort | uniq > /tmp/A_my_swarm.txt

View File

@ -50,17 +50,17 @@ ipfs swarm peers >> /tmp/ipfs_swarm_peers
for ipfsnodeid in $( (cat /tmp/ipfs_swarm_peers | grep -o '[^/]*$' && cat /tmp/A_swarm | grep -o '[^/]*$' ) | sort | uniq); for ipfsnodeid in $( (cat /tmp/ipfs_swarm_peers | grep -o '[^/]*$' && cat /tmp/A_swarm | grep -o '[^/]*$' ) | sort | uniq);
do do
## $ipfsnodeid already Treated ? ## $ipfsnodeid already Treated ?
[[ "$ipfsnodeid" == "$IPFSNODEID" ]] && continue [[ "$ipfsnodeid" == "$IPFSNODEID" ]] && continue
[[ -f ~/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && XID=$(cat ~/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid) || XID='' [[ -f ~/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid ]] && XID=$(cat ~/.zen/ipfs_swarm/.$ipfsnodeid/_xbian.zuid) || XID=''
[[ -f ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title ]] && XZUID=$(cat ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title) || XZUID='' [[ -f ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title ]] && XZUID=$(cat ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title) || XZUID=''
[[ "$XID" == "" ]] && ipfs swarm disconnect /ipfs/$ipfsnodeid ## NOT COMPLIANT STATION [[ "$XID" == "" ]] && ipfs swarm disconnect /ipfs/$ipfsnodeid ## NOT COMPLIANT STATION
# [[ $(cat /tmp/treated.ipfs.swarm | grep "$ipfsnodeid") ]] && continue # [[ $(cat /tmp/treated.ipfs.swarm | grep "$ipfsnodeid") ]] && continue
[[ $(cat ~/.zen/A_dead_swarm.txt | grep "$ipfsnodeid") ]] && continue [[ $(cat ~/.zen/A_dead_swarm.txt | grep "$ipfsnodeid") ]] && continue
# control ip isLAN? # control ip isLAN?
peerline=$(cat ~/.zen/A_swarm_map.txt | grep "$ipfsnodeid" | head -n 1) peerline=$(cat ~/.zen/A_swarm_map.txt | grep "$ipfsnodeid" | head -n 1)
[[ ! $peerline ]] && peerline=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | head -n 1) [[ ! $peerline ]] && peerline=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | head -n 1)
ip=$(cat ~/.zen/A_swarm_map.txt | grep "$ipfsnodeid" | awk -F '/' '{print $3}' | head -n 1) ip=$(cat ~/.zen/A_swarm_map.txt | grep "$ipfsnodeid" | awk -F '/' '{print $3}' | head -n 1)
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])/") 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])/")
@ -69,85 +69,85 @@ do
# Convert ipfsnodeid into g1pub # Convert ipfsnodeid into g1pub
[[ ! "${ipfsnodeid:0:2}" == "Qm" ]] && whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) || echo "$ipfsnodeid" >> ~/.zen/A_dead_swarm.txt [[ ! "${ipfsnodeid:0:2}" == "Qm" ]] && whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) || echo "$ipfsnodeid" >> ~/.zen/A_dead_swarm.txt
echo "#############################################################" echo "#############################################################"
echo "### ANALYZING $ipfsnodeid ($ip) $XID $XZUID ###" echo "### ANALYZING $ipfsnodeid ($ip) $XID $XZUID ###"
echo "$peerline" echo "$peerline"
myfriendpeer=$(cat ~/.zen/A_my_swarm.txt | grep $ipfsnodeid ) myfriendpeer=$(cat ~/.zen/A_my_swarm.txt | grep $ipfsnodeid )
if [[ "$myfriendpeer" != "" ]]; then if [[ "$myfriendpeer" != "" ]]; then
if [[ ! $(cat /tmp/ipfs_swarm_peers | grep $ipfsnodeid) ]]; then if [[ ! $(cat /tmp/ipfs_swarm_peers | grep $ipfsnodeid) ]]; then
ipfs swarm connect "$peerline" ipfs swarm connect "$peerline"
if [ $? != 0 ]; then if [ $? != 0 ]; then
grep -vEi $ip ~/.zen/A_my_swarm.txt grep -vEi $ip ~/.zen/A_my_swarm.txt
echo $ipfsnodeid >> ~/.zen/A_dead_swarm.txt echo $ipfsnodeid >> ~/.zen/A_dead_swarm.txt
echo "SEND MESSAGE ABOUT UNREACHABLE FRIEND $whoisg1 ($XID) ($XZUID)" echo "SEND MESSAGE ABOUT UNREACHABLE FRIEND $whoisg1 ($XID) ($XZUID)"
~/.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) ($XZUID)" ~/.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) ($XZUID)"
# KEEPING LAST 10 ALERT MESSAGES # KEEPING LAST 10 ALERT MESSAGES
nbmessage=0 nbmessage=0
for messageid in $(~/.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') for messageid in $(~/.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 do
nbmessage=$((nbmessage+1)) nbmessage=$((nbmessage+1))
[ $nbmessage -gt 10 ] && echo "Delete $nbmessage OLD 'ALERT' messages from $G1PUB" && ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" delete -i $messageid && sleep 0.5 [ $nbmessage -gt 10 ] && echo "Delete $nbmessage OLD 'ALERT' messages from $G1PUB" && ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" delete -i $messageid && sleep 0.5
done done
continue continue
fi fi
fi fi
## Add to bootstrap if XID exists ## Add to bootstrap if XID exists
[[ "$XID" != "" ]] && ipfs bootstrap add "$peerline" || ipfs bootstrap rm "$peerline" [[ "$XID" != "" ]] && ipfs bootstrap add "$peerline" || ipfs bootstrap rm "$peerline"
echo "OK Friend REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/" echo "OK Friend REFRESH /ipns/$ipfsnodeid INTO ~/.zen/ipfs_swarm/"
$MY_PATH/tools/timeout.sh -t 12 ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid $MY_PATH/tools/timeout.sh -t 12 ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$ipfsnodeid
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "TIMEOUT REACHED ___ REMOVE $ipfsnodeid FROM ~/.zen/A_my_swarm.txt"; echo "TIMEOUT REACHED ___ REMOVE $ipfsnodeid FROM ~/.zen/A_my_swarm.txt";
else else
################################################################ ################################################################
## REFRESH stargates keys from my friend ## REFRESH stargates keys from my friend
################################################################ ################################################################
mkdir -p ~/.zen/key/stargates/$whoisg1 mkdir -p ~/.zen/key/stargates/$whoisg1
ipfs get --output=$HOME/.zen/key/stargates/$whoisg1/ /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/ ipfs get --output=$HOME/.zen/key/stargates/$whoisg1/ /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/
## DECRYPT ## DECRYPT
[[ -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/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/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/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/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" [[ -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"
fi fi
else else
[[ -f ~/.zen/DEFCON ]] && export DEFCON=$(cat ~/.zen/DEFCON) || export DEFCON=$(cat ~/.zen/astrXbian/DEFCON) # like in crom_MINUTE.sh [[ -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 " echo "!!! UNKNOWN FRIEND !!! $ip ___ $ipfsnodeid ________ # DEFCON : $DEFCON "
[[ -d ~/.zen/ipfs_swarm/.$ipfsnodeid ]] && rm -Rf ~/.zen/ipfs_swarm/.$ipfsnodeid [[ -d ~/.zen/ipfs_swarm/.$ipfsnodeid ]] && rm -Rf ~/.zen/ipfs_swarm/.$ipfsnodeid
ip=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | awk -F '/' '{print $3}' | head -n 1) ip=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | awk -F '/' '{print $3}' | head -n 1)
[[ $ip ]] && anybodyelseipfsid=$(cat /tmp/ipfs_swarm_peers | grep "$ip" | grep -Ev "$ipfsnodeid" | head -n 1 | rev | cut -d '/' -f 1 | rev ) [[ $ip ]] && anybodyelseipfsid=$(cat /tmp/ipfs_swarm_peers | grep "$ip" | grep -Ev "$ipfsnodeid" | head -n 1 | rev | cut -d '/' -f 1 | rev )
[[ $anybodyelseipfsid ]] && isanybodyelseipmyfriend=$(cat ~/.zen/A_my_swarm.txt | grep $anybodyelseipfsid) ## AVOID BANNING IP IF A FRIEND IS IN SAME LAN PUBLIC IP [[ $anybodyelseipfsid ]] && isanybodyelseipmyfriend=$(cat ~/.zen/A_my_swarm.txt | grep $anybodyelseipfsid) ## AVOID BANNING IP IF A FRIEND IS IN SAME LAN PUBLIC IP
[[ $isanybodyelseipmyfriend ]] && echo "TODO: SEND MESSAGE TO $isanybodyelseipmyfriend WARNING ABOUT $ipfsnodeid SAME SEEN IP $ip" [[ $isanybodyelseipmyfriend ]] && echo "TODO: SEND MESSAGE TO $isanybodyelseipmyfriend WARNING ABOUT $ipfsnodeid SAME SEEN IP $ip"
if [[ $ip && ! $isanybodyelseipmyfriend && ( $DEFCON < 5 ) && ! $isLAN ]] if [[ $ip && ! $isanybodyelseipmyfriend && ( $DEFCON < 5 ) && ! $isLAN ]]
then then
## DEFCON 4 ## DEFCON 4
### SECURITY CHOICE TO MAKE IN /etc/sudoers ### ### SECURITY CHOICE TO MAKE IN /etc/sudoers ###
# $USER ALL=(ALL:ALL) NOPASSWD:ALL # $USER ALL=(ALL:ALL) NOPASSWD:ALL
# $USER ALL=(ALL:ALL) NOPASSWD:/usr/bin/fail2ban-client # $USER ALL=(ALL:ALL) NOPASSWD:/usr/bin/fail2ban-client
sudo fail2ban-client add recidive 2>/dev/null 1>&2 sudo fail2ban-client add recidive 2>/dev/null 1>&2
sudo fail2ban-client start recidive sudo fail2ban-client start recidive
sudo fail2ban-client set recidive bantime 3600 # 1 Hour bantime sudo fail2ban-client set recidive bantime 3600 # 1 Hour bantime
sudo fail2ban-client set recidive banip $ip sudo fail2ban-client set recidive banip $ip
# Show ALL banned IP # Show ALL banned IP
sudo fail2ban-client status recidive sudo fail2ban-client status recidive
## DEFCON 3 ## DEFCON 3
# ACTIVATE PRIVATE SMARM !! BOOTSRAP OASIS creates and send a key to everyfriend he knows (PUB) # ACTIVATE PRIVATE SMARM !! BOOTSRAP OASIS creates and send a key to everyfriend he knows (PUB)
## DEFCON 2 ## DEFCON 2
# nmap NOT FRIEND # nmap NOT FRIEND
## DEFCON 1 ## DEFCON 1
# DDOS NOT FRIEND # DDOS NOT FRIEND
fi fi
if [[ ! $isLAN ]]; then if [[ ! $isLAN ]]; then
ipfs swarm disconnect "$peerline" ipfs swarm disconnect "$peerline"
fi fi
ipfs bootstrap rm "$peerline" ipfs bootstrap rm "$peerline"
fi fi
echo "$ipfsnodeid" >> /tmp/treated.ipfs.swarm echo "$ipfsnodeid" >> /tmp/treated.ipfs.swarm
done done
######################################################################## ########################################################################
@ -160,8 +160,8 @@ AXID=$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid);
for PREFIX in F S A Y for PREFIX in F S A Y
do do
echo "CAT;TMDB;YEAR;TITLE;SAISON;GENRES;GROUPES;RES;URLS=http://127.0.0.1:8181" > ~/.zen/ipfs/.${IPFSNODEID}/${PREFIX}ASTRXBIAN 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 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 done
# Remove old database # Remove old database
# rm ~/.kodi/userdata/addon_data/plugin.video.vstream/astroport_cache.db # rm ~/.kodi/userdata/addon_data/plugin.video.vstream/astroport_cache.db
@ -173,9 +173,9 @@ echo "******************************************************************"
echo "### PUBLISH tiddlywiki WALL OF FRIENDS ###" echo "### PUBLISH tiddlywiki WALL OF FRIENDS ###"
echo "<html><body>" > ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/index.html echo "<html><body>" > ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/index.html
for wiki in $(ls ~/.zen/ipfs_swarm/.12D*/index.html 2>/dev/null); do for wiki in $(ls ~/.zen/ipfs_swarm/.12D*/index.html 2>/dev/null); do
ipfsnodeid=$(echo $wiki | cut -d '.' -f 3- | cut -d '/' -f 1) ipfsnodeid=$(echo $wiki | cut -d '.' -f 3- | cut -d '/' -f 1)
whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid)
echo "<iframe id=\"$ipfsnodeid\" echo "<iframe id=\"$ipfsnodeid\"
title='tiddlywiki $whoisg1' title='tiddlywiki $whoisg1'
width='600' width='600'