This commit is contained in:
fred 2022-10-27 15:48:35 +02:00
parent 130476101a
commit e2e438f368
3 changed files with 97 additions and 332 deletions

View File

@ -18,6 +18,9 @@ myIP=$(hostname -I | awk '{print $1}' | head -n 1)
[[ ! $myIP ]] && myIP="127.0.1.1"
PORT=12345
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2)
mkdir -p ~/.zen/tmp/123/
## CHECK FOR ANY ALREADY RUNNING nc
@ -45,7 +48,7 @@ while true; do
# REPLACE myIP in http response template
sed "s~127.0.0.1:12345~$myIP:$PORT~g" $HOME/.zen/Astroport.ONE/templates/index.http > ~/.zen/tmp/123/${MOATS}.myIP.http
sed -i "s~127.0.0.1~$myIP~g" ~/.zen/tmp/123/${MOATS}.myIP.http
sed -i "s~_IPFSNODEID_~$IPFSNODEID~g" ~/.zen/tmp/123/${MOATS}.myIP.http ## NODE PUBLISH HOSTED PLAYER'S JSON
sed -i "s~_IPFSNODEID_~${IPFSNODEID}~g" ~/.zen/tmp/123/${MOATS}.myIP.http ## NODE PUBLISH HOSTED WHAT'S JSON
############################################################################
## WAITING TO SERVE 1ST LANDING REDIRECT PAGE
@ -66,7 +69,7 @@ Server: Astroport
Content-Type: text/html; charset=UTF-8
" > ~/.zen/tmp/123/${MOATS}.index.redirect
sed "s~127.0.0.1~$myIP~g" $HOME/.zen/Astroport.ONE/templates/homepage.html >> ~/.zen/tmp/123/${MOATS}.index.redirect
sed -i "s~_IPFSNODEID_~$IPFSNODEID~g" ~/.zen/tmp/123/${MOATS}.index.redirect
sed -i "s~_IPFSNODEID_~${IPFSNODEID}~g" ~/.zen/tmp/123/${MOATS}.index.redirect
sed -i "s~_HOSTNAME_~$(hostname)~g" ~/.zen/tmp/123/${MOATS}.index.redirect
cat ~/.zen/tmp/123/${MOATS}.index.redirect | nc -l -p ${PORT} -q 1 &
@ -85,6 +88,7 @@ sed -i "s~_HOSTNAME_~$(hostname)~g" ~/.zen/tmp/123/${MOATS}.index.redirect
echo "PARAM : ${arr[0]} = ${arr[1]} & ${arr[2]} = ${arr[3]} & ${arr[4]} = ${arr[5]} & ${arr[6]} = ${arr[7]} & ${arr[8]} = ${arr[9]}"
# CHECK TYPE
TYPE=$(urldecode ${arr[4]})
WHAT=$(urldecode ${arr[5]})
[[ ${arr[0]} == "" || ${arr[1]} == "" ]] && (echo "ERROR - MISSING DATA" | nc -l -p ${PORT} -q 1 &) && continue
@ -100,9 +104,9 @@ sed -i "s~_HOSTNAME_~$(hostname)~g" ~/.zen/tmp/123/${MOATS}.index.redirect
[[ ! $PEPPER ]] && (echo "ERROR - PEPPER MISSING" | nc -l -p ${PORT} -q 1 &) && continue
TYPE=$(urldecode ${arr[4]} | xargs)
PLAYER=$(urldecode ${arr[5]} | xargs)
WHAT=$(urldecode ${arr[5]} | xargs)
echo "API ZERO CALL : http://$myIP:1234/?salt=$SALT&pepper=$PEPPER&$TYPE=$PLAYER"
echo "API ZERO CALL : http://$myIP:1234/?salt=$SALT&pepper=$PEPPER&$TYPE=$WHAT"
echo "\"$SALT\" \"$PEPPER\"" > ~/.zen/tmp/123/${MOATS}.secret.june
@ -118,12 +122,12 @@ sed -i "s~_HOSTNAME_~$(hostname)~g" ~/.zen/tmp/123/${MOATS}.index.redirect
GNS=$(ipfs key import gchange -f pem-pkcs8-cleartext ~/.zen/tmp/123/${MOATS}.${G1PUB}.ipns.key )
echo "Astronaute TW ? http://$myIP:8080/ipns/$GNS"
## ARCHIVE TOCTOC PLAYERS
## ARCHIVE TOCTOC WHATS
mkdir -p ~/.zen/tmp/toctoc/
ISTHERE=$(ls -t ~/.zen/tmp/toctoc/*.${G1PUB}.ipns.key 2>/dev/null | tail -n 1)
TTIME=$(echo $ISTHERE | rev | cut -d '.' -f 4 | cut -d '/' -f 1 | rev)
if [[ ! $ISTHERE ]]; then
echo "PLAYER 1ST TOCTOC : $MOATS"
echo "WHAT 1ST TOCTOC : $MOATS"
cp ~/.zen/tmp/123/${MOATS}.* ~/.zen/tmp/toctoc/
else
OLDONE=$(ls -t ~/.zen/tmp/123/*.${G1PUB}.ipns.key | tail -n 1)
@ -170,10 +174,20 @@ cat ~/.zen/tmp/123/${MOATS}.messaging.json >> ~/.zen/tmp/123/${MOATS}.index.redi
NODEID=$(urldecode ${arr[7]} | xargs)
DATAID=$(urldecode ${arr[9]} | xargs)
mkdir -p ~/.zen/tmp/${IPFSNODEID}/$NODEID/${MOATS}
echo "PING $NODEID"
ipfs --timeout 12s ping $NODEID &
ipfs --timeout 12s ls /ipfs/$DATAID &
echo "CURL https://ipfs.io/ipfs/$DATAID"
(curl -m 12 -so ~/.zen/tmp/${IPFSNODEID}/$NODEID/${MOATS}/ "https://gateway.ipfs.io/ipfs/$DATAID" && \
[[ -s ~/.zen/tmp/123/${MOATS}.data.$NODEID.ipfs ]] && \
ipfs add ~/.zen/tmp/123/${MOATS}.data.$NODEID.ipfs ) &
echo "CAT $NODEID /ipfs/$DATAID"
([[ $YOU ]] && ipfs --timeout 12s cat /ipfs/$DATAID > ~/.zen/tmp/123/${MOATS}.data.${NODEID}.ipfs &)
echo "OK - $NODEID GONE GET YOUR /ipfs/$DATAID"
(echo "OK - $NODEID WE GONE GET YOUR /ipfs/$DATAID " | nc -l -p ${PORT} -q 1 &) && continue
(echo "/ipns/${IPFSNODEID}/$NODEID/${MOATS}/ " | nc -l -p ${PORT} -q 1 &) && continue
fi
## ELSE IPNS TW REDIRECT
@ -182,8 +196,6 @@ cat ~/.zen/tmp/123/${MOATS}.messaging.json >> ~/.zen/tmp/123/${MOATS}.index.redi
# OFFICIAL Gateway ( increase waiting time ) - MORE SECURE
if [[ $TYPE == "official" ]]; then
echo "OFFICIAL latest online TW..."
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2)
echo "$LIBRA/ipns/$GNS"
echo "http://$myIP:8080/ipns/$GNS ($YOU)"
[[ $YOU ]] && ipfs --timeout 12s cat /ipns/$GNS > ~/.zen/tmp/123/${MOATS}.astroindex.html \
@ -197,7 +209,7 @@ cat ~/.zen/tmp/123/${MOATS}.messaging.json >> ~/.zen/tmp/123/${MOATS}.index.redi
tiddlywiki --load ~/.zen/tmp/123/${MOATS}.astroindex.html --output ~/.zen/tmp --render '.' 'miz.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion'
OLDIP=$(cat ~/.zen/tmp/miz.json | jq -r .[].secret)
[[ ! $OLDIP ]] && (echo "ERROR - $OLDIP WRONG TW - CONTINUE " | nc -l -p ${PORT} -q 1 &) && continue
# FIRST TIME PLAYER TW USING GATEWAY
# FIRST TIME WHAT TW USING GATEWAY
if [[ $OLDIP == "_SECRET_" ]]; then
echo "_SECRET_ TW PUSHING TW" ## SEND FULL TW
sed -i "s~_SECRET_~${myIP}~g" ~/.zen/tmp/123/${MOATS}.astroindex.html
@ -230,7 +242,7 @@ Content-Type: text/html; charset=UTF-8
echo "$MOATS -----> PAGE AVAILABLE -----> http://$myIP:${PORT}"
#echo "$GNS" | nc -l -p ${PORT} -q 1 &
## CHECK IF ALREADY EXISTING PLAYER
## CHECK IF ALREADY EXISTING WHAT
# IF NOT = BATCH CREATE TW
end=`date +%s`
echo Execution time was `expr $end - $start` seconds.
@ -249,13 +261,13 @@ Content-Type: text/html; charset=UTF-8
SALT=$(urldecode ${arr[1]} | xargs)
PEPPER=$(urldecode ${arr[3]} | xargs)
PLAYER=$(urldecode ${arr[7]} | xargs)
WHAT=$(urldecode ${arr[7]} | xargs)
PSEUDO=$(urldecode ${arr[9]} | xargs)
[[ ! $PLAYER ]] && (echo "ERROR - MISSING EMAIL FOR PLAYER CONTACT" | nc -l -p ${PORT} -q 1 &) && continue
[[ ! $WHAT ]] && (echo "ERROR - MISSING EMAIL FOR WHAT CONTACT" | nc -l -p ${PORT} -q 1 &) && continue
if [[ ! $PSEUDO ]]; then
PSEUDO=$(echo $PLAYER | cut -d '@' -f 1)
PSEUDO=$(echo $WHAT | cut -d '@' -f 1)
PSEUDO=${PSEUDO,,}; PSEUDO=${PSEUDO%%[0-9]*}${RANDOM:0:3}
fi
# PASS CRYPTING KEY
@ -264,17 +276,17 @@ Content-Type: text/html; charset=UTF-8
echo "$SALT"
echo "$PEPPER"
if [[ ! -d ~/.zen/game/players/$PLAYER ]]; then
if [[ ! -d ~/.zen/game/players/$WHAT ]]; then
# ASTRONAUT NEW VISA Create VISA.new.sh in background
$MY_PATH/tools/VISA.new.sh "$SALT" "$PEPPER" "$PLAYER" "$PSEUDO" &
echo "OK - ASTRONAUT $PLAYER VISA CREATION [$SALT + $PEPPER] ($PSEUDO)
$MY_PATH/tools/VISA.new.sh "$SALT" "$PEPPER" "$WHAT" "$PSEUDO" &
echo "OK - ASTRONAUT $WHAT VISA CREATION [$SALT + $PEPPER] ($PSEUDO)
<br> - PLEASE 'CHECK IN' http://$myIP:1234/ " | nc -l -p ${PORT} -q 1 &
continue
else
# ASTRONAUT EXISTING PLAYER
CHECK=$(cat ~/.zen/game/players/$PLAYER/secret.june | grep -w "$SALT")
[[ $CHECK ]] && CHECK=$(cat ~/.zen/game/players/$PLAYER/secret.june | grep -w "$PEPPER")
[[ ! $CHECK ]] && (echo "ERROR - PLAYER $PLAYER ALREADY EXISTS" | nc -l -p ${PORT} -q 1 &) && continue
# ASTRONAUT EXISTING WHAT
CHECK=$(cat ~/.zen/game/players/$WHAT/secret.june | grep -w "$SALT")
[[ $CHECK ]] && CHECK=$(cat ~/.zen/game/players/$WHAT/secret.june | grep -w "$PEPPER")
[[ ! $CHECK ]] && (echo "ERROR - WHAT $WHAT ALREADY EXISTS" | nc -l -p ${PORT} -q 1 &) && continue
fi
###################################################################################################
@ -287,13 +299,13 @@ Content-Type: text/html; charset=UTF-8
###################################################################################################
# API TWO : ?qrcode=G1PUB
if [[ ${arr[0]} == "qrcode" ]]; then
## Astroport.ONE local use QRCODE Contains PLAYER G1PUB
## Astroport.ONE local use QRCODE Contains WHAT G1PUB
QRCODE=$(echo $URL | cut -d ' ' -f2 | cut -d '=' -f 2 | cut -d '&' -f 1) && echo "QRCODE : $QRCODE"
g1pubpath=$(grep $QRCODE ~/.zen/game/players/*/.g1pub | cut -d ':' -f 1 2>/dev/null)
PLAYER=$(echo "$g1pubpath" | rev | cut -d '/' -f 2 | rev 2>/dev/null)
WHAT=$(echo "$g1pubpath" | rev | cut -d '/' -f 2 | rev 2>/dev/null)
## FORCE LOCAL USE ONLY. Remove to open 1234 API
[[ ! -d ~/.zen/game/players/$PLAYER || $PLAYER == "" ]] && (echo "ERROR - QRCODE - NO PLAYER ON BOARD !!" | nc -l -p ${PORT} -q 1 &) && continue
[[ ! -d ~/.zen/game/players/$WHAT || $WHAT == "" ]] && (echo "ERROR - QRCODE - NO WHAT ON BOARD !!" | nc -l -p ${PORT} -q 1 &) && continue
## UNE SECOND HTTP SERVER TO RECEIVE PASS
@ -306,7 +318,7 @@ Content-Type: text/html; charset=UTF-8
## LANCEMENT COPIE
~/.zen/Astropor.ONE/ajouter_video.sh "$(urldecode $wsource)" "$wtype" "$QRCODE" &
(echo "OK - QRCODE - COPYING $(urldecode $wsource) FOR $PLAYER" | nc -l -p ${PORT} -q 1 &) && continue
(echo "OK - QRCODE - COPYING $(urldecode $wsource) FOR $WHAT" | nc -l -p ${PORT} -q 1 &) && continue
fi
fi

View File

@ -11,32 +11,40 @@ ME="${0##*/}"
[ $(id -u) -eq 0 ] && echo "LANCEMENT root INTERDIT. Utilisez un simple utilisateur du groupe \"sudo\" SVP" && exit 1
########################################################################
[[ ! $(which ipfs) ]] && echo "=== Installez IPFS !!" && echo "https://docs.ipfs.io/install/command-line/#official-distributions" && exit 1
[[ ! $(which ipfs) ]] && echo "=== Installez IPFS KUBO !!" && echo "https://docs.ipfs.io/install/command-line/#official-distributions" && exit 1
#### GIT CLONE ###############################################################
[[ ! $(which git) ]] && sudo apt install -y git
echo "=== Clonage git CODE 'Astroport.ONE' depuis https://git.p2p.legal"
mkdir -p ~/.zen
cd ~/.zen
git clone https://git.p2p.legal/qo-op/Astroport.ONE.git
# TODO INSTALL FROM IPFS / IPNS
# MAIN # SI AUCUNE CLEF DE STATION...
if [[ ! -f ~/.zen/game/players/.current/secret.dunikey ]];
if [[ ! -d ~/.zen/game/players/ ]];
then
# Check requirements
echo "Astroport.ONE installateur pour distributions DEBIAN et dérivées : LinuxMint (https://www.linuxmint.com/) ou XBIAN (https://xbian.org) recommandées"
echo "Astroport.ONE installateur pour distributions DEBIAN et dérivées : LinuxMint (https://www.linuxmint.com/) ou XBIAN (https://xbian.org) testées"
echo "Appuyez sur ENTRER pour commencer."; read TEST; [[ "$TEST" != "" ]] && echo "SORTIE" && exit 0 ## Ajouter confirmation à chaque nouvelle étape (+explications)
echo ; echo "Mise à jour des dépots de votre distribution..."
sudo apt-get update
[[ "$USER" != "xbian" && $XDG_SESSION_TYPE == 'x11']] &&\
for i in x11-utils xclip zenity; do\
[ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ] &&\
echo ">>> Installation $i <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<";\
if [[ "$USER" != "xbian" && $XDG_SESSION_TYPE == 'x11']]; then
for i in x11-utils xclip zenity; do
if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
echo ">>> Installation $i <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
sudo apt install -y $i;
[[ $? != 0 ]] && echo "INSTALL FAILED. PLEASE REPORT ISSUE" && exit 1
[[ $? != 0 ]] && echo "INSTALL $i FAILED." && echo "INSTALL $i FAILED." >> /tmp/install.failed.log && continue
done
fi
for i in git fail2ban npm netcat-traditional inotify-tools curl net-tools libsodium* python3-pip python3-setuptools python3-wheel python3-dotenv python3-gpg python3-jwcrypto mpack; do
if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
echo ">>> Installation $i <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
sudo apt install -y $i
[[ $? != 0 ]] && echo "INSTALL FAILED. PLEASE REPORT ISSUE" && exit 1
[[ $? != 0 ]] && echo "INSTALL $i FAILED." && echo "INSTALL $i FAILED." >> /tmp/install.failed.log && continue
fi
done
@ -45,23 +53,31 @@ for i in qrencode jq bc file gawk yt-dlp ffmpeg sqlite dnsutils v4l-utils espeak
if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
echo ">>> Installation $i <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
sudo apt install -y $i
[[ $? != 0 ]] && echo "INSTALL FAILED. PLEASE REPORT ISSUE" && exit 1
[[ $? != 0 ]] && echo "INSTALL $i FAILED." && echo "INSTALL $i FAILED." >> /tmp/install.failed.log && continue
fi
done
##########################################################
echo "### Install tiddlywiki node.js"
echo "### INSTALL TW node.js"
sudo npm install -g tiddlywiki
[[ $? != 0 ]] && echo "INSTALL FAILED. PLEASE REPORT ISSUE" && exit 1
[[ $? != 0 ]] && echo "INSTALL tiddlywikiFAILED." && echo "INSTALL tiddlywiki FAILED." >> /tmp/install.failed.log && continue
##########################################################
########### KODI + kodi_uqload_downloader
if [[ ! $(which kodi) && "$USER" != "xbian" && $XDG_SESSION_TYPE == 'x11' ]]; then
## Il manque kodi
echo ">>> Installation Kodi + Vstream = VOTRE VIDEOTHEQUE ! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
sudo apt-get install kodi -y
[[ $? != 0 ]] && echo "INSTALL kodi FAILED." && echo "INSTALL kodi FAILED." >> /tmp/install.failed.log && continue
fi
if [[ $(which kodi) ]]; then
echo ">>> Installation kodi_uqload_downloade <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
${MY_PATH}/kodi_uqload_downloader.sh
[[ $? != 0 ]] && echo "INSTALL kodi_uqload_downloader FAILED." && echo "INSTALL kodi_uqload_downloader FAILED." >> /tmp/install.failed.log && continue
fi
[[ ! $(which kodi) && "$USER" != "xbian" && $XDG_SESSION_TYPE == 'x11' ]] && \
echo ">>> Installation Kodi + Vstream = VOTRE VIDEOTHEQUE ! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"; \
sudo apt-get install kodi -y; \
${MY_PATH}/.install/kodi_uqload_downloader.sh
# echo "## INSTALLATION AstroGEEK OpenCV = 'Intelligence Amie' "
echo "## INSTALLATION AstroGEEK OpenCV = 'Intelligence Amie' - DEV - "
# sudo apt-get install python3-opencv -y
## Correct PDF restrictions for imagemagick
@ -74,14 +90,22 @@ fi
echo "###########################"
echo "## INSTALL PYTHON CRYPTO LAYER "
echo "###########################"
echo 'export PATH=$PATH:$HOME/.local/bin' >> ~/.bashrc && source ~/.bashrc; echo ">>> PATH=$PATH"
python3 -m pip install -U pip
python3 -m pip install -U setuptools wheel
python3 -m pip install -U cryptography Ed25519 base58 google duniterpy pynacl pgpy pynentry SecureBytes
python3 -m pip install -U silkaj
python3 -m pip install -U protobuf==3.19.0
sudo ln -f -s /usr/bin/python3 /usr/bin/python
echo 'export PATH=$PATH:$HOME/.local/bin' >> ~/.bashrc && source ~/.bashrc; echo "<<< CHECK YOUR >>> PATH=$PATH"
# python3 -m pip install -U pip
# python3 -m pip install -U setuptools wheel
# python3 -m pip install -U cryptography Ed25519 base58 google duniterpy pynacl pgpy pynentry SecureBytes
# python3 -m pip install -U silkaj
# python3 -m pip install -U protobuf==3.19.0
for i in pip setuptools wheel cryptography Ed25519 base58 google duniterpy pynacl pgpy pynentry SecureBytes; do
echo ">>> Installation $i <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
python3 -m pip install -U $i
[[ $? != 0 ]] && echo "INSTALL $i FAILED." && echo "python3 -m pip install -U $i FAILED." >> /tmp/install.failed.log && continue
done
########### PRINTER ##############
if [[ "$USER" == "pi" ]]; then ## PROPOSE QR_CODE PRINTER SUR RPI
echo "Ambassade? Ajouter imprimante 'brother_ql'? Saisissez OUI, sinon laissez vide et tapez sur ENTRER"
read saisie
@ -96,25 +120,12 @@ if [[ "$USER" == "pi" ]]; then ## PROPOSE QR_CODE PRINTER SUR RPI
fi
fi
# python3 -m pip install -U silkaj
## python -> python3 link
sudo ln -f -s /usr/bin/python3 /usr/bin/python
########################################################################
echo "=== Clonage git CODE 'Astroport.ONE' depuis https://git.p2p.legal"
mkdir -p ~/.zen
cd ~/.zen
git clone https://git.p2p.legal/qo-op/Astroport.ONE.git
# TODO INSTALL FROM IPFS / IPNS
## Scripts pour systemd ou InitV (xbian)
echo "=== Astroport SYSTEM IPFS"
echo "=== Astroport UPGRADE SYSTEM IPFS"
~/.zen/Astroport.ONE/tools/ipfs_setup.sh
########################################################################
#### SETUP JAKLIS ###############################################################
echo "=== Configuration jaklis: Centre de communication CESIUM+ GCHANGE+"
cd $MY_PATH/tools/jaklis
./setup.sh
@ -167,17 +178,14 @@ if [[ "$USER" != "xbian" ]]
then
## Desktop install
echo "INITIALISATION Astroport"
echo "Appuyez sur la touche ENTREE pour démarrer le mode Aventure"
echo "sinon interrompez ici l'installation, et activez votre Ambassade ~/.zen/Astroport.ONE/start.sh"
echo "Appuyez sur la touche ENTREE pour démarrer votre Station"
read
# ~/.zen/Astroport.ONE/adventure.sh
#
# ~/.zen/astrXbian/ISOconfig.sh
~/.zen/Astroport.ONE/start.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 "su - xbian -c '~/.zen/Astroport.ONE/FirstBOOT.sh'" >> /tmp/new.rc.local
echo "exit 0" >> /tmp/new.rc.local
sudo cp -f /tmp/new.rc.local /etc/rc.local
@ -216,9 +224,11 @@ ipfs bootstrap rm --all
###########################################
# BOOTSTRAP NODES ARE ADDED LATER
###########################################
[[ "$USER" != "xbian" ]] && sudo systemctl restart ipfs
### ADD 20h12.sh CRON ###############
$MY_PATH/tools/cron_VRFY.sh ON
########################################################################
# SUDO permissions
########################################################################
@ -242,13 +252,13 @@ else
echo "Installation existante !!
========================
Astroport/KODI (Gchange)
Astroport/TW
========================
Connectez-vous sur https://gchange.fr avec vos identifiants
$(cat ~/.zen/game/players/.current/secret.june)
https://astroport.com
http://astroport.com
"
# MAIN #

View File

@ -1,257 +0,0 @@
#!/bin/bash
########################################################################
{ # this ensures the entire script is downloaded #
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
# CHECK not root user !!
if [ "$EUID" -eq 0 ]
then echo -e "DO NOT EXECUTE AS root. Choose a user for your Astroport Station (we like pi)"
exit 1
else echo -e "OK $USER, let's go!";
fi
echo "Hello,
This script (you could read and modify as it is open source software) is about to transform your computer into an astroport station.
This process involve different upgrades to be made on your system.
1. install IPFS, the interplanetary file system (https://ipfs.io)
2. install python cryptographic libraries to run natools, your key wizard companion
3. download 'astroport' code release you have choosen.
~/.zen directory and datastructure will emerge
~/.zen/ipfs & ~/.zen/ipfs_swarm contains all meshed media index from you and your friends.
ASTROPORT is activated by cron every minute it maintains the connection with your friends.
It is the vessel that gives you avvess to your p2p AVATAR.
You carry and share your data around your friends through a confidence network
established through 1 to 5 'hearts' exchanged, opening 5 stargates where any can push/pull data.
TODO
Just indicate which is the directory assigned to each star.
Then any of your friends from such star level can replicate (modify) those data with you.
Your station is publishing its index every time it changes and every 6 hours for all MEDIAKEY from PIN station.
Following that principle add new directory into ~/.zen/ipfs and index any dataset, it will be published on your IPFS semaphore.
Now you need to enter your password to obtain sudo access.
Please.
"
# Ask user password on start
sudo true
## Error funciton
err() {
echo -e "ERREUR: $1"
exit 1
}
# CHECK if daemon is already running
if [[ $(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) ]]; then
ipfs id && echo "ipfs swarm peers: " && ipfs swarm peers
echo "ipfs bootstrap list: " && ipfs bootstrap list
echo "ipfs daemon already running...! Must STOP ipfs AND remove ~/.ipfs to install again !!"
echo "Please RUN : sudo service ipfs stop"
exit 1
fi
[[ -d ~/.ipfs ]] && echo "IPFS install exist! Please remove or backup before executing this script EXIT" && exit 1
echo -e "Check and install python curl, git and tools."
[[ $(which pip3) ]] && python3 -m pip install -U pip && python3 -m pip install -U wheel cryptography Ed25519 base58 google protobuf duniterpy==0.62.0 termcolor python-dotenv gql==3.0.0a5 requests pybase64 || (echo "python3 pip3 is missing on your device. EXIT" && exit 1)
[[ ! $(which curl) ]] && sudo apt-get install curl -y
[[ ! $(which git) ]] && sudo apt-get install git -y
[[ ! -d ~/.zen ]] && mkdir ~/.zen
# CHECK node IP isLAN?
myIP=$(hostname -I | awk '{print $1}')
echo "Your IP is $myIP"
isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
[[ $isLAN ]] && echo "You are located in a LAN" || echo "You have a public IP address"
MACHINE_TYPE=`uname -m`
echo "You are running $MACHINE_TYPE CPU"
echo "Downloading ipfs binaries"
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
curl -s https://dist.ipfs.io/ipfs-update/v1.6.0/ipfs-update_v1.6.0_linux-amd64.tar.gz -o $MY_PATH/ipfs-update.tar.gz
elif [ ${MACHINE_TYPE:0:3} == 'arm' ]; then
curl -s https://dist.ipfs.io/ipfs-update/v1.6.0/ipfs-update_v1.6.0_linux-arm.tar.gz -o $MY_PATH/ipfs-update.tar.gz
elif [ ${MACHINE_TYPE} == 'aarch64' ]; then
curl -s https://dist.ipfs.io/go-ipfs/v0.9.1/go-ipfs_v0.9.1_linux-arm64.tar.gz -o /tmp/ipfs_aarch64_v0.9.1.tar.gz
else
echo "Your $MACHINE_TYPE is not supported yet... Please add an issue." && exit 1
fi
if [ -f $MY_PATH/ipfs-update.tar.gz ]; then
echo "INSTALL ipfs-update >>>>>>>>>>>>>>>>>>>>>>>>>>"
sudo tar -xvzf $MY_PATH/ipfs-update.tar.gz -C /usr/src/ || err "Untar ipfs-update"
rm $MY_PATH/ipfs-update.tar.gz
cd /usr/src/ipfs-update/
sudo ./install.sh || err "Install ipfs-update"
cd $MY_PATH
echo "INSTALL ipfs 0.9.1 >>>>>>>>>>>>>>>>>>>>>>>>>>"
sudo ipfs-update install 0.9.1 || err "Install IPFS"
else
## TERRAPI4 aarch64 install ipfs_aarch64_v0.9.1
echo "INSTALL ipfs 0.9.1 >>>>>>>>>>>>>>>>>>>>>>>>>> arm64"
sudo tar -xvzf /tmp/ipfs_aarch64_v0.9.1.tar.gz -C /usr/src/ || err "Untar ipfs_aarch64"
rm /tmp/ipfs_aarch64_v0.9.1.tar.gz
cd /usr/src/go-ipfs/
sudo ./install.sh || err "Install ipfs_aarch64"
cd $MY_PATH
fi
# INIT ipfs
[[ $isLAN ]] && ipfs init -p lowpower \
|| ipfs init -p server
## Special Xbian init.d config
## DEBIAN SYSTEMCTL
echo "SYSTEMD ipfs SERVICE >>>>>>>>>>>>>>>> ON"
cat > /tmp/ipfs.service <<EOF
[Unit]
Description=IPFS daemon
After=network.target
[Service]
User=_USER_
ExecStart=/usr/local/bin/ipfs daemon --enable-pubsub-experiment --enable-namesys-pubsub --enable-gc
Restart=on-failure
CPUAccounting=true
CPUQuota=60%
[Install]
WantedBy=multi-user.target
EOF
sudo cp -f /tmp/ipfs.service /etc/systemd/system/
sudo sed -i "s/_USER_/$USER/g" /etc/systemd/system/ipfs.service
echo "Activating ipfs daemon >>>>>>>>>>>>>>>>>> "
# echo "Vous pouvez régler la ressouce CPU maximum (60%)?" && read cpuy
[[ -d ~/.ipfs ]] && sudo chown -R $USER:$USER ~/.ipfs
sudo systemctl daemon-reload
sudo systemctl enable ipfs
###########################################
echo "# ACTIVATE IPFS OPTIONS: #swarm0 INIT"
###########################################
### IMPORTANT !!!!!!! IMPORTANT !!!!!!
###########################################
# DHT PUBSUB mode
ipfs config Pubsub.Router gossipsub
# MAXSTORAGE = 1/2 available
availableDiskSize=$(df -P ~/ | awk 'NR>1{sum+=$4}END{print sum}')
diskSize="$((availableDiskSize / 2))"
ipfs config Datastore.StorageMax $diskSize
## Activate Rapid "ipfs p2p"
ipfs config --json Experimental.Libp2pStreamMounting true
ipfs config --json Experimental.P2pHttpProxy true
ipfs config --json Swarm.ConnMgr.LowWater 50
ipfs config --json Swarm.ConnMgr.HighWater 100
## Install gateway on 8181 port
ipfs config Addresses.Gateway "/ip4/127.0.0.1/tcp/8181"
########################################################################
# GET IPFS KEYS & CONVERSIONS
########################################################################
IPFSNODEID=$(ipfs config Identity.PeerID)
## TODO convert to secret.dunikey
########################################################################
echo "CREATION IDENTITE BALISE IPFS ~/.zen/ipfs/.${IPFSNODEID} /G1SSB"
########################################################################
rm -Rf ~/.zen/ipfs
mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/G1SSB
########################################################################
# Give $XZUID to your (gchange friends)
########################################################################
XZUID="$(hostname)-$RANDOM$RANDOM"
echo "SETTING .player PROFILE NAME = $XZUID"
echo "$XZUID" > ~/.zen/ipfs/.${IPFSNODEID}/.player
echo 'balise /ipns/$IPFSNODEID/.$IPFSNODEID/.player'
########################################################################
########################################################################
echo "Getting tryme.addr & .mycode from OASIS
-- Change oasis address to fork your Astroport Code Universe --"
########################################################################
ipfs bootstrap rm --all
OASIS=12D3KooWBYme2BsNUrtx4mEdNX6Yioa9AV7opWzQp6nrPs6ZKabN
# aries=12D3KooWSQYTxeoZZ39SNosEKxi7RUdGTtAQAqpKeZJxjzqqrZTx
for bootnode in $(curl -s https://tube.copylaradio.com/ipns/$OASIS/.$OASIS/tryme.addr)
do
## ADD $bootnode TO BOOTSTRAP
ipfs bootstrap add $bootnode
done
codesign=$(curl -s https://tube.copylaradio.com/ipns/$OASIS/.$OASIS/.mycode)
## ADD NETWORK EXPLORATION FROM LIKES
########################################################################
echo "RESTARTING ipfs"
########################################################################
sudo service ipfs restart
echo ".... WAIT for SWARM to connect ..."
sleep 10
echo ".... ACTUAL SWARM PEERS ..."
ipfs swarm peers
echo "IPFS DONE
====================
Station Astroport INSTALL
Activation ~/.zen/astrXbian/zen/cron_VRFY.sh
Récupération CODE /ipfs/$codesign
"
## GETTING SAME SOURCE CODE AS OASIS
mkdir -p /home/$USER/.zen/astrXbian/
ipfs get --output=/home/$USER/.zen/astrXbian/ /ipfs/$codesign
## Make scripts executable
find /home/$USER/.zen/astrXbian/ -name "*.sh" -exec chmod u+x '{}' \;
find /home/$USER/.zen/astrXbian/ -name "*.py" -exec chmod u+x '{}' \;
########################################################################
echo "# Setting $USER SUDO permissions ON fail2ban mount umount apt-get apt systemctl"
########################################################################
## USED FOR fail2ban-client (DEFCON)
echo "$USER ALL=(ALL) NOPASSWD:/usr/bin/fail2ban-client" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/fail2ban-client')
## USED FOR RAMDISK (video live streaming)
echo "$USER ALL=(ALL) NOPASSWD:/bin/mount" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/mount')
echo "$USER ALL=(ALL) NOPASSWD:/bin/umount" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/umount')
## USED FOR SYSTEM UPGRADE
echo "$USER ALL=(ALL) NOPASSWD:/usr/bin/apt-get" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/apt-get')
echo "$USER ALL=(ALL) NOPASSWD:/usr/bin/apt" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/apt')
## USED FOR "systemctl restart ipfs"
echo "$USER ALL=(ALL) NOPASSWD:/bin/systemctl" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/systemctl')
## TODO G1SSB CONFIG
echo "## INSTALL TiddlyWiki /ipns/${IPFSNODEID}/.${IPFSNODEID}/index.html"
[[ ! -f ~/.zen/ipfs/.${IPFSNODEID}/index.html ]] && mkdir -p ~/.zen/ipfs/.${IPFSNODEID} && cp ~/.zen/astrXbian/.install/templates/tiddlywiki/index.html ~/.zen/ipfs/.${IPFSNODEID}/index.html
echo "Congratulation ! You are part of the astroport interplanetary fleet.
New. Activate your station offline storage.
Install ipfs companion : https://docs.ipfs.io/install/ipfs-companion/
FR : https://translate.google.com/translate?sl=auto&tl=fr&u=https://docs.ipfs.io/install/ipfs-companion/
"
echo "FIND AND CONNECT WITH YOUR FRIENDS
https://tube.copylaradio.com/ipns/$OASIS/.$OASIS/"
## OPEN https://translate.google.com/translate?sl=auto&tl=fr&u=https://docs.ipfs.io/install/ipfs-companion/
} # this ensures the entire script is downloaded #
# IPFS CONFIG documentation: https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#addressesswarm