From 2e826c1981d6bb4635590eea08fe3a4081e40997 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Mon, 16 Mar 2020 16:17:01 +0100 Subject: [PATCH 01/35] add dockerfile --- Dockerfile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ffa7773 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM debian@sha256:bf338ddc710dfb9b907a29ba661b35d0f6b3eae043515c4315f64c6e93409e94 +LABEL MAINTAINER=chamalow <@qio8/4L4vnzq3qRD0dqKI7sTpey54u8ZWbaICfpJOZw=.ed25519> +ENV DEBIAN_FRONTEND noninteractive +COPY ./key_create_dunikey.py /usr/bin/key_create_dunikey +COPY ./process-likes-g1tx.sh /usr/bin/process-likes-g1tx +COPY ./secret2dunikey.sh /usr/bin/secret2dunikey + +RUN apt-get update -y && \ + apt-get install python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-2 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 -y && \ + chmod +x /usr/bin/secret2dunikey /usr/bin/process-likes-g1tx /usr/bin/key_create_dunikey&& \ + pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + useradd -ms /bin/bash astroport + +USER astroport +WORKDIR /home/astroport +RUN mkdir -p /home/astroport/.ssb/ +VOLUME [ "/home/astroport/.ssb/" ] +EXPOSE 8008 + +ENTRYPOINT [ "/bin/bash" ] +CMD ["process-likes-g1tx"] \ No newline at end of file From 367c37c8b189a7fa6fe1a6a0ac818c9e12aa0945 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Mon, 16 Mar 2020 16:40:23 +0100 Subject: [PATCH 02/35] change documentation --- Dockerfile | 4 ++++ readme.md | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Dockerfile b/Dockerfile index ffa7773..e7c1773 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,10 @@ RUN apt-get update -y && \ rm -rf /var/lib/apt/lists/* && \ useradd -ms /bin/bash astroport +RUN git clone https://git.scuttlebot.io/%25133ulDgs%2FoC1DXjoK04vDFy6DgVBB%2FZok15YJmuhD5Q%3D.sha256 sbotc +WORKDIR /sbotc +RUN make && make install + USER astroport WORKDIR /home/astroport RUN mkdir -p /home/astroport/.ssb/ diff --git a/readme.md b/readme.md index a0a9245..e664e0f 100644 --- a/readme.md +++ b/readme.md @@ -59,4 +59,22 @@ Then, browse your filesystem to select your Duniter secret key stored in ~/.ssb/ ![Cesium log with keychain file](https://git.p2p.legal/axiom-team/ssb-g1like/raw/dev-boris/doc/cesium-dunikey-800.png) +## With docker (experimental) +First you need to build docker image + +``` +docker build -t ssb-g1like . +``` + +create your dunikey + +``` +docker run -ti --rm -v ~/.ssb:/home/astroport/.ssb ssb-g1like -c /usr/bin/secret2dunikey +``` + +run main script + +``` +docker run -ti --rm -v ~/.ssb:/home/astroport/.ssb ssb-g1like +``` From b8b5ac3d2be204fd79bc0d679e4b80f0e478c91f Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Tue, 17 Mar 2020 17:45:27 +0100 Subject: [PATCH 03/35] add base58 and build-essential package --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e7c1773..4b7d9e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ COPY ./process-likes-g1tx.sh /usr/bin/process-likes-g1tx COPY ./secret2dunikey.sh /usr/bin/secret2dunikey RUN apt-get update -y && \ - apt-get install python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-2 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 -y && \ + apt-get install build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-2 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 -y && \ chmod +x /usr/bin/secret2dunikey /usr/bin/process-likes-g1tx /usr/bin/key_create_dunikey&& \ pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ apt-get clean && \ From 61a94c4d9defa22e108470cee293b6d6300aee70 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Wed, 18 Mar 2020 14:14:53 +0100 Subject: [PATCH 04/35] updaate python3-wheel --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4b7d9e6..7bf3594 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ COPY ./process-likes-g1tx.sh /usr/bin/process-likes-g1tx COPY ./secret2dunikey.sh /usr/bin/secret2dunikey RUN apt-get update -y && \ - apt-get install build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-2 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 -y && \ + apt-get install build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-3 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 -y && \ chmod +x /usr/bin/secret2dunikey /usr/bin/process-likes-g1tx /usr/bin/key_create_dunikey&& \ pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ apt-get clean && \ From bf909804a5a62d2efca85cc3c8e6b150ce48b295 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Wed, 18 Mar 2020 17:48:48 +0100 Subject: [PATCH 05/35] add autoconf and libtool package --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7bf3594..62549ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ COPY ./process-likes-g1tx.sh /usr/bin/process-likes-g1tx COPY ./secret2dunikey.sh /usr/bin/secret2dunikey RUN apt-get update -y && \ - apt-get install build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-3 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 -y && \ + apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-3 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 -y && \ chmod +x /usr/bin/secret2dunikey /usr/bin/process-likes-g1tx /usr/bin/key_create_dunikey&& \ pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ apt-get clean && \ From bbb006e452412c0cf8f7d70200ffae700dc5e66d Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Thu, 19 Mar 2020 08:54:30 +0100 Subject: [PATCH 06/35] try to add nvm --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 62549ce..614ff0f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,9 +6,10 @@ COPY ./process-likes-g1tx.sh /usr/bin/process-likes-g1tx COPY ./secret2dunikey.sh /usr/bin/secret2dunikey RUN apt-get update -y && \ - apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-3 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 -y && \ + apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-3 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 -y && \ chmod +x /usr/bin/secret2dunikey /usr/bin/process-likes-g1tx /usr/bin/key_create_dunikey&& \ pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ useradd -ms /bin/bash astroport From 7ef3a65ab5d63989b30974441582eed8fd9da8aa Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Mon, 16 Mar 2020 16:17:01 +0100 Subject: [PATCH 07/35] add dockerfile --- Dockerfile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ffa7773 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM debian@sha256:bf338ddc710dfb9b907a29ba661b35d0f6b3eae043515c4315f64c6e93409e94 +LABEL MAINTAINER=chamalow <@qio8/4L4vnzq3qRD0dqKI7sTpey54u8ZWbaICfpJOZw=.ed25519> +ENV DEBIAN_FRONTEND noninteractive +COPY ./key_create_dunikey.py /usr/bin/key_create_dunikey +COPY ./process-likes-g1tx.sh /usr/bin/process-likes-g1tx +COPY ./secret2dunikey.sh /usr/bin/secret2dunikey + +RUN apt-get update -y && \ + apt-get install python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-2 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 -y && \ + chmod +x /usr/bin/secret2dunikey /usr/bin/process-likes-g1tx /usr/bin/key_create_dunikey&& \ + pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + useradd -ms /bin/bash astroport + +USER astroport +WORKDIR /home/astroport +RUN mkdir -p /home/astroport/.ssb/ +VOLUME [ "/home/astroport/.ssb/" ] +EXPOSE 8008 + +ENTRYPOINT [ "/bin/bash" ] +CMD ["process-likes-g1tx"] \ No newline at end of file From 671916418b5d54e09df4e9d6af0b949d5be40054 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Mon, 16 Mar 2020 16:40:23 +0100 Subject: [PATCH 08/35] change documentation --- Dockerfile | 4 ++++ readme.md | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Dockerfile b/Dockerfile index ffa7773..e7c1773 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,10 @@ RUN apt-get update -y && \ rm -rf /var/lib/apt/lists/* && \ useradd -ms /bin/bash astroport +RUN git clone https://git.scuttlebot.io/%25133ulDgs%2FoC1DXjoK04vDFy6DgVBB%2FZok15YJmuhD5Q%3D.sha256 sbotc +WORKDIR /sbotc +RUN make && make install + USER astroport WORKDIR /home/astroport RUN mkdir -p /home/astroport/.ssb/ diff --git a/readme.md b/readme.md index a0a9245..e664e0f 100644 --- a/readme.md +++ b/readme.md @@ -59,4 +59,22 @@ Then, browse your filesystem to select your Duniter secret key stored in ~/.ssb/ ![Cesium log with keychain file](https://git.p2p.legal/axiom-team/ssb-g1like/raw/dev-boris/doc/cesium-dunikey-800.png) +## With docker (experimental) +First you need to build docker image + +``` +docker build -t ssb-g1like . +``` + +create your dunikey + +``` +docker run -ti --rm -v ~/.ssb:/home/astroport/.ssb ssb-g1like -c /usr/bin/secret2dunikey +``` + +run main script + +``` +docker run -ti --rm -v ~/.ssb:/home/astroport/.ssb ssb-g1like +``` From e4a34db411dc1c90d3fe2f0e419c708177b6aa60 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Tue, 17 Mar 2020 17:45:27 +0100 Subject: [PATCH 09/35] add base58 and build-essential package --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e7c1773..4b7d9e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ COPY ./process-likes-g1tx.sh /usr/bin/process-likes-g1tx COPY ./secret2dunikey.sh /usr/bin/secret2dunikey RUN apt-get update -y && \ - apt-get install python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-2 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 -y && \ + apt-get install build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-2 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 -y && \ chmod +x /usr/bin/secret2dunikey /usr/bin/process-likes-g1tx /usr/bin/key_create_dunikey&& \ pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ apt-get clean && \ From 79173ac78e0a67ab83d4b45638bbc51eec8df00f Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Wed, 18 Mar 2020 14:14:53 +0100 Subject: [PATCH 10/35] updaate python3-wheel --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4b7d9e6..7bf3594 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ COPY ./process-likes-g1tx.sh /usr/bin/process-likes-g1tx COPY ./secret2dunikey.sh /usr/bin/secret2dunikey RUN apt-get update -y && \ - apt-get install build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-2 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 -y && \ + apt-get install build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-3 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 -y && \ chmod +x /usr/bin/secret2dunikey /usr/bin/process-likes-g1tx /usr/bin/key_create_dunikey&& \ pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ apt-get clean && \ From 022e8ed558a1043ca2d285c94ea6efa0a0c796d2 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Wed, 18 Mar 2020 17:48:48 +0100 Subject: [PATCH 11/35] add autoconf and libtool package --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7bf3594..62549ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ COPY ./process-likes-g1tx.sh /usr/bin/process-likes-g1tx COPY ./secret2dunikey.sh /usr/bin/secret2dunikey RUN apt-get update -y && \ - apt-get install build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-3 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 -y && \ + apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-3 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 -y && \ chmod +x /usr/bin/secret2dunikey /usr/bin/process-likes-g1tx /usr/bin/key_create_dunikey&& \ pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ apt-get clean && \ From c39715a743fcb98ceb471e550018a4de274ac105 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Thu, 19 Mar 2020 08:54:30 +0100 Subject: [PATCH 12/35] try to add nvm --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 62549ce..614ff0f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,9 +6,10 @@ COPY ./process-likes-g1tx.sh /usr/bin/process-likes-g1tx COPY ./secret2dunikey.sh /usr/bin/secret2dunikey RUN apt-get update -y && \ - apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-3 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 -y && \ + apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-3 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 -y && \ chmod +x /usr/bin/secret2dunikey /usr/bin/process-likes-g1tx /usr/bin/key_create_dunikey&& \ pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ useradd -ms /bin/bash astroport From 4d1071d3a78405f8074d87d9b6d8388fd36a6b7b Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Thu, 19 Mar 2020 15:25:21 +0100 Subject: [PATCH 13/35] install nodejs rust dup-mnemonic --- Dockerfile | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 614ff0f..dcad738 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,16 @@ FROM debian@sha256:bf338ddc710dfb9b907a29ba661b35d0f6b3eae043515c4315f64c6e93409e94 + LABEL MAINTAINER=chamalow <@qio8/4L4vnzq3qRD0dqKI7sTpey54u8ZWbaICfpJOZw=.ed25519> -ENV DEBIAN_FRONTEND noninteractive + +ENV DEBIAN_FRONTEND noninteractive +ENV NVM_INSTALL_DIR /opt/nvm +ENV NVM_DIR /usr/local/nvm +ENV NODE_VERSION v12.16.1 +ENV RUSTUP_HOME /usr/local/rustup +ENV CARGO_HOME /usr/local/cargo +ENV PATH /usr/local/cargo/bin:$PATH +ENV RUST_VERSION 1.42.0 + COPY ./key_create_dunikey.py /usr/bin/key_create_dunikey COPY ./process-likes-g1tx.sh /usr/bin/process-likes-g1tx COPY ./secret2dunikey.sh /usr/bin/secret2dunikey @@ -9,18 +19,57 @@ RUN apt-get update -y && \ apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-3 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 -y && \ chmod +x /usr/bin/secret2dunikey /usr/bin/process-likes-g1tx /usr/bin/key_create_dunikey&& \ pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ useradd -ms /bin/bash astroport +RUN set -eux; \ + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='ad1f8b5199b3b9e231472ed7aa08d2e5d1d539198a15c5b1e53c746aad81d27b' ;; \ + armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='6c6c3789dabf12171c7f500e06d21d8004b5318a5083df8b0b02c0e5ef1d017b' ;; \ + arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='26942c80234bac34b3c1352abbd9187d3e23b43dae3cf56a9f9c1ea8ee53076d' ;; \ + i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='27ae12bc294a34e566579deba3e066245d09b8871dc021ef45fc715dced05297' ;; \ + *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ + esac; \ + url="https://static.rust-lang.org/rustup/archive/1.21.1/${rustArch}/rustup-init"; \ + curl -O "$url"; \ + echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ + chmod +x rustup-init; \ + ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION; \ + rm rustup-init; \ + chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ + rustup --version; \ + cargo --version; \ + rustc --version; + +RUN git clone https://github.com/creationix/nvm.git $NVM_INSTALL_DIR && \ + . $NVM_INSTALL_DIR/nvm.sh && \ + nvm install --lts && \ + nvm alias default $NODE_VERSION && \ + nvm use default && \ + echo "export NVM_DIR=${NVM_DIR}" > /home/astroport/.bashrc && \ + echo ". ${NVM_INSTALL_DIR}/nvm.sh" > /home/astroport/.bashrc && \ + chown -R astroport:astroport $NVM_DIR + RUN git clone https://git.scuttlebot.io/%25133ulDgs%2FoC1DXjoK04vDFy6DgVBB%2FZok15YJmuhD5Q%3D.sha256 sbotc WORKDIR /sbotc RUN make && make install +WORKDIR / +RUN git clone https://git.duniter.org/tools/dup-mnemonic-rs +WORKDIR /dup-mnemonic-rs +RUN cargo build --release && \ + cp target/release/dup-mnemonic /usr/local/bin + USER astroport WORKDIR /home/astroport -RUN mkdir -p /home/astroport/.ssb/ + +RUN . ~/.bashrc && \ + mkdir -p /home/astroport/.ssb/ && \ + npm install sodium-native@3.0.0 ssb-backlinks@1.0.0 && \ + npm install -g ssb-server@15.2.0 + VOLUME [ "/home/astroport/.ssb/" ] EXPOSE 8008 From faef88183b82ae1734adfaf60a391a6dfd6e602b Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Mon, 23 Mar 2020 08:52:28 +0100 Subject: [PATCH 14/35] change entrypoint --- Dockerfile | 11 +++++++++-- docker/config | 19 +++++++++++++++++++ docker/docker-entrypoint.sh | 7 +++++++ docker/run-ssb-pub.sh | 4 ++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 docker/config create mode 100644 docker/docker-entrypoint.sh create mode 100644 docker/run-ssb-pub.sh diff --git a/Dockerfile b/Dockerfile index dcad738..a0a8be0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,16 +62,23 @@ WORKDIR /dup-mnemonic-rs RUN cargo build --release && \ cp target/release/dup-mnemonic /usr/local/bin + +COPY ./docker/config /home/astroport/.ssb/ +COPY ./docker/run-ssb-pub.sh /home/astroport/ +COPY ./docker/docker-entrypoint.sh /home/astroport/ + +RUN chmod +x /home/astroport/run-ssb-pub.sh /home/astroport/docker-entrypoint.sh + USER astroport WORKDIR /home/astroport RUN . ~/.bashrc && \ mkdir -p /home/astroport/.ssb/ && \ - npm install sodium-native@3.0.0 ssb-backlinks@1.0.0 && \ + npm install -g sodium-native@3.0.0 ssb-backlinks@1.0.0 && \ npm install -g ssb-server@15.2.0 VOLUME [ "/home/astroport/.ssb/" ] EXPOSE 8008 ENTRYPOINT [ "/bin/bash" ] -CMD ["process-likes-g1tx"] \ No newline at end of file +CMD ["docker-entrypoint.sh"] \ No newline at end of file diff --git a/docker/config b/docker/config new file mode 100644 index 0000000..92890fd --- /dev/null +++ b/docker/config @@ -0,0 +1,19 @@ +{ + "connections": { + "incoming": { + "net": [ + { + "scope": "public", "external": ["127.0.0.1"], "transform": "shs", "port": 8008 + }, + { "scope": "private", "transform": "shs", "port": 8008, "host": "127.0.0.1" } + ] + }, + "outgoing": { + "net": [ + { + "transform": "shs" + } + ] + } + } +} \ No newline at end of file diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh new file mode 100644 index 0000000..db06137 --- /dev/null +++ b/docker/docker-entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +. ~/.bashrc + +echo "run ssb-server" +bash /home/astroport/run-ssb-pub.sh + +tail -f /dev/null \ No newline at end of file diff --git a/docker/run-ssb-pub.sh b/docker/run-ssb-pub.sh new file mode 100644 index 0000000..50c1b65 --- /dev/null +++ b/docker/run-ssb-pub.sh @@ -0,0 +1,4 @@ +#!/bin/bash +while true; do + ssb-server start --host 127.0.0.1 +done \ No newline at end of file From aefe3fa53f747ed5230402a4df641a5df94d4848 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Mon, 23 Mar 2020 09:37:31 +0100 Subject: [PATCH 15/35] add some script and samples --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a0a8be0..9cf8dab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,10 +14,12 @@ ENV RUST_VERSION 1.42.0 COPY ./key_create_dunikey.py /usr/bin/key_create_dunikey COPY ./process-likes-g1tx.sh /usr/bin/process-likes-g1tx COPY ./secret2dunikey.sh /usr/bin/secret2dunikey +COPY ./find_ssb_user_G1_pubkey.sh /usr/bin/find_ssb_user_G1_pubkey +COPY ./tip.sh /usr/bin/tip RUN apt-get update -y && \ apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-3 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 -y && \ - chmod +x /usr/bin/secret2dunikey /usr/bin/process-likes-g1tx /usr/bin/key_create_dunikey&& \ + chmod +x /usr/bin/secret2dunikey /usr/bin/process-likes-g1tx /usr/bin/key_create_dunikey /usr/bin/find_ssb_user_G1_pubkey && \ pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ @@ -66,6 +68,7 @@ RUN cargo build --release && \ COPY ./docker/config /home/astroport/.ssb/ COPY ./docker/run-ssb-pub.sh /home/astroport/ COPY ./docker/docker-entrypoint.sh /home/astroport/ +COPY ./samples /home/astroport/ RUN chmod +x /home/astroport/run-ssb-pub.sh /home/astroport/docker-entrypoint.sh From 7592f0fd1d79fd24701fe62000cd0b66d8d2df16 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Mon, 23 Mar 2020 13:51:32 +0100 Subject: [PATCH 16/35] changement d'approche avec docker-compose multiple petit container --- Dockerfile | 3 +-- docker-compose.yml | 51 +++++++++++++++++++++++++++++++++++ ssb-server/Dockerfile | 39 +++++++++++++++++++++++++++ {docker => ssb-server}/config | 0 {docker => ssb-server}/run-ssb-pub.sh | 1 + 5 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 docker-compose.yml create mode 100644 ssb-server/Dockerfile rename {docker => ssb-server}/config (100%) rename {docker => ssb-server}/run-ssb-pub.sh (79%) diff --git a/Dockerfile b/Dockerfile index 9cf8dab..2d7b590 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,14 +12,13 @@ ENV PATH /usr/local/cargo/bin:$PATH ENV RUST_VERSION 1.42.0 COPY ./key_create_dunikey.py /usr/bin/key_create_dunikey -COPY ./process-likes-g1tx.sh /usr/bin/process-likes-g1tx COPY ./secret2dunikey.sh /usr/bin/secret2dunikey COPY ./find_ssb_user_G1_pubkey.sh /usr/bin/find_ssb_user_G1_pubkey COPY ./tip.sh /usr/bin/tip RUN apt-get update -y && \ apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 python3-wheel=0.33.6-3 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 -y && \ - chmod +x /usr/bin/secret2dunikey /usr/bin/process-likes-g1tx /usr/bin/key_create_dunikey /usr/bin/find_ssb_user_G1_pubkey && \ + chmod +x /usr/bin/secret2dunikey /usr/bin/key_create_dunikey /usr/bin/find_ssb_user_G1_pubkey /usr/bin/tip && \ pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..aaba222 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,51 @@ +version: "3" +services: + redis: + image: redis + mongo: + image: mongo + volumes: + - "./data/mongo:/data" + ohmyform: + image: ohmyform/ohmyform + #build: . + #volumes: + # - ".:/opt/app" + environment: + CREATE_ADMIN: "TRUE" + SOCKET_URL: 'localhost:5000' + SOCKET_PORT: "5000" + SOCKET_PORT_EXTERN_VISIBLE: "TRUE" + MONGODB_URI: mongodb://mongo/ohmyform + REDIS_URL: redis://redis + MAILER_SMTP_HOST: mail + MAILER_SMTP_PORT: 1025 + # command: grunt dev # override command to have livereloading on file change + links: + - mongo + - redis + - mail + ports: + - "5000:5000" + depends_on: + - mongo + - redis + mail: + image: mailhog/mailhog + ports: + - "5050:8025" + mongoexpress: + image: mongo-express + environment: + ME_CONFIG_MONGODB_SERVER: mongo + ports: + - "5051:8081" + links: + - mongo + depends_on: + - mongo + ssb-server: + build: + context: ./ssb-server + dockerfile: Dockerfile + ports \ No newline at end of file diff --git a/ssb-server/Dockerfile b/ssb-server/Dockerfile new file mode 100644 index 0000000..89099e1 --- /dev/null +++ b/ssb-server/Dockerfile @@ -0,0 +1,39 @@ +FROM debian@sha256:bf338ddc710dfb9b907a29ba661b35d0f6b3eae043515c4315f64c6e93409e94 + +LABEL MAINTAINER=chamalow <@qio8/4L4vnzq3qRD0dqKI7sTpey54u8ZWbaICfpJOZw=.ed25519> + +ENV DEBIAN_FRONTEND noninteractive +ENV NVM_INSTALL_DIR /opt/nvm +ENV NVM_DIR /usr/local/nvm +ENV NODE_VERSION v12.16.1 + +RUN apt-get update -y && \ + apt-get install autoconf=2.69-11.1 build-essential=12.8 libsodium-dev=1.0.18-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + useradd -ms /bin/bash astroport + +RUN git clone https://github.com/creationix/nvm.git $NVM_INSTALL_DIR && \ + . $NVM_INSTALL_DIR/nvm.sh && \ + nvm install --lts && \ + nvm alias default $NODE_VERSION && \ + nvm use default && \ + echo "export NVM_DIR=${NVM_DIR}" > /home/astroport/.bashrc && \ + echo ". ${NVM_INSTALL_DIR}/nvm.sh" > /home/astroport/.bashrc && \ + chown -R astroport:astroport $NVM_DIR + +USER astroport +WORKDIR /home/astroport + +RUN . ~/.bashrc && \ + mkdir -p /home/astroport/.ssb/ && \ + npm install -g sodium-native@3.0.0 ssb-backlinks@1.0.0 && \ + npm install -g ssb-server@15.2.0 + +COPY ./config /home/astroport/.ssb/ +COPY ./run-ssb-pub.sh /home/astroport/run-ssb-pub.sh + +EXPOSE 8008 +VOLUME [ "/home/astroport/.ssb" ] +ENTRYPOINT [ "/bin/bash" ] +CMD [ "/home/astroport/run-ssb-pub.sh" ] diff --git a/docker/config b/ssb-server/config similarity index 100% rename from docker/config rename to ssb-server/config diff --git a/docker/run-ssb-pub.sh b/ssb-server/run-ssb-pub.sh similarity index 79% rename from docker/run-ssb-pub.sh rename to ssb-server/run-ssb-pub.sh index 50c1b65..e03e10f 100644 --- a/docker/run-ssb-pub.sh +++ b/ssb-server/run-ssb-pub.sh @@ -1,4 +1,5 @@ #!/bin/bash +. ~/.bashrc while true; do ssb-server start --host 127.0.0.1 done \ No newline at end of file From 10b85b1dbec2e3e813ce7c7a14f50fd938f811ac Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Mon, 23 Mar 2020 17:21:54 +0100 Subject: [PATCH 17/35] =?UTF-8?q?cr=C3=A9ation=20d'une=20image=20pour=20se?= =?UTF-8?q?cret2dunikey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 9 ++++++++- secret2dunikey/Dockerfile | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 secret2dunikey/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml index aaba222..7393324 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -48,4 +48,11 @@ services: build: context: ./ssb-server dockerfile: Dockerfile - ports \ No newline at end of file + ports: + - "8008:8008" + volumes: + - ~/.ssb-test/:/home/astroport/.ssb + secret2dunikey: + build: + context: . + dockerfile: ./secret2dunikey/Dockerfile \ No newline at end of file diff --git a/secret2dunikey/Dockerfile b/secret2dunikey/Dockerfile new file mode 100644 index 0000000..c9bfa39 --- /dev/null +++ b/secret2dunikey/Dockerfile @@ -0,0 +1,18 @@ +FROM debian@sha256:bf338ddc710dfb9b907a29ba661b35d0f6b3eae043515c4315f64c6e93409e94 + +LABEL MAINTAINER=chamalow <@qio8/4L4vnzq3qRD0dqKI7sTpey54u8ZWbaICfpJOZw=.ed25519> + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update -y && \ + apt-get install base58=1.0.3-1 python3-pip=18.1-5 python3-setuptools=44.0.0-1 -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + useradd -ms /bin/bash astroport + +USER astroport +WORKDIR /home/astroport/ + +COPY ./secret2dunikey.sh /home/astroport/secret2dunikey.sh +ENTRYPOINT ["/bin/bash"] +CMD [ "secret2dunikey.sh"] \ No newline at end of file From 82c5a11a572d615dbdbdb4fe804bfc97b91857c6 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Mon, 23 Mar 2020 17:23:08 +0100 Subject: [PATCH 18/35] update documentation --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index dcbc910..d73f3fe 100644 --- a/readme.md +++ b/readme.md @@ -96,13 +96,13 @@ The main clients for Duniter are [Cesium](https://cesium.app/) and [Silkaj](http First you need to build docker image ``` -docker build -t ssb-g1like . +docker-compose build ``` create your dunikey ``` -docker run -ti --rm -v ~/.ssb:/home/astroport/.ssb ssb-g1like -c /usr/bin/secret2dunikey +docker run -ti --rm -v ~/.ssb:/home/astroport/.ssb ssb-g1like_secret2dunikey ``` run main script From 67e3f28e519be16ddb78e3eeb2d277ca65e1afd2 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Tue, 24 Mar 2020 08:06:17 +0100 Subject: [PATCH 19/35] create dockerfile for tip container --- Dockerfile | 22 +--------------------- docker-compose.yml | 8 ++++++-- docker/docker-entrypoint.sh | 3 --- tip/Dockerfile | 27 +++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 tip/Dockerfile diff --git a/Dockerfile b/Dockerfile index 2d7b590..e2f47e8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,16 +3,12 @@ FROM debian@sha256:bf338ddc710dfb9b907a29ba661b35d0f6b3eae043515c4315f64c6e93409 LABEL MAINTAINER=chamalow <@qio8/4L4vnzq3qRD0dqKI7sTpey54u8ZWbaICfpJOZw=.ed25519> ENV DEBIAN_FRONTEND noninteractive -ENV NVM_INSTALL_DIR /opt/nvm -ENV NVM_DIR /usr/local/nvm -ENV NODE_VERSION v12.16.1 ENV RUSTUP_HOME /usr/local/rustup ENV CARGO_HOME /usr/local/cargo ENV PATH /usr/local/cargo/bin:$PATH ENV RUST_VERSION 1.42.0 COPY ./key_create_dunikey.py /usr/bin/key_create_dunikey -COPY ./secret2dunikey.sh /usr/bin/secret2dunikey COPY ./find_ssb_user_G1_pubkey.sh /usr/bin/find_ssb_user_G1_pubkey COPY ./tip.sh /usr/bin/tip @@ -44,14 +40,6 @@ RUN set -eux; \ cargo --version; \ rustc --version; -RUN git clone https://github.com/creationix/nvm.git $NVM_INSTALL_DIR && \ - . $NVM_INSTALL_DIR/nvm.sh && \ - nvm install --lts && \ - nvm alias default $NODE_VERSION && \ - nvm use default && \ - echo "export NVM_DIR=${NVM_DIR}" > /home/astroport/.bashrc && \ - echo ". ${NVM_INSTALL_DIR}/nvm.sh" > /home/astroport/.bashrc && \ - chown -R astroport:astroport $NVM_DIR RUN git clone https://git.scuttlebot.io/%25133ulDgs%2FoC1DXjoK04vDFy6DgVBB%2FZok15YJmuhD5Q%3D.sha256 sbotc WORKDIR /sbotc @@ -63,22 +51,14 @@ WORKDIR /dup-mnemonic-rs RUN cargo build --release && \ cp target/release/dup-mnemonic /usr/local/bin - -COPY ./docker/config /home/astroport/.ssb/ -COPY ./docker/run-ssb-pub.sh /home/astroport/ COPY ./docker/docker-entrypoint.sh /home/astroport/ COPY ./samples /home/astroport/ -RUN chmod +x /home/astroport/run-ssb-pub.sh /home/astroport/docker-entrypoint.sh +RUN chmod +x /home/astroport/docker-entrypoint.sh USER astroport WORKDIR /home/astroport -RUN . ~/.bashrc && \ - mkdir -p /home/astroport/.ssb/ && \ - npm install -g sodium-native@3.0.0 ssb-backlinks@1.0.0 && \ - npm install -g ssb-server@15.2.0 - VOLUME [ "/home/astroport/.ssb/" ] EXPOSE 8008 diff --git a/docker-compose.yml b/docker-compose.yml index 7393324..d829ba0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -49,10 +49,14 @@ services: context: ./ssb-server dockerfile: Dockerfile ports: - - "8008:8008" + - "8009:8008" volumes: - ~/.ssb-test/:/home/astroport/.ssb secret2dunikey: build: context: . - dockerfile: ./secret2dunikey/Dockerfile \ No newline at end of file + dockerfile: ./secret2dunikey/Dockerfile + tip: + build: + context: . + dockerfile: ./tip/Dockerfile \ No newline at end of file diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index db06137..8f75b8d 100644 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -1,7 +1,4 @@ #!/bin/bash . ~/.bashrc -echo "run ssb-server" -bash /home/astroport/run-ssb-pub.sh - tail -f /dev/null \ No newline at end of file diff --git a/tip/Dockerfile b/tip/Dockerfile new file mode 100644 index 0000000..85afdda --- /dev/null +++ b/tip/Dockerfile @@ -0,0 +1,27 @@ +FROM debian@sha256:bf338ddc710dfb9b907a29ba661b35d0f6b3eae043515c4315f64c6e93409e94 + +LABEL MAINTAINER=chamalow <@qio8/4L4vnzq3qRD0dqKI7sTpey54u8ZWbaICfpJOZw=.ed25519> + +ENV DEBIAN_FRONTEND noninteractive + +COPY ./tip.sh /usr/bin/tip +COPY ./samples / + +RUN apt-get update -y && \ + apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 -y && \ + chmod +x /usr/bin/tip && \ + pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + useradd -ms /bin/bash astroport + +RUN git clone https://git.scuttlebot.io/%25133ulDgs%2FoC1DXjoK04vDFy6DgVBB%2FZok15YJmuhD5Q%3D.sha256 sbotc +WORKDIR /sbotc +RUN make && make install + +USER astroport +WORKDIR /home/astroport +RUN mkdir .ssb +VOLUME [ "/home/astroport/.ssb"] +ENTRYPOINT ["/bin/bash"] +CMD ["/usr/bin/tip"] From 0d677fded63e4183f93c03c0a7883188e0919813 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Tue, 24 Mar 2020 08:07:14 +0100 Subject: [PATCH 20/35] update script --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index d73f3fe..269cadb 100644 --- a/readme.md +++ b/readme.md @@ -105,10 +105,10 @@ create your dunikey docker run -ti --rm -v ~/.ssb:/home/astroport/.ssb ssb-g1like_secret2dunikey ``` -run main script +run main tip script ``` -docker run -ti --rm -v ~/.ssb:/home/astroport/.ssb ssb-g1like +docker run -ti --rm -v ~/.ssb:/home/astroport/.ssb ssb-g1like_tip ``` ## Authors From 1ebbb25515110337f91a71051074342294da1464 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Tue, 24 Mar 2020 11:05:11 +0100 Subject: [PATCH 21/35] =?UTF-8?q?fix=20le=20bug=20des=20sample=20non=20tro?= =?UTF-8?q?uv=C3=A9s=20et=20mis=20=C3=A0=20jour=20de=20la=20documentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 4 +++- readme.md | 4 ++-- tip/Dockerfile | 13 +++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d829ba0..db73986 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,4 +59,6 @@ services: tip: build: context: . - dockerfile: ./tip/Dockerfile \ No newline at end of file + dockerfile: ./tip/Dockerfile + links: + - "ssb-server:ssb-server" \ No newline at end of file diff --git a/readme.md b/readme.md index 269cadb..e83b7c4 100644 --- a/readme.md +++ b/readme.md @@ -102,13 +102,13 @@ docker-compose build create your dunikey ``` -docker run -ti --rm -v ~/.ssb:/home/astroport/.ssb ssb-g1like_secret2dunikey +docker-compose run --rm -v ~/.ssb:/home/astroport/.ssb ssb-g1like_secret2dunikey ``` run main tip script ``` -docker run -ti --rm -v ~/.ssb:/home/astroport/.ssb ssb-g1like_tip +docker-compose run --rm -v ~/.ssb:/home/astroport/.ssb ssb-g1like_tip ``` ## Authors diff --git a/tip/Dockerfile b/tip/Dockerfile index 85afdda..f956337 100644 --- a/tip/Dockerfile +++ b/tip/Dockerfile @@ -4,12 +4,8 @@ LABEL MAINTAINER=chamalow <@qio8/4L4vnzq3qRD0dqKI7sTpey54u8ZWbaICfpJOZw=.ed25519 ENV DEBIAN_FRONTEND noninteractive -COPY ./tip.sh /usr/bin/tip -COPY ./samples / - RUN apt-get update -y && \ apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 -y && \ - chmod +x /usr/bin/tip && \ pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ @@ -19,9 +15,14 @@ RUN git clone https://git.scuttlebot.io/%25133ulDgs%2FoC1DXjoK04vDFy6DgVBB%2FZok WORKDIR /sbotc RUN make && make install + +COPY ./samples /home/astroport/samples +COPY ./tip.sh /home/astroport/tip +RUN chmod +x /home/astroport/samples /home/astroport/tip + USER astroport WORKDIR /home/astroport -RUN mkdir .ssb +RUN mkdir .ssb VOLUME [ "/home/astroport/.ssb"] ENTRYPOINT ["/bin/bash"] -CMD ["/usr/bin/tip"] +CMD ["/home/astroport/tip"] From a395a7d378c2cb973811bad91a74ccdc484fb9a6 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Tue, 24 Mar 2020 11:07:24 +0100 Subject: [PATCH 22/35] supression du repertoire docker pas utile --- docker/docker-entrypoint.sh | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 docker/docker-entrypoint.sh diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh deleted file mode 100644 index 8f75b8d..0000000 --- a/docker/docker-entrypoint.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -. ~/.bashrc - -tail -f /dev/null \ No newline at end of file From fdb88fe1372d82d43c1bef66653d14d9a64cce1e Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Tue, 24 Mar 2020 17:31:56 +0100 Subject: [PATCH 23/35] essaye de connecter ssb-server et sbotc de tip container --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index db73986..a70c4e1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -61,4 +61,4 @@ services: context: . dockerfile: ./tip/Dockerfile links: - - "ssb-server:ssb-server" \ No newline at end of file + - ssb-server \ No newline at end of file From e71d12de6f98d78a84e9bca706b073caefcef0c9 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Wed, 25 Mar 2020 11:15:29 +0100 Subject: [PATCH 24/35] fix issue ssb-server port settings --- docker-compose.yml | 2 +- ssb-server/config | 4 ++-- ssb-server/run-ssb-pub.sh | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a70c4e1..d32c96a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -49,7 +49,7 @@ services: context: ./ssb-server dockerfile: Dockerfile ports: - - "8009:8008" + - "8008:8008" volumes: - ~/.ssb-test/:/home/astroport/.ssb secret2dunikey: diff --git a/ssb-server/config b/ssb-server/config index 92890fd..a5e8019 100644 --- a/ssb-server/config +++ b/ssb-server/config @@ -3,9 +3,9 @@ "incoming": { "net": [ { - "scope": "public", "external": ["127.0.0.1"], "transform": "shs", "port": 8008 + "scope": "public", "external": ["0.0.0.0"], "transform": "shs", "port": 8008 }, - { "scope": "private", "transform": "shs", "port": 8008, "host": "127.0.0.1" } + { "scope": "private", "transform": "shs", "port": 8008, "host": "0.0.0.0" } ] }, "outgoing": { diff --git a/ssb-server/run-ssb-pub.sh b/ssb-server/run-ssb-pub.sh index e03e10f..f018e42 100644 --- a/ssb-server/run-ssb-pub.sh +++ b/ssb-server/run-ssb-pub.sh @@ -1,5 +1,6 @@ #!/bin/bash . ~/.bashrc + while true; do - ssb-server start --host 127.0.0.1 + ssb-server start done \ No newline at end of file From c513455d9aae2fc0bbb139378e3d8cbb585f81a9 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Thu, 26 Mar 2020 10:11:56 +0100 Subject: [PATCH 25/35] solve issue with sbotc tcp_connect --- docker-compose.yml | 2 -- ssb-server/Dockerfile | 1 - ssb-server/config | 19 ------------------- tip/Dockerfile | 29 +++++++++++++++++++++-------- tip/sbotc.sh | 4 ++++ 5 files changed, 25 insertions(+), 30 deletions(-) delete mode 100644 ssb-server/config create mode 100644 tip/sbotc.sh diff --git a/docker-compose.yml b/docker-compose.yml index d32c96a..e0296b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -48,8 +48,6 @@ services: build: context: ./ssb-server dockerfile: Dockerfile - ports: - - "8008:8008" volumes: - ~/.ssb-test/:/home/astroport/.ssb secret2dunikey: diff --git a/ssb-server/Dockerfile b/ssb-server/Dockerfile index 89099e1..6cd34b0 100644 --- a/ssb-server/Dockerfile +++ b/ssb-server/Dockerfile @@ -30,7 +30,6 @@ RUN . ~/.bashrc && \ npm install -g sodium-native@3.0.0 ssb-backlinks@1.0.0 && \ npm install -g ssb-server@15.2.0 -COPY ./config /home/astroport/.ssb/ COPY ./run-ssb-pub.sh /home/astroport/run-ssb-pub.sh EXPOSE 8008 diff --git a/ssb-server/config b/ssb-server/config deleted file mode 100644 index a5e8019..0000000 --- a/ssb-server/config +++ /dev/null @@ -1,19 +0,0 @@ -{ - "connections": { - "incoming": { - "net": [ - { - "scope": "public", "external": ["0.0.0.0"], "transform": "shs", "port": 8008 - }, - { "scope": "private", "transform": "shs", "port": 8008, "host": "0.0.0.0" } - ] - }, - "outgoing": { - "net": [ - { - "transform": "shs" - } - ] - } - } -} \ No newline at end of file diff --git a/tip/Dockerfile b/tip/Dockerfile index f956337..3baea19 100644 --- a/tip/Dockerfile +++ b/tip/Dockerfile @@ -2,27 +2,40 @@ FROM debian@sha256:bf338ddc710dfb9b907a29ba661b35d0f6b3eae043515c4315f64c6e93409 LABEL MAINTAINER=chamalow <@qio8/4L4vnzq3qRD0dqKI7sTpey54u8ZWbaICfpJOZw=.ed25519> -ENV DEBIAN_FRONTEND noninteractive +ENV DEBIAN_FRONTEND noninteractive +ENV NVM_INSTALL_DIR /opt/nvm +ENV NVM_DIR /usr/local/nvm +ENV NODE_VERSION v12.16.1 + +COPY ./tip/sbotc.sh /usr/bin/sbotc RUN apt-get update -y && \ - apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 -y && \ + apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 git=1:2.25.1-1 -y && \ pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ - useradd -ms /bin/bash astroport - -RUN git clone https://git.scuttlebot.io/%25133ulDgs%2FoC1DXjoK04vDFy6DgVBB%2FZok15YJmuhD5Q%3D.sha256 sbotc -WORKDIR /sbotc -RUN make && make install + useradd -ms /bin/bash astroport && \ + chmod +x /usr/bin/sbotc +RUN git clone https://github.com/creationix/nvm.git $NVM_INSTALL_DIR && \ + . $NVM_INSTALL_DIR/nvm.sh && \ + nvm install --lts && \ + nvm alias default $NODE_VERSION && \ + nvm use default && \ + echo "export NVM_DIR=${NVM_DIR}" > /home/astroport/.bashrc && \ + echo ". ${NVM_INSTALL_DIR}/nvm.sh" > /home/astroport/.bashrc && \ + chown -R astroport:astroport $NVM_DIR COPY ./samples /home/astroport/samples COPY ./tip.sh /home/astroport/tip RUN chmod +x /home/astroport/samples /home/astroport/tip USER astroport +RUN . ~/.bashrc && \ + mkdir -p /home/astroport/.ssb/ && \ + npm install -g sodium-native@3.0.0 ssb-backlinks@1.0.0 && \ + npm install -g ssb-server@15.2.0 WORKDIR /home/astroport -RUN mkdir .ssb VOLUME [ "/home/astroport/.ssb"] ENTRYPOINT ["/bin/bash"] CMD ["/home/astroport/tip"] diff --git a/tip/sbotc.sh b/tip/sbotc.sh new file mode 100644 index 0000000..d25f413 --- /dev/null +++ b/tip/sbotc.sh @@ -0,0 +1,4 @@ +#!/bin/bash +. ~/.bashrc + +ssb-server --host ssb-server --port 8008 $@ \ No newline at end of file From 0f530efb3c972f08e69ea108cb84fffb0dcb27c8 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Thu, 26 Mar 2020 17:20:25 +0100 Subject: [PATCH 26/35] query issue solved --- tip/Dockerfile | 4 +- tip/tip.sh | 531 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 533 insertions(+), 2 deletions(-) create mode 100755 tip/tip.sh diff --git a/tip/Dockerfile b/tip/Dockerfile index 3baea19..6e5f9d5 100644 --- a/tip/Dockerfile +++ b/tip/Dockerfile @@ -10,7 +10,7 @@ ENV NODE_VERSION v12.16.1 COPY ./tip/sbotc.sh /usr/bin/sbotc RUN apt-get update -y && \ - apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=18.1-5 python3-setuptools=44.0.0-1 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 git=1:2.25.1-1 -y && \ + apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=20.0.2-2 python3-setuptools=44.0.0-1 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 git=1:2.25.1-1 -y && \ pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ @@ -27,7 +27,7 @@ RUN git clone https://github.com/creationix/nvm.git $NVM_INSTALL_DIR && \ chown -R astroport:astroport $NVM_DIR COPY ./samples /home/astroport/samples -COPY ./tip.sh /home/astroport/tip +COPY ./tip/tip.sh /home/astroport/tip RUN chmod +x /home/astroport/samples /home/astroport/tip USER astroport diff --git a/tip/tip.sh b/tip/tip.sh new file mode 100755 index 0000000..49cf298 --- /dev/null +++ b/tip/tip.sh @@ -0,0 +1,531 @@ +#!/bin/bash +################################################################################ +# +# Authors: +# +# [@cel](@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519) +# [@Fred](@9BbJwPDjcyIqrOUPNn0nJZBduWdIrpMk3Cjz5MP361s=.ed25519) +# [@Boris](@l5nYExWYIgDLV6BYHOJPoI97jIUyTdSm8CTLpQ0XeOg=.ed25519) +# [@poka](@vDQif9KU3T78XJx+NliK+wdo1vmehHZCWqD+3X700Uk=.ed25519) +# @[chamalow](@qio8/4L4vnzq3qRD0dqKI7sTpey54u8ZWbaICfpJOZw=.ed25519) +# +# Version: 1.0 +# +# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) +# +########################################################################################### +# PREVENT DOUBLE PAYEMENT +# ADD Ğ1 Layer 10 LOVE to message writer you like ! +############################################################################################ + +# Customizable + +# debugMsgMode, when set to 1 does doesn't send transaction and does not update "last timestamp" +debugMsgMode=0 + +# If you don't want to wait +readable=1 + +minimumAmountPerLikeInUD="0.1" + +############################################################################################ + +# Let's get Ğ1 public and private keys +g1pub=$(cat ~/.ssb/secret.dunikey | grep "pub" | cut -d ' ' -f 2) +g1priv=$(cat ~/.ssb/secret.dunikey | grep "sec" | cut -d ' ' -f 2) + +# SSB pubkey +ssbpub=$(cat ~/.ssb/secret | grep public\" | cut -d ' ' -f 4 | cut -d '.' -f 1 | sed s/\"//g) + +defaultAmountPerLikeInUD="0.1" +bold=$(tput bold) +normal=$(tput sgr0) +ssbMaxSize=8192 + +baseSizeOfAMessageFile=$(wc -c samples/message.json | awk '{print $1}') +sizeOfATagMention=$(wc -c samples/tag_mention.json | awk '{print $1}') +sizeOfAUserMention=$(wc -c samples/user_mention.json | awk '{print $1}') +sizeOfAPostMention=$(wc -c samples/post_mention.json | awk '{print $1}') + + +############################################################################################ +#### CHECK LIKE AND SEND LOVE +# Let's get Ğ1 account balance +echo "" +echo -e "${bold}Welcome${normal} to the Ğ1/SSB-like microdonation system!\n" +if [[ $readable -eq 1 ]]; then sleep 1; fi +echo "MMMMMMMMMMMMMNk;'cdxxd:,c0WMMMMMMMMMMMMM +MMMMMMMMMMMMMNx,. .;kWMMMMMMMMMMMMM +MMMMMMMMMMMMMMMNOdlccld0NMMMMMMMMMMMMMMM +MMMMMMMMMMMWXko:,'....',:okXWMMMMMMMMMMM +MMMMMMMMMNk:. .cOWMMMMMMMMM +MMMMMMMW0: .c0MMMMMMMM" +if [[ $readable -eq 1 ]]; then sleep 1; fi +echo "MMMMMMWk. 'lxkOOkdc' .cOWMMMMMMM +MMMMMMO' 'kNMMMMMMMMNxcoOXWMMMMMMMMM +MMMMMNl '0MMMMMMMMMMMMMMMMMMMMMMMMMM +MMMMMX; cNMMMMMMMNOkkkkkkkkkkONMMMMM +MMMMMNc ;XMMMMMMMNd' .OMMMMM +MMMMMWx. cKMMMMMMMWKc. .OMMMMM +MMMMMMNo. .lkKXNNXKkc. .OMMMMM" +if [[ $readable -eq 1 ]]; then sleep 1; fi +echo "MMMMMMMNd. ...... .OMMMMM +MMMMMMMMWKl. 'c:. .OMMMMM +MMMMMMMMMMWXkc,.. ..,lkXWWO:;OMMMMM +MMMMMMMMMMMMMMWX0OxddxO0XWMMMMMMWXNMMMMM +MMMMMMMMMMMMMMMMNx;'',dNMMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMK, '0MMMMMMMMMMMMMMMM +MMMMMMMMMMMMMMMMNd. .oNMMMMMMMMMMMMMMMM +" +if [[ $readable -eq 1 ]]; then sleep 1; fi +printf "You know your SSB pubkey:\n%s\n\n" $ssbpub +if [[ $readable -eq 1 ]]; then sleep 2; fi +printf "...but did you know it is also a valid Ğ1 wallet?\n%s\n\n" $g1pub +if [[ $readable -eq 1 ]]; then sleep 2; fi +printf "Let's check the current balance of your wallet!\n\n" +if [[ $readable -eq 1 ]]; then sleep 1; fi +printf "I am interrogating the Ğ1 blockchain to check if anyone has already sent you Ğ1...\n\n" +if [[ $readable -eq 1 ]]; then sleep 2; fi +printf "A moment please...\n\n" +if [[ $readable -eq 1 ]]; then sleep 1; fi + +silkajRelativeAmountPattern='Total\sRelative\s+=\s+(.*)\s+UD' + + +duniter_servers[0]="duniter-g1.p2p.legal:443" +duniter_servers[1]="g1.duniter.org:443" +duniter_servers[2]="g1.presles.fr:443" +duniter_servers[3]="balboa.altsysnet.com:10900" +duniter_servers[4]="remuniter.cgeek.fr:16120" +duniter_servers[5]="duniter.moul.re:443" +duniter_servers[6]="77.152.31.154:20901" +duniter_servers[7]="duniter.g1.1000i100.fr:443" + +silkajExitCode=1 +i=0 + +while [ $silkajExitCode -ne 0 ] && [ $i -lt ${#duniter_servers[@]} ] +do + + echo "Testing server ${duniter_servers[$i]}..." + echo "" + silkajOutput=$(silkaj -p "${duniter_servers[$i]}" balance $g1pub 2>/dev/null) + silkajExitCode=$? + + ((i++)) +done + +if [ $silkajExitCode -eq 1 ] +then + echo "The server did not respond well. Please try again." + exit 1 +fi + +if [[ $silkajOutput =~ $silkajRelativeAmountPattern ]] +then + balance="${BASH_REMATCH[1]}" +else + echo "Account balance wasn't found." + exit 1 +fi + +printf "You have ${bold}%s UDĞ1${normal} on your Duniter Ğ1 wallet.\n\n" "$balance" +if [[ $readable -eq 1 ]]; then sleep 2; fi +printf "Want to show your appreciation of your fellow butts' posts while helping spreading awareness about libre currencies?\n\n" +if [[ $readable -eq 1 ]]; then sleep 3; fi + + +# BEGIN timestamp computation +self=$(sbotc whoami | jq -r .id) || exit 1 +ssb_dir=~/.${ssb_appname:-ssb} +id_part=$(echo "$self" | sed 's/\//_/g' | tail -c +2 | head -c 9) +state_file=$ssb_dir/likes-g1-$id_part.ts + +current_ts=$(date -u +%s%N | cut -b1-13) + +if [ -s "$state_file" ] +then + last_ts=$(cat "$state_file") || exit 1 +else + # timestamp from 24h ago + last_ts=$((current_ts - 24*3600*1000 - 1)) +#else last_ts=null +fi + +days_from_last_tx=$(( (current_ts - last_ts) / (24*60*60*1000) )) +# END timestamp computation + + +printf "First, let's see how much ❤ you gave lately...\n\n" +if [[ $readable -eq 1 ]]; then sleep 1; fi + +declare -A likesNbPerAuthor + +declare -A likedPosts +declare -A likesNbPerPost + +declare -A postsTimestamps + +declare -A excerpts + +totalLikesGiven=0 + +process_msg() { + + msg=$1 + target_id=$(printf %s "$msg" | jq -r '.value?.content?.vote?.link') || return 1 + target_msg=$(sbotc -e get "$target_id") || return 1 + target_author=$(printf %s "$target_msg" | jq -r .author) || return 1 + + msg_content=$(printf %s "$target_msg" | jq -r .content?.text) || return 1 + + # beware of markdown ! + msg_excerpt=${msg_content:0:10} + + #root_id=$(printf %s "$target_msg" | jq -r .content?.root) || return 1 + #[[ $root_id = "null" ]] && root_id=$target_id +} + + +process_author() { + + author_id=$1 + g1_author=$(echo $author_id | cut -d '.' -f 1 | cut -d '@' -f2 | base64 -d | base58) + author_name=$(sbotc query.read '[{"$filter":{"value":{"content":{"about":"'"$author_id"'"}}}}]' | jq .value?.content?.name | grep -v null | tail -n 1) + author_name=${author_name:1:-1} +} + +authorsNb=0 + +i=0 + +messages=$(sbotc query.read '[{"$filter":{"value":{"author":"'"$self"'","content":{"type":"vote","vote":{"expression":"Like"}},"timestamp":{"$gt":'"$last_ts"'}}}}]') +while read -r msg +do + priv=$(printf %s "$msg" | jq .value.content.private) + if [[ $priv = true ]] + then + printf "Private message $priv, continue to next one\n" >&2 + continue + fi + + if ! process_msg "$msg" + then + msg_id=$(printf %s "$msg" | jq -r .key) + printf '\nUnable to process message %s\n' "$msg_id" >&2 + exit 1 + fi + + if [[ $g1_author = $g1pub ]]; then + + echo "I LIKE MY MESSAGE $target_id" + + else + + ((totalLikesGiven++)) + + if [[ ${likesNbPerAuthor[$target_author]} -eq 0 ]] + then + likesNbPerAuthor[$target_author]=1 + likedPosts[$target_author]="" + else + likesNbPerAuthor[$target_author]=$((${likesNbPerAuthor[$target_author]} + 1)) + fi + + + if [[ ${likesNbPerPost[$target_id]} -eq 0 ]] + then + likesNbPerPost[$target_id]=1 + + likedPosts[$target_author]+=$target_id + likedPosts[$target_author]+="\n" + else + ((likesNbPerPost[$target_id]++)) + fi + + + excerpts[$target_id]=$msg_excerpt + + # We cannot use this anymore + # (now saving current_ts once all tx have been sent) + # + # if ! postsTimestamps[$target_id]=$(printf %s "$msg" | jq -r .value.timestamp) + #then + # printf 'Unable to get message timestamp\n' >&2 + # exit 1 + #fi + + ((i++)) + fi +done < <(printf '%s' "$messages") + +if [[ $totalLikesGiven -eq 0 ]] +then + printf "You did not give any like during the past %s days or they have already been processed.\n\n" "$days_from_last_tx" + printf "Try again in a few days.\n\n" +fi + +printf "You gave ${bold}%s❤${normal} during the past %s days.\n\n" "$totalLikesGiven" "$days_from_last_tx" +if [[ $readable -eq 1 ]]; then sleep 2; fi + +tx_are_possible=0 + +while [[ $tx_are_possible -eq 0 ]] +do + + printf "How many UDĞ1 do you want to send per each like you gave? (minimum is ${bold}%s UDĞ1${normal}) " "$minimumAmountPerLikeInUD" + read a + printf "\n" + + if [[ -z $a ]] + then + amountPerLikeInUD=$minimumAmountPerLikeInUD + else + amountPerLikeInUD=$a + fi + + amountGiven=$(echo "$totalLikesGiven * $amountPerLikeInUD" | bc -l) + + + has_enough_money=$(( $(echo "$amountGiven <= $balance" | bc -l) )) + amountPerLike_is_enough=$(( $(echo "$amountPerLikeInUD >= $minimumAmountPerLikeInUD" | bc -l) )) + tx_are_possible=$(( $has_enough_money && $amountPerLike_is_enough )) + + if [[ $readable -eq 1 ]]; then sleep 1; fi + + if [[ $tx_are_possible -eq 0 ]] ; then + + if [[ $has_enough_money -eq 0 ]] ; then + + printf "You don't have enough UDĞ1 to send all transactions.\n\n" + if [[ $readable -eq 1 ]]; then sleep 1; fi + printf "${bold}%s UDĞ1${normal} are needed.\n\n" "$amountGiven" + if [[ $readable -eq 1 ]]; then sleep 1; fi + elif [[ $amountPerLike_is_enough -eq 0 ]] ; then + + printf "Minimum amount per like is %s UDĞ1.\n\n" $minimumAmountPerLikeInUD + if [[ $readable -eq 1 ]]; then sleep 1; fi + + fi + + printf "Try again with a different amount per like.\n\n" + maxAmountPerLike=$(awk -vp=$balance -vq=$totalLikesGiven 'BEGIN{printf "%.2f" ,p / q}') + if [[ $readable -eq 1 ]]; then sleep 1; fi + printf "Maximum amount per like possible: ${bold}%s UDĞ1${normal}\n\n" "$maxAmountPerLike" + if [[ $readable -eq 1 ]]; then sleep 1; fi + else + newBalance=$(echo "$balance - $amountGiven" | bc -l) + printf "${bold}%s UDĞ1${normal} will be given.\n\n" "$amountGiven" + if [[ $readable -eq 1 ]]; then sleep 1; fi + printf "After sending transactions, your new balance will be ${bold}%s UDĞ1${normal}\n\n" "$newBalance" + if [[ $readable -eq 1 ]]; then sleep 1; fi + printf "Press ENTER to continue: " && read + printf "\n" + fi +done + +# Let's construct thank you posts (tyPosts) and send transactions! + +tyPostIndex=0 +tyPosts[0]="" +tyPosts[0]+="# I tipped you for your posts!\n\n" +tyPosts[0]+=$(printf "Huge thanks to the ScuttleButt community for all the fascinating posts you allowed me to read in the past %s days." "$days_from_last_tx") +tyPosts[0]+="\n\nAs a means to thank you further, I have just sent you #Ğ1 libre money.\n\n" +tyPosts[0]+="These messages, though they might feel spammy (sorry) are also a way for the Ğ1 community to spread awareness about [libre currencies](https://libre-currency.org/) so we can build #resilience at every level.\n\n" +tyPosts[0]+="You can learn how to spend your freshly earned money at [https://git.p2p.legal/Axiom-Team/ssb-g1-tip](https://git.p2p.legal/Axiom-Team/ssb-g1-tip)\n\n" +tyPosts[0]+="Below is the list of SSB users whose content I liked recently, and the amount each one was given:\n\n" +tableHeaders='| thanks to | for their posts | tip |\n' +tableHeaders+='| --- | --- | ---- |\n' +sizeOfTableHeaders=$(printf "%s" "$tableHeaders" | wc -c) +tyPosts[0]+=$tableHeaders + +# for message size calculation +# update following if you add tags in the message : +tags[0]="Ğ1" +tags[1]="resilience" + +sizeOfTags=0 +for t in ${!tags[@]} +do + tagSize=$(printf "%s" "${tags[t]}" | wc -c) + + (( sizeOfTags+=sizeOfATagMention + tagSize )) +done + +firstPostContentSize=$(printf "%s" "${tyPosts[0]}" | wc -c) +tyPostsSizes[0]=$((baseSizeOfAMessageFile + firstPostContentSize + sizeOfTags)) + +nbOfAuthors=${#likesNbPerAuthor[@]} +authorNum=1 + +for author_id in ${!likesNbPerAuthor[@]} +do + process_author $author_id + + # (Legacy) saving authors we have already mentionned in a message + likedAuthorsFile=$ssb_dir/db/g1likes + if [ ! -f $likedAuthorsFile ]; then + touch $likedAuthorsFile + fi + + if ! grep -Fxq $author_id $likedAuthorsFile; then + echo $author_id >> $likedAuthorsFile + fi + + + tipAmount=$(bc <<< "${likesNbPerAuthor[$author_id]} * $amountPerLikeInUD") + newLine='' + newLine+=$(printf "| [@%s](%s) " "$author_name" "$author_id") + newLine+="| " + + sizeOfAuthorName=$(printf "%s" "$author_name" | wc -c) + sizeOfAuthorId=$(printf "%s" "$author_id" | wc -c) + newLineSize=0 + (( newLineSize+=sizeOfAUserMention + sizeOfAuthorName + sizeOfAuthorId)) + + + p=${likedPosts[$author_id]} + thisAuthorLikedPosts=( ${p//\\n/ } ) + + isFirstPostOfThisAuthor=1 + + for likedPostId in ${thisAuthorLikedPosts[@]} + do + if [[ $isFirstPostOfThisAuthor -eq 1 ]] + then + isFirstPostOfThisAuthor=0 + else + newLine+=", " + (( newLineSize+=2 )) + fi + + newLine+=$(printf " %s❤" "${likesNbPerPost[$likedPostId]}") + newLine+=$(printf "[\`%s\`](%s)" "${excerpts[$likedPostId]}" "$likedPostId") + + sizeOfExcerpt=${#excerpts[$likedPostId]} + (( sizeOfExcerpt+=2 )) # for before ` and after ` + sizeOfLikedPostId=$(printf "%s" "$likedPostId" | wc -c) + (( newLineSize+=sizeOfAPostMention + sizeOfExcerpt + sizeOfLikedPostId )) + + done + + newLine+=$(printf "| %s UDĞ1 " "$tipAmount") + + newLine+="|\n" + + + (( newLineSize+=$(printf "%s" "$newLine" | wc -c) )) + + # printf "total size: %s\n\n" "$((${tyPostsSizes[$tyPostIndex]} + $newLineSize))" + + + # If adding new line would exceed max size, we create a new thank you post + + sizeWithNewLine=${tyPostsSizes[$tyPostIndex]} + (( sizeWithNewLine+=newLineSize )) + + if [[ $sizeWithNewLine -gt $ssbMaxSize ]] + then + printf "size before split: %s\n\n" "${tyPostsSizes[$tyPostIndex]}" + printf "size with new line: %s\n\n" "$sizeWithNewLine" + printf "size of new line: %s\n\n" "$newLineSize" + + (( tyPostIndex++ )) + tyPosts[$tyPostIndex]+=$tableHeaders + (( tyPostsSizes[$tyPostIndex]=baseSizeOfAMessageFile + sizeOfTableHeaders )) + fi + + tyPosts[$tyPostIndex]+=$newLine + (( tyPostsSizes[$tyPostIndex]+=newLineSize )) + + + if [[ $debugMsgMode -eq 0 ]] + then + + if [[ $authorNum -ne 1 ]] + then + sleep 20 # DO NOT OVER CHARGE DUNITER + fi + + #printf '%s\n' "silkaj -af --file ~/.ssb/secret.dunikey tx --output $g1_author --amountUD $tipAmount --comment "Thx for your cool posts on ScuttleButt" + silkaj -p "$duniter_server" -af --file ~/.ssb/secret.dunikey tx --output $g1_author --amountUD $tipAmount --comment "Thx for your cool posts on ScuttleButt" -y 2>/dev/null + + printf "\n${bold}%s UDĞ1${normal} sent to %s!\n\n" "$tipAmount" "$author_name" + fi + + (( authorNum++ )) +done + +# Let's save the current timestamp +if [[ $debugMsgMode -eq 0 ]] +then + if ! echo "$current_ts" > "$state_file"~ + then + printf 'Unable to write to backup state file.\n' >&2 + exit 1 + fi + + if ! mv "$state_file"~ "$state_file" + then + printf 'Unable to write to state file. Update state file manually to prevent tips to %s from being processed twice.\n' "$author_name" >&2 + exit 1 + fi +fi + +printf "\n%s UDĞ1 sent to %s butts!\n\n" "$amountGiven" "${#likesNbPerAuthor[@]}" + +# Let's publicly thank everyone! +#echo -e "${tyPosts[$n]}" + +# the following produces error: +# "sbotc: unexpected end of parent stream" +# must be a non-escaped quote problem... +#thank_you_msg=$(printf "%q" "${tyPosts[$n]}") +#sbotc publish '{"type":"post","text":"'"$thank_you_msg"'"}' 2>&1>/dev/null + +printf "What now ?\n\n" + +if [[ $readable -eq 1 ]]; then sleep 1; fi + +date=$(date -u +%Y-week-%W) + +if [[ ${#tyPosts[@]} -eq 1 ]] +then + msg_filename=thank-your-butts-$date + echo -e ${tyPosts[$n]} > ~/$msg_filename.md +else + for i in ${!tyPosts[@]} + do + part=$((i + 1)) + msg_filename=thank-your-butts-$date + echo -e ${tyPosts[$i]} > ~/$msg_filename-part-$part.md + done +fi + +printf "A surprise is awaiting in your home dir (~).\n\n" + +if [[ $readable -eq 1 ]]; then sleep 2; fi + +if [[ ${#tyPosts[@]} -eq 1 ]] +then + printf "It's a file.\n\n" + if [[ $readable -eq 1 ]]; then sleep 2; fi + printf "It's called $msg_filename.md\n\n" +else + printf "It's %s files.\n\n" "${#tyPosts[@]}" + if [[ $readable -eq 1 ]]; then sleep 2; fi + printf "The first one is called $msg_filename-part-1.md.\n\n" +fi + +if [[ $readable -eq 1 ]]; then sleep 2; fi + +printf "Customize it to your needs to thank your fellow butts publicly and help spread awareness about libre currencies :-)\n\n" + +if [[ $readable -eq 1 ]]; then sleep 3; fi + +printf "Then delete it.\n\n" + +if [[ $readable -eq 1 ]]; then sleep 2; fi + +printf "...because it won't self-destruct, haha :D \n\n" + From 51fe6cc39172f82ce8806f1d6a4f30fc07af1ba8 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Fri, 27 Mar 2020 08:42:32 +0100 Subject: [PATCH 27/35] add ipfs node --- docker-compose.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e0296b8..191b078 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: mongo: image: mongo volumes: - - "./data/mongo:/data" + - mongo-data:/data ohmyform: image: ohmyform/ohmyform #build: . @@ -59,4 +59,15 @@ services: context: . dockerfile: ./tip/Dockerfile links: - - ssb-server \ No newline at end of file + - ssb-server + ipfs: + image: ipfs-node + volumes: + - ipfs-data:/data/ipfs + ports: + - 8080:8080 + - 4001:4001 + - 5001:5001 +volumes: + ipfs-data: + mongo-data: \ No newline at end of file From 0227ec48cf669ad03aba4cc116a6beb8b4ee514e Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Fri, 27 Mar 2020 08:52:02 +0100 Subject: [PATCH 28/35] change some information into docker-compose --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 191b078..4e2c65f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -61,7 +61,7 @@ services: links: - ssb-server ipfs: - image: ipfs-node + image: ipfs/go-ipfs volumes: - ipfs-data:/data/ipfs ports: From 879bf6ef11c4d866e8bf541ab514dbc94842c916 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Fri, 27 Mar 2020 16:59:29 +0100 Subject: [PATCH 29/35] solved issue with tip.sh and add bc package --- tip/Dockerfile | 2 +- tip/tip.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tip/Dockerfile b/tip/Dockerfile index 6e5f9d5..e2226bc 100644 --- a/tip/Dockerfile +++ b/tip/Dockerfile @@ -10,7 +10,7 @@ ENV NODE_VERSION v12.16.1 COPY ./tip/sbotc.sh /usr/bin/sbotc RUN apt-get update -y && \ - apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=20.0.2-2 python3-setuptools=44.0.0-1 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 git=1:2.25.1-1 -y && \ + apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=20.0.2-2 python3-setuptools=44.0.0-1 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 git=1:2.25.1-1 bc=1.07.1-2+b2 -y && \ pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ diff --git a/tip/tip.sh b/tip/tip.sh index 49cf298..13bcb81 100755 --- a/tip/tip.sh +++ b/tip/tip.sh @@ -174,7 +174,7 @@ process_msg() { msg=$1 target_id=$(printf %s "$msg" | jq -r '.value?.content?.vote?.link') || return 1 - target_msg=$(sbotc -e get "$target_id") || return 1 + target_msg=$(sbotc query.read '[{"$filter":{"value":{"content":{}},"key":"'"$target_id"'"}}]') || return 1 target_author=$(printf %s "$target_msg" | jq -r .author) || return 1 msg_content=$(printf %s "$target_msg" | jq -r .content?.text) || return 1 @@ -257,7 +257,7 @@ do ((i++)) fi -done < <(printf '%s' "$messages") +done < <(echo "$messages" | jq -c) if [[ $totalLikesGiven -eq 0 ]] then From 4f428b5dc3795af0d6c9ecb425aaf58c302456bb Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Tue, 31 Mar 2020 11:46:27 +0200 Subject: [PATCH 30/35] fixe le bug dans secret2dunikey and daemonize tip container --- docker-compose.yml | 7 +++++++ secret2dunikey/Dockerfile | 2 +- tip/Dockerfile | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4e2c65f..ea7cde4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -54,12 +54,19 @@ services: build: context: . dockerfile: ./secret2dunikey/Dockerfile + volumes: + - ~/.ssb-test/:/home/astroport/.ssb tip: build: context: . dockerfile: ./tip/Dockerfile + volumes: + - ~/.ssb-test/:/home/astroport/.ssb links: - ssb-server + depends_on: + - ssb-server + - secret2dunikey ipfs: image: ipfs/go-ipfs volumes: diff --git a/secret2dunikey/Dockerfile b/secret2dunikey/Dockerfile index c9bfa39..bbf8f30 100644 --- a/secret2dunikey/Dockerfile +++ b/secret2dunikey/Dockerfile @@ -5,7 +5,7 @@ LABEL MAINTAINER=chamalow <@qio8/4L4vnzq3qRD0dqKI7sTpey54u8ZWbaICfpJOZw=.ed25519 ENV DEBIAN_FRONTEND noninteractive RUN apt-get update -y && \ - apt-get install base58=1.0.3-1 python3-pip=18.1-5 python3-setuptools=44.0.0-1 -y && \ + apt-get install base58=1.0.3-1 python3-pip=20.0.2-2 python3-setuptools=44.0.0-1 -y && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ useradd -ms /bin/bash astroport diff --git a/tip/Dockerfile b/tip/Dockerfile index e2226bc..5d18cb9 100644 --- a/tip/Dockerfile +++ b/tip/Dockerfile @@ -38,4 +38,4 @@ RUN . ~/.bashrc && \ WORKDIR /home/astroport VOLUME [ "/home/astroport/.ssb"] ENTRYPOINT ["/bin/bash"] -CMD ["/home/astroport/tip"] +CMD ["-c", "tail" ,"-f", "/dev/null"] From 757a90df9ae69ec7b7b984083e554ab715cbfd05 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Wed, 1 Apr 2020 09:09:48 +0200 Subject: [PATCH 31/35] ressoud l'issue daemonize tip container --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index ea7cde4..230b200 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -60,6 +60,7 @@ services: build: context: . dockerfile: ./tip/Dockerfile + tty: true volumes: - ~/.ssb-test/:/home/astroport/.ssb links: From 631c5e8caf0e0f2b85f0e7a53f5df1c285d8c98b Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Wed, 1 Apr 2020 09:18:31 +0200 Subject: [PATCH 32/35] =?UTF-8?q?cr=C3=A9ation=20param=C3=A9trer=20le=20ss?= =?UTF-8?q?b-path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 230b200..ed16a87 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -49,20 +49,20 @@ services: context: ./ssb-server dockerfile: Dockerfile volumes: - - ~/.ssb-test/:/home/astroport/.ssb + - ${SSB_PATH}:/home/astroport/.ssb secret2dunikey: build: context: . dockerfile: ./secret2dunikey/Dockerfile volumes: - - ~/.ssb-test/:/home/astroport/.ssb + - ${SSB_PATH}:/home/astroport/.ssb tip: build: context: . dockerfile: ./tip/Dockerfile tty: true volumes: - - ~/.ssb-test/:/home/astroport/.ssb + - ${SSB_PATH}:/home/astroport/.ssb links: - ssb-server depends_on: From 8a4c2fbee23d2c1683164e7a7011f545035ea4a8 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Wed, 1 Apr 2020 14:53:00 +0200 Subject: [PATCH 33/35] =?UTF-8?q?mise=20=C3=A0=20jour=20de=20la=20document?= =?UTF-8?q?ation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index e83b7c4..e356af2 100644 --- a/readme.md +++ b/readme.md @@ -93,22 +93,36 @@ The main clients for Duniter are [Cesium](https://cesium.app/) and [Silkaj](http ## With docker (experimental) -First you need to build docker image +### variables + +SSB_PATH : this is important variable to locate your ssb db path and secret file don't forget to set that. +if you use patchwork or other project please *copy all directory other location* because a +lock file is create when a patchwork or other projet run and ssb-server cannot run. + + +First you need to build docker image. ``` -docker-compose build +SSB_PATH=~/your-copy-ssb/ docker-compose build ``` create your dunikey ``` -docker-compose run --rm -v ~/.ssb:/home/astroport/.ssb ssb-g1like_secret2dunikey + SSB_PATH=~/your-copy-ssb/ docker-compose up -d tip # only you need to run tiping part + SSB_PATH=~/your-copy-ssb/ docker-compose up -d # if you need to run all platform ``` run main tip script ``` -docker-compose run --rm -v ~/.ssb:/home/astroport/.ssb ssb-g1like_tip +container_id=$(docker ps -a -q --filter="ancestor=ssb-g1like_tip") && docker exec -ti $container_id bash -c "/home/astroport/tip" +``` + +For display thank you file + +``` +container_id=$(docker ps -a -q --filter="ancestor=ssb-g1like_tip") && docker cp $container_id:/home/astroport/your_thank.md ~ && docker exec -ti $container_id bash -c "rm -rf /home/astroport/your_thank.md" ``` ## Authors From 845b0b53328ccd7eef82514df34f8f8b15bf59a6 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Wed, 1 Apr 2020 15:16:29 +0200 Subject: [PATCH 34/35] add documentation to install docker docker-compose --- readme.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/readme.md b/readme.md index e356af2..dc76acc 100644 --- a/readme.md +++ b/readme.md @@ -93,6 +93,11 @@ The main clients for Duniter are [Cesium](https://cesium.app/) and [Silkaj](http ## With docker (experimental) +### install docker & docker-compose + +[Docker](https://docs.docker.com/install/) +[Docker-compose](https://docs.docker.com/compose/install/) + ### variables SSB_PATH : this is important variable to locate your ssb db path and secret file don't forget to set that. From de9d0e5a913f2a69804f9c003d469048f1bcfa70 Mon Sep 17 00:00:00 2001 From: joseelinchevalay Date: Mon, 6 Apr 2020 09:11:20 +0200 Subject: [PATCH 35/35] fix quelque issue avec les script et le dependance entre les containers --- docker-compose.yml | 21 +++++++++------ {ssb-server => oasis}/Dockerfile | 17 ++++++------ readme.md | 7 ++--- ssb-server/run-ssb-pub.sh | 6 ----- tip/Dockerfile | 7 ++--- tip/sbotc.js | 56 ++++++++++++++++++++++++++++++++++++++++ tip/sbotc.sh | 2 +- tip/tip.sh | 6 ++--- 8 files changed, 87 insertions(+), 35 deletions(-) rename {ssb-server => oasis}/Dockerfile (63%) delete mode 100644 ssb-server/run-ssb-pub.sh create mode 100755 tip/sbotc.js diff --git a/docker-compose.yml b/docker-compose.yml index ed16a87..fe13181 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,18 +44,23 @@ services: - mongo depends_on: - mongo - ssb-server: - build: - context: ./ssb-server - dockerfile: Dockerfile - volumes: - - ${SSB_PATH}:/home/astroport/.ssb secret2dunikey: build: context: . dockerfile: ./secret2dunikey/Dockerfile volumes: - ${SSB_PATH}:/home/astroport/.ssb + oasis: + build: + context: . + dockerfile: ./oasis/Dockerfile + tty: true + ports: + - 3000:3000 + volumes: + - ${SSB_PATH}:/home/astroport/.ssb + depends_on: + - secret2dunikey tip: build: context: . @@ -64,9 +69,9 @@ services: volumes: - ${SSB_PATH}:/home/astroport/.ssb links: - - ssb-server + - oasis depends_on: - - ssb-server + - oasis - secret2dunikey ipfs: image: ipfs/go-ipfs diff --git a/ssb-server/Dockerfile b/oasis/Dockerfile similarity index 63% rename from ssb-server/Dockerfile rename to oasis/Dockerfile index 6cd34b0..9d92507 100644 --- a/ssb-server/Dockerfile +++ b/oasis/Dockerfile @@ -8,7 +8,8 @@ ENV NVM_DIR /usr/local/nvm ENV NODE_VERSION v12.16.1 RUN apt-get update -y && \ - apt-get install autoconf=2.69-11.1 build-essential=12.8 libsodium-dev=1.0.18-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 -y && \ + apt-get install autoconf=2.69-11.1 build-essential=12.8 python3-pip=20.0.2-2 python3-setuptools=44.0.0-1 libsodium-dev=1.0.18-1 jq=1.6-1 make=4.2.1-1.2 git=1:2.25.1-1 gcc=4:9.2.1-3.1 base58=1.0.3-1 libtool=2.4.6-14 curl=7.68.0-1 git=1:2.25.1-1 bc=1.07.1-2+b2 -y && \ + pip3 install duniterpy==0.56.0 silkaj==0.7.6 && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ useradd -ms /bin/bash astroport @@ -22,17 +23,15 @@ RUN git clone https://github.com/creationix/nvm.git $NVM_INSTALL_DIR && \ echo ". ${NVM_INSTALL_DIR}/nvm.sh" > /home/astroport/.bashrc && \ chown -R astroport:astroport $NVM_DIR -USER astroport -WORKDIR /home/astroport +USER astroport RUN . ~/.bashrc && \ mkdir -p /home/astroport/.ssb/ && \ npm install -g sodium-native@3.0.0 ssb-backlinks@1.0.0 && \ - npm install -g ssb-server@15.2.0 - -COPY ./run-ssb-pub.sh /home/astroport/run-ssb-pub.sh + npm install -g fraction/oasis#semver: +VOLUME [ "/home/astroport/.ssb"] +EXPOSE 3000 EXPOSE 8008 -VOLUME [ "/home/astroport/.ssb" ] -ENTRYPOINT [ "/bin/bash" ] -CMD [ "/home/astroport/run-ssb-pub.sh" ] +ENTRYPOINT ["/bin/bash"] +CMD ["-c", ". ~/.bashrc && oasis --host 0.0.0.0 --open false && tail -f /dev/null"] \ No newline at end of file diff --git a/readme.md b/readme.md index dc76acc..a72cce1 100644 --- a/readme.md +++ b/readme.md @@ -101,14 +101,11 @@ The main clients for Duniter are [Cesium](https://cesium.app/) and [Silkaj](http ### variables SSB_PATH : this is important variable to locate your ssb db path and secret file don't forget to set that. -if you use patchwork or other project please *copy all directory other location* because a -lock file is create when a patchwork or other projet run and ssb-server cannot run. - First you need to build docker image. ``` -SSB_PATH=~/your-copy-ssb/ docker-compose build +SSB_PATH=~/.ssb/ docker-compose build ``` create your dunikey @@ -127,7 +124,7 @@ container_id=$(docker ps -a -q --filter="ancestor=ssb-g1like_tip") && docker exe For display thank you file ``` -container_id=$(docker ps -a -q --filter="ancestor=ssb-g1like_tip") && docker cp $container_id:/home/astroport/your_thank.md ~ && docker exec -ti $container_id bash -c "rm -rf /home/astroport/your_thank.md" +container_id=$(docker ps -a -q --filter="ancestor=ssb-g1like_tip") && docker cp $container_id:/home/astroport/thank-your-butts-$(date -u +%Y-week-%W).md ~ && docker exec -ti $container_id bash -c "rm -rf /home/astroport/thank-your-butts-$(date -u +%Y-week-%W).md" ``` ## Authors diff --git a/ssb-server/run-ssb-pub.sh b/ssb-server/run-ssb-pub.sh deleted file mode 100644 index f018e42..0000000 --- a/ssb-server/run-ssb-pub.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -. ~/.bashrc - -while true; do - ssb-server start -done \ No newline at end of file diff --git a/tip/Dockerfile b/tip/Dockerfile index 5d18cb9..aae1144 100644 --- a/tip/Dockerfile +++ b/tip/Dockerfile @@ -28,14 +28,15 @@ RUN git clone https://github.com/creationix/nvm.git $NVM_INSTALL_DIR && \ COPY ./samples /home/astroport/samples COPY ./tip/tip.sh /home/astroport/tip -RUN chmod +x /home/astroport/samples /home/astroport/tip +COPY ./tip/sbotc.js /home/astroport/sbotc.js +RUN chmod +x /home/astroport/samples /home/astroport/tip /home/astroport/sbotc.js USER astroport +WORKDIR /home/astroport/ RUN . ~/.bashrc && \ mkdir -p /home/astroport/.ssb/ && \ npm install -g sodium-native@3.0.0 ssb-backlinks@1.0.0 && \ - npm install -g ssb-server@15.2.0 -WORKDIR /home/astroport + npm install commander@5.0.0 ssb-client@4.9.0 pull-stream@3.6.14 VOLUME [ "/home/astroport/.ssb"] ENTRYPOINT ["/bin/bash"] CMD ["-c", "tail" ,"-f", "/dev/null"] diff --git a/tip/sbotc.js b/tip/sbotc.js new file mode 100755 index 0000000..6348c97 --- /dev/null +++ b/tip/sbotc.js @@ -0,0 +1,56 @@ +const {program} = require("commander"); +const ssbClient = require('ssb-client'); +const pull = require('pull-stream'); + +let convertToInt = (value) => { + return parseInt(value); +} + +let throwProgram = (err) => { + console.error(err.message); + process.exit(1); +} + +program.version('.0.0.1'); + +program + .requiredOption('-s, --host ', 'host name or ip of ssb-server', 'oasis') + .requiredOption('-p, --port ', 'port of ssb-server', convertToInt, 8008) + +/** +* whoami command +*/ +program + .command('whoami') + .description('return your identity') + .action(() => { + ssbClient({host:program.host, port:program.port}, (err, sbot) => { + if(err) throwProgram(err) + sbot.whoami((err, identity) =>{ + if(err) throwProgram + console.log(JSON.stringify(identity)); + sbot.close(); + }) + }) + }); + +/** +* query +*/ +program + .command('query ') + .description('you can execute a query') + .action((query) => { + ssbClient({host:program.host, port:program.port}, (err, sbot) =>{ + if(err) throwProgram(err); + pull(sbot.query.read({query:JSON.parse(query)}),pull.collect( (err, array) => { + if(err) throwProgram(err); + array.forEach((result) => { + console.log(JSON.stringify(result)); + }) + sbot.close(); + })) + }) + }); + +program.parse(process.argv); diff --git a/tip/sbotc.sh b/tip/sbotc.sh index d25f413..83bebb1 100644 --- a/tip/sbotc.sh +++ b/tip/sbotc.sh @@ -1,4 +1,4 @@ #!/bin/bash . ~/.bashrc -ssb-server --host ssb-server --port 8008 $@ \ No newline at end of file +node ~/sbotc.js $@ \ No newline at end of file diff --git a/tip/tip.sh b/tip/tip.sh index 13bcb81..cd8e5ae 100755 --- a/tip/tip.sh +++ b/tip/tip.sh @@ -174,7 +174,7 @@ process_msg() { msg=$1 target_id=$(printf %s "$msg" | jq -r '.value?.content?.vote?.link') || return 1 - target_msg=$(sbotc query.read '[{"$filter":{"value":{"content":{}},"key":"'"$target_id"'"}}]') || return 1 + target_msg=$(sbotc query '[{"$filter":{"value":{"content":{}},"key":"'"$target_id"'"}}]') || return 1 target_author=$(printf %s "$target_msg" | jq -r .author) || return 1 msg_content=$(printf %s "$target_msg" | jq -r .content?.text) || return 1 @@ -191,7 +191,7 @@ process_author() { author_id=$1 g1_author=$(echo $author_id | cut -d '.' -f 1 | cut -d '@' -f2 | base64 -d | base58) - author_name=$(sbotc query.read '[{"$filter":{"value":{"content":{"about":"'"$author_id"'"}}}}]' | jq .value?.content?.name | grep -v null | tail -n 1) + author_name=$(sbotc query '[{"$filter":{"value":{"content":{"about":"'"$author_id"'"}}}}]' | jq .value?.content?.name | grep -v null | tail -n 1) author_name=${author_name:1:-1} } @@ -199,7 +199,7 @@ authorsNb=0 i=0 -messages=$(sbotc query.read '[{"$filter":{"value":{"author":"'"$self"'","content":{"type":"vote","vote":{"expression":"Like"}},"timestamp":{"$gt":'"$last_ts"'}}}}]') +messages=$(sbotc query '[{"$filter":{"value":{"author":"'"$self"'","content":{"type":"vote","vote":{"expression":"Like"}},"timestamp":{"$gt":'"$last_ts"'}}}}]') while read -r msg do priv=$(printf %s "$msg" | jq .value.content.private)