#!/bin/bash ######################################################################## # Author: Fred (support@qo-op.com) # Version: 2020.12.05 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ######################################################################## # AUTOMATIC version of interactive 1stRUNconfig.sh # This script can run from ~/.config/autostart/Astroport_X_config.desktop # ######################################################################## # Create secret key files # ~/.zen/secret.june # ~/.zen/secret.dunikey # ~/.zen/secret.ipfs & /tmp/config.ipfs # ~/.zen/ipfs.sync ######################################################################## # CHECK IF CONFIG ALREADY DONE !! Remove ~/.zen/ipfs ~/.zen/secret ~/.zen/ipfs.sync if [[ -f ~/.zen/ipfs.sync ]]; then echo "CONFIG ALREADY DONE" source ~/.zen/ipfs.sync # NEW BOOT! SEND ipfstryme message to my friends... cd ~/.zen/astrXbian/zen/jaklis # GET LIST of issuer(s) who likes me for liking_me in $(./jaklis.py like | jq -r '.likes[].issuer'); do # CHECk if I am liking him either friend_of_mine=$(./jaklis.py like -p $liking_me | jq -r '.yours'); echo "Sending IPFSTRYME message to $liking_me" [[ $friend_of_mine != null ]] && ./jaklis.py send -d $liking_me -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr done cd - exit 0 fi # 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/astrXbian/zen/tools/diceware.sh 3 | xargs)" [[ $salt == "" ]] && echo "ERROR" && exit 1 pepper="$(~/.zen/astrXbian/zen/tools/diceware.sh 3 | xargs)" g1_salt="$salt" g1_pepper="$pepper" echo "CREATING /tmp/secret.june" echo "$g1_salt" > /tmp/secret.june echo "$g1_pepper" >> /tmp/secret.june ######################################################################## ######################################################################## echo "CREATING /tmp/secret.dunikey" ######################################################################## python3 ~/.zen/astrXbian/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/astrXbian/zen/tools/create_ipfsnodeid_from_tmp_secret.dunikey.py) echo $ipfs_ID > /tmp/secret.ipfs && source /tmp/secret.ipfs [[ $PrivKEY == "" ]] && echo "ERROR" && exit 1 jq -r --arg PeerID "$PeerID" '.Identity.PeerID=$PeerID' ~/.ipfs/config > /tmp/config.tmp jq -r --arg PrivKEY "$PrivKEY" '.Identity.PrivKey=$PrivKEY' /tmp/config.tmp > /tmp/config.ipfs rm /tmp/config.tmp # IPFSNODEID=$PeerID echo $IPFSNODEID ## 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 mv ~/.zen/secret.dunikey ~/.zen/secret.dunikey.old mv /tmp/secret.dunikey ~/.zen/secret.dunikey mv ~/.zen/secret.ipfs ~/.zen/secret.ipfs.old mv /tmp/secret.ipfs ~/.zen/secret.ipfs mv ~/.ipfs/config ~/.ipfs/config.old mv /tmp/config.ipfs ~/.ipfs/config ######################################################################## echo "INIT ~/.zen/ipfs/.${IPFSNODEID}" ######################################################################## rm -Rf ~/.zen/ipfs mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/G1SSB ######################################################################## # Give $XZUID to your (gchange friends) to add in Vstream Astroport and access your sharings # IPNS link to "pastebin list" http://localhost:8181/ipns/$IPNSKEY/xbian/$XZUID ######################################################################## XZUID=$(~/.zen/astrXbian/zen/tools/diceware.sh 1 | xargs)$(hostname -I | cut -d ' ' -f 1 | cut -d "." -f 4 )$(~/.zen/astrXbian/zen/tools/diceware.sh 1 | xargs) echo "CREATE ~/.zen/ipfs/xbian/$XZUID" mkdir -p ~/.zen/ipfs/xbian touch ~/.zen/ipfs/xbian/$XZUID # https://github.com/Kodi-vStream/venom-xbmc-addons/wiki/Voir-et-partager-sa-biblioth%C3%A8que-priv%C3%A9e#d%C3%A9clarer-des-films echo "$XZUID" > ~/.zen/ipfs/.${IPFSNODEID}/_xbian.zuid ######################################################################## ######################################################################## echo "CREATE + profile" ######################################################################## cd ~/.zen/astrXbian/zen/jaklis ./jaklis.py -n "https://g1.data.e-is.pro" set --name "$XZUID" --avatar "$HOME/.zen/astrXbian/logo.png" #CESIUM+ ./jaklis.py -n "https://data.gchange.fr" set --name "$XZUID" --avatar "$HOME/.zen/astrXbian/logo.png" #GCHANGE+ ######################################################################## ######################################################################## echo "BECOME FRIEND with oasis (1st bootstrap)" ######################################################################## ./jaklis.py -n "https://g1.data.e-is.pro" like -p 2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS -s 5 ./jaklis.py -n "https://data.gchange.fr" like -p 2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS -s 5 ######################################################################## echo "RESTART ipfs" ######################################################################## sudo service ipfs restart echo ".... WAIT for SWARM to connect ..." sleep 10 ipfs swarm peers ######################################################################## echo 'EXTEND ~/.bashrc' ######################################################################## ~/.zen/astrXbian/.install/update_bashrc.sh echo "Configure .kodi/addons/plugin.video.vstream/resources/sites/astroport.py" cp -f ~/.zen/astrXbian/.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 XZUID 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 sed -i "s/_PROFIL_/$XZUID/g" ~/.kodi/addons/plugin.video.vstream/resources/sites/astroport.py sed -i "s/_LOGIN_/$salt/g" ~/.kodi/addons/plugin.video.vstream/resources/sites/astroport.py sed -i "s/_MDP_/$pepper/g" ~/.kodi/addons/plugin.video.vstream/resources/sites/astroport.py ~/.zen/astrXbian/zen/cesium_IPFS_swarm.sh ~/.zen/astrXbian/zen/ipfs_SWARM_refresh.sh ######################################################################## 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 && $tryme != "" ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr && echo "$tryme" done echo 'SEND ipfstryme to oasis' # Add your bootstrap Pub here ./jaklis.py -n "https://g1.data.le-sou.org" send -d 2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ./jaklis.py -n "https://data.gchange.fr send" -d 2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ######################################################################## echo 'INSTALL Astroport cron_MINUTE' ######################################################################## ~/.zen/astrXbian/zen/cron_VRFY.sh # Run only once: comment /etc/rc.local (su - xbian -c "~/.zen/astrXbian/ISOconfig.sh") # sudo sed -i s/su/\#su/g /etc/rc.local # BETTER NOT: Send new 'ipfstryme' message on each boot is done instead echo "CHANGE hostname" astrxbian=$(hostname) sudo sed -i "s/$astrxbian/$XZUID/g" /etc/hostname sudo sed -i "s/$astrxbian/$XZUID/g" /etc/hosts echo "CHANGE DNS" # Avoid provider restrictions sudo mv /etc/resolv.conf /etc/resolv.conf.old sudo cat > /etc/resolv.conf < ~/.zen/ipfs.sync # OTHER LANGUAGE KEYBOARD dpkg-reconfigure keyboard-configuration ######################################################################## echo 'REBOOT NOW...' ######################################################################## sudo reboot exit 0