add docker files

This commit is contained in:
Yann Autissier 2022-11-16 05:11:07 +00:00
parent fdd1509b99
commit 4b8a72e934
23 changed files with 354 additions and 55 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
.git*

1
.env.dist Normal file
View File

@ -0,0 +1 @@
DOCKER_SERVICE_1234_TAGS=urlprefix-astroport.${APP_DOMAIN}/

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.env

View File

@ -21,7 +21,7 @@ isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(
PORT=12345 PORT=12345
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); ## $USER running ipfs YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); ## $USER running ipfs
LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2) ## SWARM#0 ENTRANCE URL LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2) ## SWARM#0 ENTRANCE URL
mkdir -p ~/.zen/tmp/coucou/ mkdir -p ~/.zen/tmp/coucou/
@ -61,7 +61,7 @@ while true; do
MOATS=$(date -u +"%Y%m%d%H%M%S%4N") MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
## CHANGE NEXT PORT (HERE YOU CREATE A SOCKET QUEUE) ## CHANGE NEXT PORT (HERE YOU CREATE A SOCKET QUEUE)
[ ${PORT} -le 12345 ] && PORT=$((PORT+${RANDOM:0:3})) || PORT=$((PORT-${RANDOM:0:3})) [ ${PORT} -le 12345 ] && PORT=$((PORT+${RANDOM:0:2})) || PORT=$((PORT-${RANDOM:0:2}))
portinuse=$(ps auxf --sort=+utime | grep -w ${PORT} | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) portinuse=$(ps auxf --sort=+utime | grep -w ${PORT} | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
[[ $portinuse ]] && echo "$portinuse" && continue [[ $portinuse ]] && echo "$portinuse" && continue
## RANDOM PORT SWAPPINESS AVOIDING COLLISION ## RANDOM PORT SWAPPINESS AVOIDING COLLISION

View File

@ -11,7 +11,7 @@ countMErunning=$(ps auxf --sort=+utime | grep -w $ME | grep -v -E 'color=auto|gr
[[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0 [[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0
start=`date +%s` start=`date +%s`
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) && [[ ! $YOU ]] && echo "ipfs NOT RUNNING. EXIT" && exit 1 YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) && [[ ! $YOU ]] && echo "ipfs NOT RUNNING. EXIT" && exit 1
G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) && [[ ! $G1PUB ]] && echo "ERREUR G1PUB. EXIT" && exit 1 G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) && [[ ! $G1PUB ]] && echo "ERREUR G1PUB. EXIT" && exit 1
IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) || ( echo "noipfsid" && exit 1 ) IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) || ( echo "noipfsid" && exit 1 )
######################################################################## ########################################################################

View File

@ -53,7 +53,7 @@ isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(
[[ ! $myIP || $isLAN ]] && myIP="127.0.1.1" [[ ! $myIP || $isLAN ]] && myIP="127.0.1.1"
echo "Getting latest online TW..." echo "Getting latest online TW..."
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || 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) LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2)
echo "$LIBRA/ipns/$ASTRONAUTENS" echo "$LIBRA/ipns/$ASTRONAUTENS"
echo "http://$myIP:8080/ipns/$ASTRONAUTENS ($YOU)" echo "http://$myIP:8080/ipns/$ASTRONAUTENS ($YOU)"

View File

@ -13,7 +13,7 @@ MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}" ME="${0##*/}"
TS=$(date -u +%s%N | cut -b1-13) TS=$(date -u +%s%N | cut -b1-13)
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || echo " warning ipfs daemon not running" YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || echo " warning ipfs daemon not running"
isLAN=$(hostname -I | awk '{print $1}' | head -n 1 | 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=$(hostname -I | awk '{print $1}' | head -n 1 | 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])/")
IPFSGWESC="https:\/\/tube.copylaradio.com" && IPFSNGW="https://tube.copylaradio.com" IPFSGWESC="https:\/\/tube.copylaradio.com" && IPFSNGW="https://tube.copylaradio.com"

21
Makefile Normal file
View File

@ -0,0 +1,21 @@
MYOS ?= ../myos
MYOS_REPOSITORY ?= https://github.com/aynicos/myos
-include $(MYOS)/make/include.mk
$(MYOS):
-@git clone $(MYOS_REPOSITORY) $(MYOS)
.PHONY: all install shellcheck shellcheck-% tests
SHELL_FILES ?= $(wildcard .*/*.sh */*.sh */*/*.sh)
all: install tests
install:
./install.sh
tests: shellcheck
shellcheck:
shellcheck $(SHELL_FILES) ||:
shellcheck-%:
shellcheck $*/*.sh

View File

@ -17,7 +17,7 @@ isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(
PORT=12345 PORT=12345
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); ## $USER running ipfs YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); ## $USER running ipfs
LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2) ## SWARM#0 ENTRANCE URL LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2) ## SWARM#0 ENTRANCE URL
ncrunning=$(ps auxf --sort=+utime | grep -w 'nc -l -p 12345' | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) ncrunning=$(ps auxf --sort=+utime | grep -w 'nc -l -p 12345' | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)

View File

@ -106,7 +106,7 @@ if [[ $1 == "on" ]]; then
fi fi
## CHECK IF ASTROPORT/CRON/IPFS IS RUNNING ## CHECK IF ASTROPORT/CRON/IPFS IS RUNNING
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
[[ ! $YOU ]] && espeak "I P F S not running - EXIT" && exit 1 [[ ! $YOU ]] && espeak "I P F S not running - EXIT" && exit 1
######################################################################## ########################################################################

176
docker/Dockerfile Normal file
View File

@ -0,0 +1,176 @@
FROM debian:bullseye as dist
LABEL maintainer aynic.os <support+docker@asycn.io>
ARG DOCKER_BUILD_DIR
ARG DOCKER_MACHINE=x86_64
ARG DOCKER_SYSTEM=Linux
RUN apt-get update \
&& apt-get -fy upgrade \
&& apt-get -fy install \
bash \
bc \
cron \
curl \
dnsutils \
detox \
espeak \
fail2ban \
file \
ffmpeg \
gawk \
gettext \
git \
gpg \
gpg-agent \
html2text \
httrack \
imagemagick \
inotify-tools \
jq \
libsodium* \
make \
mp3info \
mpack \
msmtp \
musl-dev \
nano \
net-tools \
netcat-traditional \
nmap \
npm \
ntpdate \
openssh-client \
openssl* \
python3 \
python3-brotli \
python3-dotenv \
python3-gpg \
python3-jwcrypto \
python3-opencv \
python3-pip \
python3-setuptools \
python3-wheel \
qrencode \
screen \
socat \
ssmtp \
sudo \
tmux \
v4l-utils \
vlc \
vim-nox \
wget \
x11-utils \
xclip \
xz-utils \
youtube-dl \
zenity \
&& sed -i '/PDF/d' /etc/ImageMagick-6/policy.xml \
&& ln -f -s /usr/bin/python3 /usr/bin/python \
&& rm -rf /var/lib/apt/lists/*
RUN set -x && buildDeps=' \
build-essential \
libssl-dev \
cargo \
libffi-dev \
python3-dev \
swig \
' \
&& apt-get update \
&& apt-get install -y $buildDeps --no-install-recommends \
&& mkdir -p /usr/local/src/jaklis \
&& wget -qO - https://git.p2p.legal/axiom-team/jaklis/archive/master.tar.gz \
|tar --strip-components 1 -C /usr/local/src/jaklis -xzf - \
&& pip3 install -r /usr/local/src/jaklis/requirements.txt \
&& ln -s /usr/local/src/jaklis/jaklis.py /usr/local/bin/jaklis \
&& chmod 0755 /usr/local/bin/jaklis \
&& /usr/local/bin/jaklis --help >/dev/null \
&& mkdir -p /usr/local/src/dpgpid \
&& wget -qO - https://git.p2p.legal/aya/dpgpid/archive/master.tar.gz \
|tar --strip-components 1 -C /usr/local/src/dpgpid -xzf - \
&& pip3 install -r /usr/local/src/dpgpid/requirements.txt \
&& ln -s /usr/local/src/dpgpid/keygen /usr/local/bin/keygen \
&& chmod 0755 /usr/local/bin/keygen \
&& /usr/local/bin/keygen --help >/dev/null \
&& rm -rf /root/.cache \
&& apt-get clean
RUN npm install -g tiddlywiki sjcl-cli
ARG IPFS_VERSION=0.16.0
RUN { OS="$(echo ${DOCKER_SYSTEM} |awk '{print tolower($0)}')"; \
ARCH="$(echo ${DOCKER_MACHINE})"; \
wget -qO - https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.${OS}.${ARCH}.tar.xz \
|tar --strip-components 1 -C /usr/local/bin -xJf - shellcheck-stable/shellcheck; } \
&& { OS="$(echo ${DOCKER_SYSTEM} |awk '{print tolower($0)}')"; \
ARCH="$(echo ${DOCKER_MACHINE} |awk '/x86_64/ {print "amd64"}; /aarch64/ {print "arm64"}')"; \
wget -qO - https://github.com/ipfs/kubo/releases/download/v${IPFS_VERSION}/kubo_v${IPFS_VERSION}_${OS}-${ARCH}.tar.gz \
|tar --strip-components 1 -C /usr/local/bin -xzf - kubo/ipfs; } \
&& mkdir -p /usr/local/lib/shellspec \
&& wget -qO - https://github.com/shellspec/shellspec/archive/refs/heads/master.tar.gz \
|tar --strip-components 1 -C /usr/local/lib/shellspec -xzf - \
&& ln -s /usr/local/lib/shellspec/shellspec /usr/local/bin/shellspec
ADD https://raw.github.com/kvz/cronlock/master/cronlock /usr/local/bin/cronlock
RUN chmod +rx /usr/local/bin/cronlock
# config ssmtp
COPY templates/.ssmtprc /etc/ssmtp/ssmtp.conf
RUN chmod 600 /etc/ssmtp/ssmtp.conf
EXPOSE 1234 12345
COPY install.sh /install.sh
COPY ${DOCKER_BUILD_DIR}/docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["start"]
FROM dist as master
ARG DOCKER_BUILD_DIR
ARG DOCKER_GID
ARG SHELL=/bin/bash
ARG UID
ARG USER
ENV UID=${UID}
ENV GID=${UID}
ENV USER=zen
# If we provide a numeric UID
RUN [ "$UID" -eq "$UID" ] 2>/dev/null \
# Remove user with $UID if it is not our $USER
&& if [ "$(getent passwd $UID |awk -F: '{print $1}')" != "$USER" ]; then \
sed -i '/^'$(getent passwd $UID |awk -F: '{print $1}')':x:'$UID':/d' /etc/passwd; \
sed -i '/^'$(getent group $GID |awk -F: '{print $1}')':x:'$GID':/d' /etc/group; \
fi \
# Force $UID if our $USER already exists
&& sed -i 's/^'$USER':x:[0-9]\+:[0-9]\+:/'$USER':x:'$UID':'$GID':/' /etc/passwd \
&& sed -i 's/^'$USER':x:[0-9]\+:/'$USER':x:'$GID':/' /etc/group \
# Create $USER if it does not exist
&& if [ "$(getent passwd $UID)" = "" ]; then \
echo "$USER:x:$UID:$GID::/home/$USER:$SHELL" >> /etc/passwd; \
echo "$USER:\!:$(($(date +%s) / 60 / 60 / 24)):0:99999:7:::" >> /etc/shadow; \
echo "$USER:x:$GID:" >> /etc/group; \
fi \
&& mkdir -p /home/$USER \
&& chown $UID:$GID /home/$USER \
|| true
## sudo
RUN echo "$USER ALL=(ALL:ALL) NOPASSWD: ALL" > "/etc/sudoers.d/$USER"
# config ssmtp
RUN echo "$USER:support@g1sms.fr:mail.asycn.io:587" >> /etc/ssmtp/revaliases
# config crontab
RUN echo "SHELL=/bin/bash" > /var/spool/cron/crontabs/$USER \
&& echo "PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" >> /var/spool/cron/crontabs/$USER \
&& echo "12 20 * * * /bin/bash /home/zen/.zen/20h12.process.sh > /tmp/20h12.log 2>&1" >> /var/spool/cron/crontabs/$USER \
&& chown $USER /var/spool/cron/crontabs/$USER
USER $USER
ENV SHELL=${SHELL}
WORKDIR /home/$USER
RUN mkdir ~/.zen ~/.zen/tmp ~/astroport

View File

@ -0,0 +1,20 @@
version: '3.6'
services:
docker:
environment:
- ENV=${ENV}
- SHELL=${DOCKER_SHELL}
image: ${DOCKER_REPOSITORY}/docker:${DOCKER_IMAGE_TAG}
labels:
- SERVICE_1234_CHECK_HTTP=/
- SERVICE_1234_NAME=${COMPOSE_SERVICE_NAME}-docker-1234
- SERVICE_1234_TAGS=${DOCKER_SERVICE_1234_TAGS}
networks:
private:
external: true
name: ${DOCKER_NETWORK_PRIVATE}
public:
external: true
name: ${DOCKER_NETWORK_PUBLIC}

36
docker/docker-compose.yml Normal file
View File

@ -0,0 +1,36 @@
version: '3.6'
services:
docker:
build:
args:
- DOCKER_BUILD_DIR=docker
- GID=${GID}
- IPFS_VERSION=${IPFS_VERSION:-0.16.0}
- UID=${UID}
context: ../
dockerfile: docker/Dockerfile
network_mode: host
restart: always
tty: true
user: ${UID}:${GID}
volumes:
- data:/home/zen/astroport:cached
- ipfs:/home/zen/.ipfs:cached,ro
- zen:/home/zen/.zen:delegated
working_dir: /home/zen/.zen
volumes:
data:
ipfs:
driver: local
driver_opts:
type: none
device: ${HOME}/.ipfs
o: bind
zen:
driver: local
driver_opts:
type: none
device: ${HOME}/.zen
o: bind

37
docker/docker-entrypoint.sh Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env sh
set -euo errexit
# Print a debug message if debug mode is on ($DEBUG is not empty)
# @param message
debug_msg ()
{
if [ -n "${DEBUG:-}" -a "${DEBUG:-}" != "false" ]; then
echo "$@"
fi
}
mkdir -p /home/zen/.zen/tmp
SOURCE_DIR="/home/zen/.zen/Astroport.ONE"
[ -d "$SOURCE_DIR" ] && cd "$SOURCE_DIR" && git pull -q || git clone -q https://git.p2p.legal/qo-op/Astroport.ONE.git "$SOURCE_DIR"
cd "$SOURCE_DIR"
sudo -n /usr/sbin/cron -L/dev/stdout
case "${1:-${cmd:-start}}" in
start)
debug_msg "Starting $SOURCE_DIR/start.sh ..."
exec "$SOURCE_DIR"/start.sh
;;
install)
debug_msg "Installing..."
exec /install.sh
;;
*)
debug_msg "Exec: $@"
exec "$@"
;;
esac

View File

@ -38,7 +38,7 @@ echo
## VERIFY SOFTWARE DEPENDENCIES ## VERIFY SOFTWARE DEPENDENCIES
[[ ! $(which ipfs) ]] && echo "EXIT. Vous devez avoir installé ipfs CLI sur votre ordinateur" && echo "https://dist.ipfs.io/#go-ipfs" && exit 1 [[ ! $(which ipfs) ]] && echo "EXIT. Vous devez avoir installé ipfs CLI sur votre ordinateur" && echo "https://dist.ipfs.io/#go-ipfs" && exit 1
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
[[ ! $YOU ]] && echo "Lancez 'ipfs daemon' SVP sudo systemctl start ipfs" && exit 1 [[ ! $YOU ]] && echo "Lancez 'ipfs daemon' SVP sudo systemctl start ipfs" && exit 1
IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID)

View File

@ -120,7 +120,7 @@ do
## GET FRIEND TW !! ## GET FRIEND TW !!
echo "Getting latest online TW..." echo "Getting latest online TW..."
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || 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) LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2)
echo "$LIBRA/ipns/$ASTRONAUTENS" echo "$LIBRA/ipns/$ASTRONAUTENS"
echo "http://$myIP:8080/ipns/$ASTRONAUTENS ($YOU)" echo "http://$myIP:8080/ipns/$ASTRONAUTENS ($YOU)"

View File

@ -11,7 +11,7 @@ countMErunning=$(ps auxf --sort=+utime | grep -w $ME | grep -v -E 'color=auto|gr
[[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0 [[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0
start=`date +%s` start=`date +%s`
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) && [[ ! $YOU ]] && echo "ipfs NOT RUNNING. EXIT" && exit 1 YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) && [[ ! $YOU ]] && echo "ipfs NOT RUNNING. EXIT" && exit 1
G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) && [[ ! $G1PUB ]] && echo "ERREUR G1PUB. EXIT" && exit 1 G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) && [[ ! $G1PUB ]] && echo "ERREUR G1PUB. EXIT" && exit 1
IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) || ( echo "noipfsid" && exit 1 ) IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) || ( echo "noipfsid" && exit 1 )
######################################################################## ########################################################################

View File

@ -16,7 +16,7 @@ PLAYER="$3"
PSEUDO="$4" PSEUDO="$4"
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || 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) LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2)
MOATS=$(date -u +"%Y%m%d%H%M%S%4N") MOATS=$(date -u +"%Y%m%d%H%M%S%4N")

45
tools/ipfs_config.sh Normal file
View File

@ -0,0 +1,45 @@
#!/bin/bash
myIP=$(hostname -I | awk '{print $1}')
isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
###########################################
### 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 20
ipfs config --json Swarm.ConnMgr.HighWater 40
[[ ! $isLAN ]] && ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://'$myIP':8080", "http://127.0.0.1:8080", "http://127.0.1.1:8080" ]' \
|| ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://127.0.0.1:8080", "http://127.0.1.1:8080" ]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["true"]'
## For ipfs.js = https://github.com/ipfs/js-ipfs/blob/master/docs/DELEGATE_ROUTERS.md
ipfs config --json Addresses.Swarm | jq '. += ["/ip4/0.0.0.0/tcp/30215/ws"]' > /tmp/30215.ws
ipfs config --json Addresses.Swarm "$(cat /tmp/30215.ws)"
ipfs config Addresses.API "/ip4/0.0.0.0/tcp/5001"
ipfs config Addresses.Gateway "/ip4/0.0.0.0/tcp/8080"
######### CLEAN DEFAULT BOOTSTRAP ADD Astroport.ONE Officials ###########
ipfs bootstrap rm --all
for bootnode in $(cat ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | grep -Ev "#") # remove comments
do
ipfsnodeid=${bootnode##*/}
ipfs bootstrap add $bootnode
done

View File

@ -24,7 +24,7 @@ err() {
# CHECK node IP isLAN? # CHECK node IP isLAN?
myIP=$(hostname -I | awk '{print $1}') myIP=$(hostname -I | awk '{print $1}')
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 $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
MACHINE_TYPE=`uname -m` MACHINE_TYPE=`uname -m`
@ -74,46 +74,7 @@ sudo systemctl enable ipfs
########################################### ###########################################
# ACTIVATE IPFS OPTIONS: #swarm0 INIT # ACTIVATE IPFS OPTIONS: #swarm0 INIT
########################################### ###########################################
### IMPORTANT !!!!!!! IMPORTANT !!!!!! ~/.zen/Astroport.ONE/tools/ipfs_config.sh
###########################################
# 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 20
ipfs config --json Swarm.ConnMgr.HighWater 40
[[ ! $isLAN ]] && ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://'$myIP':8080", "http://127.0.0.1:8080", "http://127.0.1.1:8080" ]' \
|| ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://127.0.0.1:8080", "http://127.0.1.1:8080" ]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["true"]'
## For ipfs.js = https://github.com/ipfs/js-ipfs/blob/master/docs/DELEGATE_ROUTERS.md
ipfs config --json Addresses.Swarm | jq '. += ["/ip4/0.0.0.0/tcp/30215/ws"]' > /tmp/30215.ws
ipfs config --json Addresses.Swarm "$(cat /tmp/30215.ws)"
ipfs config Addresses.API "/ip4/0.0.0.0/tcp/5001"
ipfs config Addresses.Gateway "/ip4/0.0.0.0/tcp/8080"
######### CLEAN DEFAULT BOOTSTRAP ADD Astroport.ONE Officials ###########
ipfs bootstrap rm --all
for bootnode in $(cat ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | grep -Ev "#") # remove comments
do
ipfsnodeid=${bootnode##*/}
ipfs bootstrap add $bootnode
done
sudo systemctl restart ipfs sudo systemctl restart ipfs
## Add ulimit "open files" (avoid ipfs hang) ## Add ulimit "open files" (avoid ipfs hang)

View File

@ -14,7 +14,7 @@ countMErunning=$(ps auxf --sort=+utime | grep -w $ME | grep -v -E 'color=auto|gr
[[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0 [[ $countMErunning -gt 2 ]] && echo "$ME already running $countMErunning time" && exit 0
start=`date +%s` start=`date +%s`
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID)
[[ ! $IPFSNODEID ]] && echo 'ERROR missing IPFS Node id !! IPFS is not responding !?' && exit 1 [[ ! $IPFSNODEID ]] && echo 'ERROR missing IPFS Node id !! IPFS is not responding !?' && exit 1

View File

@ -9,7 +9,7 @@
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}" ME="${0##*/}"
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
IPFSNODEID=$(ipfs id -f='<id>\n') IPFSNODEID=$(ipfs id -f='<id>\n')
G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) G1PUB=$(cat ~/.zen/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
# GET XZUID # GET XZUID

View File

@ -20,7 +20,7 @@ ASTRONAUTENS=$(ipfs key list -l | grep -w ${PLAYER} | cut -d ' ' -f1)
[[ ! $ASTRONAUTENS ]] && echo "${PLAYER} CLEF IPNS INTROUVABLE - EXIT -" && exit 1 [[ ! $ASTRONAUTENS ]] && echo "${PLAYER} CLEF IPNS INTROUVABLE - EXIT -" && exit 1
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || 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) LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2)
MOATS=$(date -u +"%Y%m%d%H%M%S%4N") MOATS=$(date -u +"%Y%m%d%H%M%S%4N")