go on Xbian ISOconfig / Vstream /Pastebin IPNS share

This commit is contained in:
qo-op 2020-12-08 01:47:34 +01:00
parent e8c08856a3
commit 418b0a27bb
4 changed files with 89 additions and 111 deletions

View File

@ -16,7 +16,7 @@ SITE_IDENTIFIER = 'astroport'
SITE_NAME = 'ASTROPORT'
SITE_DESC = 'Astroport permet de partager le contenu du répertoire ~/astroport avec tous ses amis https://gchange.fr'
URL_MAIN = 'http://localhost:8080/ipfs/'
URL_MAIN = 'http://localhost:8080/ipns/_IPNSKEY_/xbian/'
KEY_PASTE_ID = 'PASTE_ID'
SETTING_PASTE_ID = 'pastebin_id_'

View File

@ -14,11 +14,17 @@
# ~/.zen/secret.ipfs & /tmp/config.ipfs
# ~/.zen/ipfs.sync
########################################################################
# CHECK IF CONFIG ALREADY DONE !! Remove ~/.zen/ipfs ~/.zen/secret ~/.zen/ipfs.sync
[[ -f ~/.zen/ipfs.sync ]] && echo "CONFIG ALREADY DONE" && source ~/.zen/ipfs.sync && exit 0
# CHECK INTERNET CONNECTIVITY !!
ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null && echo ok || (echo "NO INTERNET CONNEXION" && exit 1)
########################################################################
########################################################################
echo "CREATING Gchange credentials"
########################################################################
salt="$(~/.zen/astroport/zen/tools/diceware.sh 3 | xargs)"
[[ $salt == "" ]] && echo "ERROR" && exit 1
pepper="$(~/.zen/astroport/zen/tools/diceware.sh 3 | xargs)"
@ -32,14 +38,18 @@ echo "$g1_salt" > /tmp/secret.june
echo "$g1_pepper" >> /tmp/secret.june
########################################################################
########################################################################
echo "CREATING /tmp/secret.dunikey"
########################################################################
python3 ~/.zen/astroport/zen/tools/key_create_dunikey.py "$g1_salt" "$g1_pepper"
g1pub=$(cat /tmp/secret.dunikey | grep "pub" | cut -d ' ' -f 2)
g1sec=$(cat /tmp/secret.dunikey | grep "sec" | cut -d ' ' -f 2)
########################################################################
########################################################################
echo "CREATING /tmp/config.ipfs"
########################################################################
ipfs_ID=$(python3 ~/.zen/astroport/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py)
echo $ipfs_ID > /tmp/secret.ipfs && source /tmp/secret.ipfs
[[ $PrivKEY == "" ]] && echo "ERROR" && exit 1
@ -47,11 +57,16 @@ jq -r --arg PeerID "$PeerID" '.Identity.PeerID=$PeerID' ~/.ipfs/config > /tmp/co
jq -r --arg PrivKEY "$PrivKEY" '.Identity.PrivKey=$PrivKEY' /tmp/config.tmp > /tmp/config.ipfs
rm /tmp/config.tmp
#
IPFSNODEID=$PeerID
echo $IPFSNODEID
## Directory transfered to IPFS
IPFS_sync_directory="$HOME/.zen/miam"
## Declare directory transfered in IPFS
IPFS_sync_directory="$HOME/astroport"
########################################################################
# INSTALL KEYS
########################################################################
mv ~/.zen/secret.june ~/.zen/secret.june.old
mv /tmp/secret.june ~/.zen/secret.june
@ -67,32 +82,85 @@ mv /tmp/config.ipfs ~/.ipfs/config
# WRITE ~/.zen/ipfs.sync CONFIG
echo "IPFS_SYNC_DIR=$IPFS_sync_directory" > ~/.zen/ipfs.sync
# CREATE gchange+ profile
cd ~/.zen/astroport/zen/jaklis
./jaklis.py set --name "$(hostname)" --avatar "$HOME/.zen/astroport/logo.png"
########################################################################
# Give $(hostname)-$ZUID to your (gchange friends) to add in Vstream Astroport and access your sharings
# IPNS link to "pastebin list" http://localhost:8080/ipns/$IPNSKEY/xbian/$(hostname)-$ZUID
########################################################################
ZUID=$(~/.zen/astroport/zen/tools/diceware.sh 1 | xargs)$(hostname -I | cut -d ' ' -f 1 | cut -d "." -f 4 )
echo "CREATE ~/.zen/ipfs/xbian/$(hostname)-$ZUID"
touch ~/.zen/ipfs/xbian/$(hostname)-$ZUID # https://github.com/Kodi-vStream/venom-xbmc-addons/wiki/Voir-et-partager-sa-biblioth%C3%A8que-priv%C3%A9e#d%C3%A9clarer-des-films
# BECOME FRIEND with oasis
########################################################################
echo "INIT ~/.zen/ipfs/.${IPFSNODEID}"
########################################################################
mkdir -Rf ~/.zen/ipfs
mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/G1SSB
echo "$(hostname)-$ZUID" > ~/.zen/ipfs/.${IPFSNODEID}/_xbian.zuid
########################################################################
########################################################################
echo "CREATE gchange+ profile"
########################################################################
cd ~/.zen/astroport/zen/jaklis
./jaklis.py set --name "$(hostname)-$ZUID" --avatar "$HOME/.zen/astroport/logo.png"
########################################################################
########################################################################
echo "BECOME FRIEND with oasis (1st bootstrap)"
########################################################################
./jaklis.py like -p 2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS -s 5
echo "Restart IPFS"
########################################################################
echo "RESTART ipfs"
########################################################################
sudo service ipfs restart
echo ".... WAIT for SWARM to connect ..."
sleep 10
ipfs swarm peers
########################################################################
echo 'EXTEND ~/.bashrc'
########################################################################
~/.zen/astroport/.install/update_bashrc.sh
mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/G1SSB
echo "" > ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
echo "Configure .kodi/addons/plugin.video.vstream/resources/sites/astroport.py"
cp -f ~/.zen/.install/.kodi/addons/plugin.video.vstream/resources/sites/astroport.py \
.kodi/addons/plugin.video.vstream/resources/sites/astroport.py
# CREATE xbian IPNSKEY used to publish ~/.zen/ipfs_swarm/xbian (contains all xbian-ZUID pastebin files)
ipfs key rm xbian
IPNSKEY=$(ipfs key gen xbian)
sed -i s/_IPNSKEY_/$IPNSKEY/g .kodi/addons/plugin.video.vstream/resources/sites/astroport.py
# Optionnal PUBLISH actual (later done by cron_MINUTE.sh)
IXBIAN=$(ipfs add -qr ~/.zen/ipfs_swarm/xbian | tail -n 1)
JXBIAN=$(ipfs name publish -k xbian $I)
########################################################################
echo 'SEND "ipfstryme" message'
########################################################################
echo "" > ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr # ERASE
for tryme in $(ipfs id | jq -r .Addresses[]);
do
isLAN=$(echo $tryme | 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 "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr && echo "$tryme"
[[ ! $isLAN && $tryme != "" ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr && echo "$tryme"
done
echo 'SEND ipfstryme to oasis'
echo 'SEND ipfstryme to oasis' # Add your bootstrap Pub here
./jaklis.py send -d 2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
########################################################################
echo 'INSTALL Astroport cron_MINUTE'
########################################################################
~/.zen/astroport/zen/tools/cron_VRFY.sh
# Run only once: comment /etc/rc.local (su - xbian -c "~/.zen/astroport/ISOconfig.sh")
sudo sed -i s/su/\#su/g /etc/rc.local
########################################################################
echo 'REBOOT NOW...'
########################################################################
sudo reboot
exit 0

View File

@ -15,7 +15,7 @@ source $HOME/.profile
[[ ! $(echo $PATH | grep "/usr/games") ]] && export PATH="$PATH:/usr/games"
#### INIT STATION PARAMETERS
[[ -f $MY_PATH/../secret.astroport.key ]] && source $MY_PATH/../secret.astroport.key
[[ -f $MY_PATH/../secret.astroport.key ]] && source $MY_PATH/../secret.astroport.key # DEPRECATED now using ~/.bashrc
export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
source /home/$YOU/.profile
[[ $IPFSNODEID ]] && export IPFSNODEID=$IPFSNODEID || export IPFSNODEID=$(ipfs id -f='<id>\n')
@ -84,12 +84,6 @@ if [[ $(($minute % 5)) == 0 ]]; then
git pull
fi
# __________ ____ __ ________ ___________
# / ___/ ___// __ ) \ \ / _/ __ \/ ____/ ___/
# \__ \\__ \/ __ | _____\ \ / // /_/ / /_ \__ \
# ___/ /__/ / /_/ / /_____/ / _/ // ____/ __/ ___/ /
# /____/____/_____/ /_/ /___/_/ /_/ /____/
#
# __ __ _____ ____
# __/ // /_/ ___/ ______ __________ ___ / __ \
# /_ _ __/\__ \ | /| / / __ `/ ___/ __ `__ \/ / / /
@ -102,7 +96,6 @@ fi
[[ $(($minute % 15)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/ipfs_SWARM_refresh.sh &
## TODO investigate could breaks "ipfs p2p" forwards ?
##################################################################
@ -119,61 +112,6 @@ fi
##################################################################
##################################################################
# __ __ __
# __/ // /_____ ___ ____ __ __/ /__ __
# /_ _ __/_ / / _ \/ __ \/ / / / __/ | / /
# /_ _ __/ / /_/ __/ / / / /_/ / /_ | |/ /
# /_//_/ /___/\___/_/ /_/\__, /\__/ |___/
# /____/
# SSB message 2 "youtube-dl" EXPERIMENTAL
# TODO : Run on BIG STATIONS (Control available Disk Space !!)
##################################################################
# RANDOMLY RUN SSB GET zenytv (avoid simultaneous run in swarm)
randh=$((1 + RANDOM % 24))
if [[ $(($heure % $randh)) == 0 ]]; then
diskMBps=$(dd if=/dev/zero of=~/.zen/test.disk bs=10M count=1 oflag=dsync 2>&1 | tail -n 1 | sed s/\,\ /\ -/g | cut -d '-' -f 4 | cut -d ' ' -f 1 | cut -d '.' -f 1)
diskGiga=$(df -h ~/.ipfs/ | tail -n 1 | awk '{print $4}' | cut -d 'G' -f '1')
echo "GET_zenytv write speed : $diskMBps MB/s"
echo "Disk size : $diskGiga GB"
sleep $((1 + RANDOM % 10))
[[ $diskMBps -gt 15 ]] && [[ $diskGiga -gt 5 ]] && $MY_PATH/zen/ssb_GET_zenytv.sh &
fi
##################################################################
randh=$((1 + RANDOM % 24))
if [[ $(($heure % $randh)) == 0 ]]; then
diskMBps=$(dd if=/dev/zero of=~/.zen/test.disk bs=10M count=1 oflag=dsync 2>&1 | tail -n 1 | sed s/\,\ /\ -/g | cut -d '-' -f 4 | cut -d ' ' -f 1 | cut -d '.' -f 1)
diskGiga=$(df -h ~/.ipfs/ | tail -n 1 | awk '{print $4}' | cut -d 'G' -f '1' | cut -d '.' -f 1 )
echo "ssb_GET_zenyta write speed : $diskMBps MB/s"
echo "Disk size : $diskGiga GB"
# You can modify limit for a station to act ( > 15MB/s && > 5GB )
sleep $((1 + RANDOM % 10))
[[ $diskMBps -gt 15 ]] && [[ $diskGiga -gt 5 ]] && $MY_PATH/zen/ssb_GET_zenyta.sh &
fi
##################################################################
##################################################################
############ ASTROPORT LAUNCHING DATE 12:12 (HOUR is UTC)
TODAY=$(date -u '+%Y%m%d')
if [[ "$timebar" == "10:12" ]]; then
echo '
_____ ___ ___ __ __ _
|__ / |__ \ < / / /___ ___ ______ _____/ /_ (_)___ ____ _
/_ < __/ / / / / / __ `/ / / / __ \/ ___/ __ \/ / __ \/ __ `/
___/ / / __/ / /_ _ _ / / /_/ / /_/ / / / / /__/ / / / / / / / /_/ /
/____/ /____/ /_/(_|_|_) /_/\__,_/\__,_/_/ /_/\___/_/ /_/_/_/ /_/\__, /
/____/
ASTROPORT NOW... automate cellulaire - blob à rétrocontrole humain COLLECTIVE INIT
'
echo "$TODAY 12:12 - GCHANGE MARKET 50km SCAN"
sleep $((1 + RANDOM % 10))
# $MY_PATH/zen/gchange_MONITOR.sh &
fi
##################################################################
##################################################################
##################################################################
##################################################################
# MIDNIGHT:01 : ZENBOT CLEANING & UPDATE
##################################################################
@ -186,7 +124,7 @@ echo '
# / /_/ / /_/ / _ / /_/ / /
# \____/\____/ (_) \____/_/
#
# Clean & Upgrade + Log rotation + git pull + ipfs p2p port forward refresh, etc...
# MAINTENANCE
'
sleep $((1 + RANDOM % 5)) ### Be careful if random sleep is not activated...
############################## That swarm could become an aggressive blob !!
@ -203,7 +141,8 @@ echo '
# ssb_INIT + LOG ROTATE EVERY SUNDAY # TODO /var/log/ + logrotate (& tempfiles in /tmp in RAMFS)
if [[ $dayoftheweek == 0 ]]; then
$MY_PATH/zen/gchange_INIT.sh &
tar cvzf ~/.zen/astroport.$weeknumber.log.tgz /tmp/astroport.log # LOG BACKUP FOR 1 YEAR !!
# ACTIVATE IF CRON LOGGING
#tar cvzf ~/.zen/astroport.$weeknumber.log.tgz /tmp/astroport.log # LOG BACKUP FOR 1 YEAR !!
fi
#### DESYNC
sleep $((1 + RANDOM % 5))
@ -211,33 +150,7 @@ echo '
# GIT UPDATE
./git-update.sh
git pull # UPDATE CODE git pull
##################################################################
# Clear 24h ssb_GET markers
rm ~/.zen/zenytv.last.ts
rm ~/.zen/zenyta.last.ts
##################################################################
echo '
_________
/ ____< / _________ ___ _____
/ / __ / / / ___/ __ `__ \/ ___/
/ /_/ // / (__ ) / / / / (__ )
\____//_/ /____/_/ /_/ /_/____/
HTTP API forwarding to http://127.0.0.1:10099
'
echo '' > /tmp/A_P2Pforward
ipfs p2p close --all
####### OPEN PORT TO FORWARD ####### ADMIN ANY NODE (placer à 5 + 1mn)
### ADAPT TO ANY IPFSNODEID and TCP port
if [[ "$IPFSNODEID" == "QmVywXoBSz7JZ5vunYYVwi72SdTizvFt7k7qd3ooyYHvHA" ]]; then
ipfs p2p listen /x/g1pub-ssh /ip4/127.0.0.1/tcp/22 # CLOSE WITH ipfs p2p close /x/g1pub-ssh
ipfs p2p listen /x/g1pub-http /ip4/127.0.0.1/tcp/80
fi
# INDICATE OPENED PORTS to OTHER STATIONS
echo "ipfs p2p forward /x/g1pub-ssh /ip4/127.0.0.1/tcp/2021 /p2p/QmVywXoBSz7JZ5vunYYVwi72SdTizvFt7k7qd3ooyYHvHA" >> /tmp/A_P2Pforward
echo "ipfs p2p forward /x/g1pub-http /ip4/127.0.0.1/tcp/8021 /p2p/QmVywXoBSz7JZ5vunYYVwi72SdTizvFt7k7qd3ooyYHvHA" >> /tmp/A_P2Pforward
./zen/ipfs_OPEN_ports.sh
ipfs p2p ls
##################################################################
echo '
@ -247,9 +160,9 @@ echo '
/ /_/ __/ / / / / / / ___ / /_/ /
/___/\___/_/ /_/ /_/ /_/ |_\____/
REFRESHing ZenTAG nano DHTs
REFRESHing ZenTAG nano DHTs = Zen File ECONOMY
'
./zen/ipns_TAG_refresh.sh
# ./zen/ipns_TAG_refresh.sh
##################################################################
if [[ $dayofthemonth == 7 ]]; then
@ -270,9 +183,6 @@ echo '
'
echo "StorageMax = $diskSize"
## RESET ipfs_SWARM_refresh.sh alert
rm -f /tmp/ssb-friends_ALERT.txt
fi
##################################################################

View File

@ -24,7 +24,7 @@ awk -i inplace -v rmv="cron_MINUTE" '!index($0,rmv)' /tmp/mycron && echo "Astrop
crontest=$(cat /tmp/mycron | grep -F 'cron_MINUTE')
# ADD cron_MINUTE.sh TO cron ?
if [[ ! $crontest ]]; then
echo "* * * * * $MY_PATH/../cron_MINUTE.sh >> /tmp/astroport.log 2>&1" >> /tmp/mycron && crontab /tmp/mycron \
echo "* * * * * $MY_PATH/../cron_MINUTE.sh >> /tmp/astroport.log 2>&1>/dev/null" >> /tmp/mycron && crontab /tmp/mycron \
else
echo "No operation needed. Your crontab is: " && crontab -l
fi