diff --git a/ISOconfig.sh b/ISOconfig.sh index d3ddea4..c7e703c 100755 --- a/ISOconfig.sh +++ b/ISOconfig.sh @@ -31,14 +31,14 @@ mkdir -p ~/.zen/astrXbian && cd ~/.zen/astrXbian && git pull || exit 1 # CHECK IF CONFIG ALREADY DONE !! # ~/.zen/ipfs ~/.zen/secret ~/.zen/ipfs.sync if [[ -f ~/.zen/ipfs.sync ]]; then - echo "CONFIG ALREADY DONE.... logging init in /tmp/A_booting_log.txt" - source ~/.zen/ipfs.sync - # Wait for IPFS to connect SWARM - sleep 20 - ~/.zen/astrXbian/zen/gchange_INIT.sh >> /tmp/A_booting_log.txt - sleep 10 - ~/.zen/astrXbian/zen/gchange_IPFS_swarm.sh >> /tmp/A_booting_log.txt - exit 0 + echo "CONFIG ALREADY DONE.... logging init in /tmp/A_booting_log.txt" + source ~/.zen/ipfs.sync + # Wait for IPFS to connect SWARM + sleep 20 + ~/.zen/astrXbian/zen/gchange_INIT.sh >> /tmp/A_booting_log.txt + sleep 10 + ~/.zen/astrXbian/zen/gchange_IPFS_swarm.sh >> /tmp/A_booting_log.txt + exit 0 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 do if [[ $bootnode != "" ]]; then - ipfsnodeid=${bootnode##*/} - g1node=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) - 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 - ### DELETE - # ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" unstars -p $g1node + ipfsnodeid=${bootnode##*/} + g1node=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) + 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 + ### DELETE + # ~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" unstars -p $g1node fi 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 do if [[ $bootnode != "" ]]; then - ipfsnodeid=${bootnode##*/} - g1node=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) - echo "SENDING ipfstryme to BOOTSTRAP node : $g1node" - 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 + ipfsnodeid=${bootnode##*/} + g1node=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) + echo "SENDING ipfstryme to BOOTSTRAP node : $g1node" + 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 fi done @@ -281,8 +281,8 @@ ipfs config --json Experimental.P2pHttpProxy true ipfs bootstrap rm --all for bootnode in $(cat ~/.zen/astrXbian/A_boostrap_nodes.txt | grep -Ev "#") # remove comments do - ## ADD $bootnode TO BOOTSTRAP - ipfs bootstrap add $bootnode + ## ADD $bootnode TO BOOTSTRAP + ipfs bootstrap add $bootnode done # AVOID CONFLICT WITH KODI REMOTE diff --git a/cron_MINUTE.sh b/cron_MINUTE.sh index 2828159..1137b63 100755 --- a/cron_MINUTE.sh +++ b/cron_MINUTE.sh @@ -66,20 +66,20 @@ weeknumber=$(date +%V) # WAKEUP TIME 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 - source /tmp/A_Station_ON - old=$ontimebar - new=$timebar - # feeding variables by using read and splitting with IFS - IFS=: read old_hour old_min <<< "$old" - IFS=: read hour min <<< "$new" - # convert hours to minutes - # the 10# is there to avoid errors with leading zeros - # by telling bash that we use base 10 - total_old_minutes=$((10#$old_hour*60 + 10#$old_min)) - total_minutes=$((10#$hour*60 + 10#$min)) - runtime=$((total_minutes - total_old_minutes)) + source /tmp/A_Station_ON + old=$ontimebar + new=$timebar + # feeding variables by using read and splitting with IFS + IFS=: read old_hour old_min <<< "$old" + IFS=: read hour min <<< "$new" + # convert hours to minutes + # the 10# is there to avoid errors with leading zeros + # by telling bash that we use base 10 + total_old_minutes=$((10#$old_hour*60 + 10#$old_min)) + total_minutes=$((10#$hour*60 + 10#$min)) + runtime=$((total_minutes - total_old_minutes)) fi # RUN TIME $runtime @@ -109,36 +109,36 @@ if [[ $(($minute % 15)) == 0 ]]; then git pull [[ ! $? == 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 -# 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" -# fi +# 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" +# fi - # CLEAN AND REMOVE BAD DIRECTORIES - [[ -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_swarm/astroport ]] && rm -Rf ~/.zen/ipfs_swarm/astroport - [[ -d ~/.zen/ipfs/xbian ]] && rm -Rf ~/.zen/ipfs/xbian - [[ -d ~/.zen/ipfs_swarm/xbian ]] && rm -Rf ~/.zen/ipfs_swarm/xbian - [[ -d ~/.zen/ipfs/PIN ]] && rm -Rf ~/.zen/ipfs/PIN - [[ -d ~/.zen/ipfs_swarm/PIN ]] && rm -Rf ~/.zen/ipfs_swarm/PIN - ## CLEANING OLD BAD FILES - rm ~/.zen/ipfs/* - rm ~/.zen/ipfs/.* - rm ~/.zen/ipfs_swarm/* - rm ~/.zen/ipfs_swarm/.* - - [[ -f /tmp/ipfsindex.html ]] && mv /tmp/ipfsindex.html ~/.zen/ipfs/index.html + # CLEAN AND REMOVE BAD DIRECTORIES + [[ -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_swarm/astroport ]] && rm -Rf ~/.zen/ipfs_swarm/astroport + [[ -d ~/.zen/ipfs/xbian ]] && rm -Rf ~/.zen/ipfs/xbian + [[ -d ~/.zen/ipfs_swarm/xbian ]] && rm -Rf ~/.zen/ipfs_swarm/xbian + [[ -d ~/.zen/ipfs/PIN ]] && rm -Rf ~/.zen/ipfs/PIN + [[ -d ~/.zen/ipfs_swarm/PIN ]] && rm -Rf ~/.zen/ipfs_swarm/PIN + ## CLEANING OLD BAD FILES + rm ~/.zen/ipfs/* + rm ~/.zen/ipfs/.* + rm ~/.zen/ipfs_swarm/* + rm ~/.zen/ipfs_swarm/.* + + [[ -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) - if [[ ! $isIPFSRunning ]]; then - [[ -f /etc/sudoers.d/systemctl && -f ~/.zen/ipfs/.$IPFSNODEID/.switch ]] && sudo systemctl restart ipfs - echo "ERROR! ipfs daemon is not running. EXIT" - exit 1 - fi - + isIPFSRunning=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1) + if [[ ! $isIPFSRunning ]]; then + [[ -f /etc/sudoers.d/systemctl && -f ~/.zen/ipfs/.$IPFSNODEID/.switch ]] && sudo systemctl restart ipfs + echo "ERROR! ipfs daemon is not running. EXIT" + exit 1 + fi + ########## 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 # CLOSE-SSH + # [[ "$(ipfs p2p ls | grep $G1PUB-ssh)" != "" ]] && sleep $((1 + RANDOM % 10)) && ~/.zen/astrXbian/zen/ssh_forward2onelove.sh # CLOSE-SSH fi # __ __ _____ ____ @@ -166,13 +166,13 @@ fi # 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 if [[ "$USER" == "xbian" ]]; then - [[ ! -e /home/$USER/astroport ]] && mkdir -p /home/$USER/astroport - # 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) - if [[ "$inotifywaitRunning" != "xbian" ]] - 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 & - fi + [[ ! -e /home/$USER/astroport ]] && mkdir -p /home/$USER/astroport + # 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) + if [[ "$inotifywaitRunning" != "xbian" ]] + 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 & + fi fi ########################################################## @@ -190,13 +190,13 @@ if [[ "$timebar" == "12:12" || "$timebar" == "00:12" || $(($runtime % 720)) == 0 # Restarting IPFS daemon [[ -f /etc/sudoers.d/systemctl || "$USER" == "xbian" ]] && sudo systemctl restart ipfs - #### timebar DESYNC + #### timebar DESYNC sleep $((1 + RANDOM % 5)) - #### Refresh & publish MEDIAKEYs - $MY_PATH/zen/ipns_TAG_refresh.sh - - ## REINIT dead swarm + #### Refresh & publish MEDIAKEYs + $MY_PATH/zen/ipns_TAG_refresh.sh + + ## REINIT dead swarm rm -f ~/.zen/A_dead_swarm.txt fi @@ -215,64 +215,64 @@ echo ' # # 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 !! ### PEACE & LOVE software is processing... We are HyperWeb people here. # DEFCON 5 quiet behaviour so Please keep cool, take care and be zen. # GOOD BYE GOOGLE, AMAZON, FACEBOOK, APPLE, MICROSOFT. LIBRE WE ARE. - #################################################################### + #################################################################### # REFRESH & UPGRADE youtube-dl - youtube-dl --rm-cache-dir - youtube-dl -U + youtube-dl --rm-cache-dir + youtube-dl -U - ################################################################## + ################################################################## if [[ $dayoftheweek == 1 ]]; then - # EVERY MONDAY - # _____ __ __ ___ - # / ___// /_____ _________ _____ ____ / |/ /___ __ __ - # \__ \/ __/ __ \/ ___/ __ `/ __ `/ _ \ / /|_/ / __ `/ |/_/ - # ___/ / /_/ /_/ / / / /_/ / /_/ / __/ / / / / /_/ /> < - # /____/\__/\____/_/ \__,_/\__, /\___/ /_/ /_/\__,_/_/|_| - # /____/ - # 1/2 HDD for IPFS size - dicotomic adaptation 7th EVERY MONTH - availableDiskSize=$(df -P ~/ | awk 'NR>1{sum+=$4}END{print sum}') - availableDiskSize="$(($availableDiskSize * 1024))" + # EVERY MONDAY + # _____ __ __ ___ + # / ___// /_____ _________ _____ ____ / |/ /___ __ __ + # \__ \/ __/ __ \/ ___/ __ `/ __ `/ _ \ / /|_/ / __ `/ |/_/ + # ___/ / /_/ /_/ / / / /_/ / /_/ / __/ / / / / /_/ /> < + # /____/\__/\____/_/ \__,_/\__, /\___/ /_/ /_/\__,_/_/|_| + # /____/ + # 1/2 HDD for IPFS size - dicotomic adaptation 7th EVERY MONTH + availableDiskSize=$(df -P ~/ | awk 'NR>1{sum+=$4}END{print sum}') + availableDiskSize="$(($availableDiskSize * 1024))" - diskSize="$((availableDiskSize / 2))" - ipfs config Datastore.StorageMax $diskSize - echo "StorageMax = $diskSize" - - # New full test review in gchange_INIT.sh + diskSize="$((availableDiskSize / 2))" + ipfs config Datastore.StorageMax $diskSize + echo "StorageMax = $diskSize" + + # New full test review in gchange_INIT.sh rm -f ~/.ipfs/test.disk - # LOG ROTATE - [[ -f /tmp/astroport.log ]] && tar cvzf ~/.zen/astroport.$weeknumber.log.tgz /tmp/astroport.log && echo "" > /tmp/astroport.log - - fi - - ################################################################## - ## CHECK STARTGATE LEVEL KEYS - # _ open _ - # ___| |_ __ _ _ __ __ _ __ _| |_ ___ - #/ __| __/ _` | '__/ _` |/ _` | __/ _ \ - #\__ \ || (_| | | | (_| | (_| | || __/ - #|___/\__\__,_|_| \__, |\__,_|\__\___| - # |___/ - # IPNS KEYS used to publish with star friends (creates 5 levels of streaming / file sharing) - # 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 - rm -Rf ~/.zen/key/ - # RENEW & SEND STARS TO FRIENDS ~/.zen/astrXbian/zen/manage_stargates.sh - $MY_PATH/zen/manage_stargates.sh + # LOG ROTATE + [[ -f /tmp/astroport.log ]] && tar cvzf ~/.zen/astroport.$weeknumber.log.tgz /tmp/astroport.log && echo "" > /tmp/astroport.log + + fi + + ################################################################## + ## CHECK STARTGATE LEVEL KEYS + # _ open _ + # ___| |_ __ _ _ __ __ _ __ _| |_ ___ + #/ __| __/ _` | '__/ _` |/ _` | __/ _ \ + #\__ \ || (_| | | | (_| | (_| | || __/ + #|___/\__\__,_|_| \__, |\__,_|\__\___| + # |___/ + # IPNS KEYS used to publish with star friends (creates 5 levels of streaming / file sharing) + # 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 + rm -Rf ~/.zen/key/ + # RENEW & SEND STARS TO FRIENDS ~/.zen/astrXbian/zen/manage_stargates.sh + $MY_PATH/zen/manage_stargates.sh fi ### DISAPEAR ONE HOUR FROM IPFS SWARM ZOMBIES > 300 peers in swarm if [[ $(cat /tmp/ipfs_swarm_peers | wc -l) -gt 300 ]]; then if [[ "$timebar" == "04:05" ]]; then - ~/.zen/astrXbian/zen/ipfs_SWARM_renew.sh 3600 ## CUT IPFS FOR ONE HOUR - ## SWITCHING ON - echo "1" > ~/.zen/ipfs/.$IPFSNODEID/.switch + ~/.zen/astrXbian/zen/ipfs_SWARM_renew.sh 3600 ## CUT IPFS FOR ONE HOUR + ## SWITCHING ON + echo "1" > ~/.zen/ipfs/.$IPFSNODEID/.switch fi fi diff --git a/install.sh b/install.sh index 019061c..5eeea4b 100755 --- a/install.sh +++ b/install.sh @@ -59,18 +59,18 @@ echo "Sécurisation DEFCON SUDOERS FAIL2BAN" if [[ "$USER" == "xbian" ]] then - echo "enabling ipfs initV service autostart" - cd /etc/rc2.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/rc5.d && sudo ln -s ../init.d/ipfs S02ipfs + echo "enabling ipfs initV service autostart" + cd /etc/rc2.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/rc5.d && sudo ln -s ../init.d/ipfs S02ipfs - cd /etc/rc0.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 - - # Disable xbian-config auto launch - echo 0 > ~/.xbian-config-start + cd /etc/rc0.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 + + # Disable xbian-config auto launch + echo 0 > ~/.xbian-config-start fi @@ -82,23 +82,23 @@ mkdir -p ~/astroport/anime if [[ "$USER" != "xbian" ]] then - ## Desktop install - echo "INITIALISATIOn Astroport/KODI" - 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" - read - ~/.zen/astrXbian/ISOconfig.sh + ## Desktop install + echo "INITIALISATIOn Astroport/KODI" + 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" + read + ~/.zen/astrXbian/ISOconfig.sh else - ## Rpi Xbian install. - cat /etc/rc.local | grep -Ev "exit 0" > /tmp/new.rc.local ## REMOVE "exit 0" - # PREPARE NEXT BOOT - Network config - NEXTBOOT - ISOConfig - NEXTBOOT - OK - echo "su - xbian -c '~/.zen/astrXbian/FirstBOOT.sh'" >> /tmp/new.rc.local - echo "exit 0" >> /tmp/new.rc.local - sudo cp -f /tmp/new.rc.local /etc/rc.local + ## Rpi Xbian install. + cat /etc/rc.local | grep -Ev "exit 0" > /tmp/new.rc.local ## REMOVE "exit 0" + # PREPARE NEXT BOOT - Network config - NEXTBOOT - ISOConfig - NEXTBOOT - OK + echo "su - xbian -c '~/.zen/astrXbian/FirstBOOT.sh'" >> /tmp/new.rc.local + echo "exit 0" >> /tmp/new.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 "Faites une ISO : sudo xbian-config" - exit 0 + echo "STOP!! Redémarrer Xbian pour continuer la configuration de votre station Astroport/KODI" + echo "Faites une ISO : sudo xbian-config" + exit 0 fi # MAIN # -f ~/.zen/secret.june (ISOConfig déjà lancé) ## diff --git a/zen/gchange_INIT.sh b/zen/gchange_INIT.sh index 7f961bf..27c5da9 100755 --- a/zen/gchange_INIT.sh +++ b/zen/gchange_INIT.sh @@ -78,22 +78,22 @@ export LANG=C.UTF-8 #attipix ######################################################################## # NODE DISK PERFORMANCE, manual remove ~/.ipfs/test.disk to run again 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) - echo "DISK PERFORMANCE TESTING : $diskperf" - # NODE disk.perf - echo "$diskperf" > ~/.zen/ipfs/.${IPFSNODEID}/disk.perf - # NODE disk.bytes - echo $(df ~/.ipfs/ | tail -n 1 | awk '{print $4}') > ~/.zen/ipfs/.${IPFSNODEID}/disk.bytes - # IPFS repo.stat - ipfs repo stat > ~/.zen/ipfs/.${IPFSNODEID}/repo.stat - ########################################### - # GEOLOC MUST BE SECURELY EXCHANGED (TODO) - ########################################### - # CREATE "_g1.gchange_geoPoint.lat" AND "_g1.gchange_geoPoint.lon" - # 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 - # 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 + 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" + # NODE disk.perf + echo "$diskperf" > ~/.zen/ipfs/.${IPFSNODEID}/disk.perf + # NODE disk.bytes + echo $(df ~/.ipfs/ | tail -n 1 | awk '{print $4}') > ~/.zen/ipfs/.${IPFSNODEID}/disk.bytes + # IPFS repo.stat + ipfs repo stat > ~/.zen/ipfs/.${IPFSNODEID}/repo.stat + ########################################### + # GEOLOC MUST BE SECURELY EXCHANGED (TODO) + ########################################### + # CREATE "_g1.gchange_geoPoint.lat" AND "_g1.gchange_geoPoint.lon" + # 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 + # 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 fi ### @@ -118,55 +118,55 @@ rm -f /tmp/friend_of_mine for liking_me in $(cat /tmp/liking_me); do ##### BOOTSTRAP AUTO LIKE BACK (NOT liking Myself) - if [[ "$IamBOOTSTRAP" == "$G1PUB" ]]; then - echo "I AM A BOOTSTRAP AUTO LIKING $liking_me FRIEND" - if [[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/tryme.addr && "$liking_me" != "$G1PUB" ]]; then - 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 - 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 - sleep $((1 + RANDOM % 2)) # SLOW DOWN - fi - fi + if [[ "$IamBOOTSTRAP" == "$G1PUB" ]]; then + echo "I AM A BOOTSTRAP AUTO LIKING $liking_me FRIEND" + if [[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/tryme.addr && "$liking_me" != "$G1PUB" ]]; then + 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 + 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 + sleep $((1 + RANDOM % 2)) # SLOW DOWN + fi + fi ##### 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'); - if [[ "$friend_of_mine" != "null" && "$liking_me" != "$G1PUB" ]] - then - # ADD $liking_me TO MY ipfs FRIENDS list - echo "$liking_me is my FRIEND" - mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me + if [[ "$friend_of_mine" != "null" && "$liking_me" != "$G1PUB" ]] + then + # ADD $liking_me TO MY ipfs FRIENDS list + echo "$liking_me is my FRIEND" + mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me - # REFRESH & PUBLISH stars friends map - 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) - cp /tmp/Gstars.json ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/ - echo "$stars" > ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/stars.level && echo "***** $stars STARS *****" + # REFRESH & PUBLISH stars friends map + 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) + 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 *****" - # 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) ]] - then - echo "I AM $G1PUB" - echo "Sending IPFSTRYME message to $liking_me" - 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 - else - echo 'MISSING ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr' - fi - echo "$friend_of_mine" >> /tmp/friend_of_mine - else - echo "tryme.addr MESSAGE ALREADY SENT TO $liking_me" - fi - # MEMORIZE actual tryme.addr - cp -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/ - fi + # 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) ]] + then + echo "I AM $G1PUB" + echo "Sending IPFSTRYME message to $liking_me" + 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 + else + echo 'MISSING ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr' + fi + echo "$friend_of_mine" >> /tmp/friend_of_mine + else + echo "tryme.addr MESSAGE ALREADY SENT TO $liking_me" + fi + # MEMORIZE actual tryme.addr + cp -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/ + fi - sleep $((1 + RANDOM % 2)) # SLOW DOWN + sleep $((1 + RANDOM % 2)) # SLOW DOWN done # REMOVE NOT ANYMORE FRIENDS ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me/ diff --git a/zen/gchange_IPFS_swarm.sh b/zen/gchange_IPFS_swarm.sh index ab009c3..be6d02f 100755 --- a/zen/gchange_IPFS_swarm.sh +++ b/zen/gchange_IPFS_swarm.sh @@ -13,8 +13,8 @@ IPFSNODEID=$(ipfs --timeout=5s id -f='\n') && [[ "$IPFSNODEID" == "" ]] && e # CLEAN "A_my_swarm.txt" and "A_swarm_map.txt" 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_swarm_map.txt && touch ~/.zen/A_swarm_map.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 fi ######################################################################## @@ -26,71 +26,71 @@ echo $(date) ######################################################################## # Let's look for Friends and "IPFS swarm connect" with them ######################################################################## -# 1. Get Gchange "liking_me" people list -~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' > /tmp/liking_me +# 1. Get Gchange "liking_me" people list (made by gchange_INIT.sh) +[[ ! -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); do - [[ "$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 - # SI JE SUIS LEUR AMI EN RETOUR, je conserve leur ID dans ~/.zen/A_my_swarm.txt - # Check if my like is reverse - liking_me_count=$((liking_me_count+1)) - 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 + [[ "$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 + # SI JE SUIS LEUR AMI EN RETOUR, je conserve leur ID dans ~/.zen/A_my_swarm.txt + # Check if my like is reverse + liking_me_count=$((liking_me_count+1)) + 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 - [[ $(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); + [[ $(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); do - echo "======================================================" - # GET $ipfsnodeid FROM $peerline - echo "PEERLINE: $peerline" + echo "======================================================" + # GET $ipfsnodeid FROM $peerline + echo "PEERLINE: $peerline" ipfsnodeid=${peerline##*/} # http://mywiki.wooledge.org/BashFAQ/100 [[ "$ipfsnodeid" == "" ]] && continue [[ $(cat ~/.zen/A_my_swarm.txt | grep $ipfsnodeid ) ]] && continue # ALREADY in my SWARM - # GET $whoisg1 FROM $peerline - ## Remove Qm ipfs nodes + # GET $whoisg1 FROM $peerline + ## 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 - # KEEPING LAST ipfstryme MESSAGES only - 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') - do - 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 - sleep 0.5 - done - [[ $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'" + # KEEPING LAST ipfstryme MESSAGES only + 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') + do + 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 + sleep 0.5 + done + [[ $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'" - # REFRESH A_swarm_map.txt - echo $peerline >> ~/.zen/A_swarm_map.txt + # REFRESH A_swarm_map.txt + echo $peerline >> ~/.zen/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 - - # FRIEND ADDRESS DISCOVERY + cp -f /tmp/A_swarm_map.txt ~/.zen/A_swarm_map.txt + + # FRIEND ADDRESS DISCOVERY 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 - if [[ "$friend_of_mine" != "null" ]]; then - if [[ ! $(grep "$ipfsnodeid" ~/.zen/A_my_swarm.txt) ]] - then - echo "OK FRIEND" - # COUNT UNIQ FRIENDS - friend_of_mine_count=$((friend_of_mine_count+1)) - echo "$peerline" >> ~/.zen/A_my_swarm.txt - ipfs bootstrap add "$peerline" - else - echo "ALREADY RECORDED FRIEND" - fi - else - echo "NOT FULL FRIEND $ipfsnodeid / $whoisg1" - [[ "$liking_me" != "" ]] && rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me - # 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'" - fi + 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 [[ ! $(grep "$ipfsnodeid" ~/.zen/A_my_swarm.txt) ]] + then + echo "OK FRIEND" + # COUNT UNIQ FRIENDS + friend_of_mine_count=$((friend_of_mine_count+1)) + echo "$peerline" >> ~/.zen/A_my_swarm.txt + ipfs bootstrap add "$peerline" + else + echo "ALREADY RECORDED FRIEND" + fi + else + echo "NOT FULL FRIEND $ipfsnodeid / $whoisg1" + [[ "$liking_me" != "" ]] && rm -Rf ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/$liking_me + # 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'" + fi done; - echo "__________________________________________" + echo "__________________________________________" done @@ -120,21 +120,21 @@ ipfs bootstrap > /tmp/ipfs_bootstrap [[ $(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 do - ipfsnodeid=${bootnode##*/} - [[ "$ipfsnodeid" != "$IPFSNODEID" ]] && sleep 20 ## RALENTIR DEMARRAGE STATIONS NON BOOTSTRAP - ## ADD $bootnode TO BOOTSTRAP - ipfs bootstrap add $bootnode - echo "$bootnode" >> ~/.zen/A_my_swarm.txt + ipfsnodeid=${bootnode##*/} + [[ "$ipfsnodeid" != "$IPFSNODEID" ]] && sleep 20 ## RALENTIR DEMARRAGE STATIONS NON BOOTSTRAP + ## ADD $bootnode TO BOOTSTRAP + ipfs bootstrap add $bootnode + echo "$bootnode" >> ~/.zen/A_my_swarm.txt done ## RECONNECT WITH FRIENDS for g1id in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS); do -if [[ -d ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/$g1id ]]; then -ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1id) -ipfs swarm connect /ipfs/$ipfsnodeid -[[ $? == 0 ]] && ipfs swarm peers | grep $ipfsnodeid | tail -n 1 >> ~/.zen/A_my_swarm.txt -fi + if [[ -d ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/$g1id ]]; then + ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1id) + ipfs swarm connect /ipfs/$ipfsnodeid + [[ $? == 0 ]] && ipfs swarm peers | grep $ipfsnodeid | tail -n 1 >> ~/.zen/A_my_swarm.txt + fi done # UNIQ file cat ~/.zen/A_my_swarm.txt | sort | uniq > /tmp/A_my_swarm.txt diff --git a/zen/ipfs_SWARM_refresh.sh b/zen/ipfs_SWARM_refresh.sh index 85b1bba..b252b82 100755 --- a/zen/ipfs_SWARM_refresh.sh +++ b/zen/ipfs_SWARM_refresh.sh @@ -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); do ## $ipfsnodeid already Treated ? - [[ "$ipfsnodeid" == "$IPFSNODEID" ]] && continue - [[ -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='' - [[ "$XID" == "" ]] && ipfs swarm disconnect /ipfs/$ipfsnodeid ## NOT COMPLIANT STATION - # [[ $(cat /tmp/treated.ipfs.swarm | grep "$ipfsnodeid") ]] && continue - [[ $(cat ~/.zen/A_dead_swarm.txt | grep "$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/G1SSB/_g1.gchange_title ]] && XZUID=$(cat ~/.zen/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.gchange_title) || XZUID='' + [[ "$XID" == "" ]] && ipfs swarm disconnect /ipfs/$ipfsnodeid ## NOT COMPLIANT STATION + # [[ $(cat /tmp/treated.ipfs.swarm | grep "$ipfsnodeid") ]] && continue + [[ $(cat ~/.zen/A_dead_swarm.txt | grep "$ipfsnodeid") ]] && continue - # control ip isLAN? - peerline=$(cat ~/.zen/A_swarm_map.txt | grep "$ipfsnodeid" | head -n 1) - [[ ! $peerline ]] && peerline=$(cat /tmp/ipfs_swarm_peers | grep "$ipfsnodeid" | head -n 1) + # control ip isLAN? + peerline=$(cat ~/.zen/A_swarm_map.txt | 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) 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 [[ ! "${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 "$peerline" - myfriendpeer=$(cat ~/.zen/A_my_swarm.txt | grep $ipfsnodeid ) - if [[ "$myfriendpeer" != "" ]]; then - 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 - 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)" - # KEEPING LAST 10 ALERT MESSAGES - 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') - do - 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 - done - continue - fi - fi - ## Add to bootstrap if XID exists - [[ "$XID" != "" ]] && ipfs bootstrap add "$peerline" || ipfs bootstrap rm "$peerline" - 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 - if [ $? != 0 ]; then - echo "TIMEOUT REACHED ___ REMOVE $ipfsnodeid FROM ~/.zen/A_my_swarm.txt"; - else - ################################################################ - ## REFRESH stargates keys from my friend - ################################################################ - mkdir -p ~/.zen/key/stargates/$whoisg1 - ipfs get --output=$HOME/.zen/key/stargates/$whoisg1/ /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/ - ## 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/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" - fi - else - [[ -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 " - [[ -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 ]] && 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 - [[ $isanybodyelseipmyfriend ]] && echo "TODO: SEND MESSAGE TO $isanybodyelseipmyfriend WARNING ABOUT $ipfsnodeid SAME SEEN IP $ip" - if [[ $ip && ! $isanybodyelseipmyfriend && ( $DEFCON < 5 ) && ! $isLAN ]] - 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 - sudo fail2ban-client set recidive bantime 3600 # 1 Hour bantime + myfriendpeer=$(cat ~/.zen/A_my_swarm.txt | grep $ipfsnodeid ) + if [[ "$myfriendpeer" != "" ]]; then + 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 + 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)" + # KEEPING LAST 10 ALERT MESSAGES + 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') + do + 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 + done + continue + fi + fi + ## Add to bootstrap if XID exists + [[ "$XID" != "" ]] && ipfs bootstrap add "$peerline" || ipfs bootstrap rm "$peerline" + 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 + if [ $? != 0 ]; then + echo "TIMEOUT REACHED ___ REMOVE $ipfsnodeid FROM ~/.zen/A_my_swarm.txt"; + else + ################################################################ + ## REFRESH stargates keys from my friend + ################################################################ + mkdir -p ~/.zen/key/stargates/$whoisg1 + ipfs get --output=$HOME/.zen/key/stargates/$whoisg1/ /ipns/$ipfsnodeid/.$ipfsnodeid/FRIENDS/$G1PUB/ + ## 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/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" + fi + else + [[ -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 " + [[ -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 ]] && 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 + [[ $isanybodyelseipmyfriend ]] && echo "TODO: SEND MESSAGE TO $isanybodyelseipmyfriend WARNING ABOUT $ipfsnodeid SAME SEEN IP $ip" + if [[ $ip && ! $isanybodyelseipmyfriend && ( $DEFCON < 5 ) && ! $isLAN ]] + 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 + sudo fail2ban-client set recidive bantime 3600 # 1 Hour bantime - sudo fail2ban-client set recidive banip $ip - # Show ALL banned IP - sudo fail2ban-client status recidive - - ## DEFCON 3 - # ACTIVATE PRIVATE SMARM !! BOOTSRAP OASIS creates and send a key to everyfriend he knows (PUB) - - ## 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 + sudo fail2ban-client set recidive banip $ip + # Show ALL banned IP + sudo fail2ban-client status recidive + + ## DEFCON 3 + # ACTIVATE PRIVATE SMARM !! BOOTSRAP OASIS creates and send a key to everyfriend he knows (PUB) + + ## 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 ######################################################################## @@ -160,8 +160,8 @@ AXID=$(cat ~/.zen/ipfs/.$IPFSNODEID/_xbian.zuid); for PREFIX in F S A Y 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 + 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 # Remove old database # rm ~/.kodi/userdata/addon_data/plugin.video.vstream/astroport_cache.db @@ -173,9 +173,9 @@ echo "******************************************************************" echo "### PUBLISH tiddlywiki WALL OF FRIENDS ###" echo "" > ~/.zen/ipfs/.${IPFSNODEID}/FRIENDS/index.html 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) - whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) - + ipfsnodeid=$(echo $wiki | cut -d '.' -f 3- | cut -d '/' -f 1) + whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) + echo "