diff --git a/bin/appimg.sh b/bin/appimg.sh new file mode 100755 index 0000000..4c26613 --- /dev/null +++ b/bin/appimg.sh @@ -0,0 +1,114 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2021-2023 diva.exchange +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# Author/Maintainer: DIVA.EXCHANGE Association +# + +set -eu + +RDNS_NAME="exchange.diva.divachain" + +PROJECT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/../ +cd "${PROJECT_PATH}" +PROJECT_PATH=$( pwd ) +APP_DIR="$PROJECT_PATH/build/$RDNS_NAME.AppDir" + +# load helpers +source "${PROJECT_PATH}"/bin/util/echos.sh +source "${PROJECT_PATH}"/bin/util/helpers.sh +source "${PROJECT_PATH}"/bin/util/commands.sh + +# DIVA_TESTNET=1 "$PROJECT_PATH"/bin/build.sh + +grab_i2pd_build() { + I2PD_LIBS=( + /usr/lib/libboost_filesystem.so.1.78.0 + /usr/lib/libboost_program_options.so.1.78.0 + /lib/libssl.so.1.1 + /lib/libcrypto.so.1.1 + /usr/lib/libminiupnpc.so.17 + /lib/libz.so.1 + /usr/lib/libstdc++.so.6 + /usr/lib/libgcc_s.so.1 + /lib/libc.musl-x86_64.so.1 + /lib/ld-musl-x86_64.so.1 + ) + + id=$(docker create divax/i2p:current) + docker cp -L $id:/home/i2pd "$APP_DIR/opt/" + docker cp -L $id:/bin/sh "$APP_DIR/bin/" + + + for lib in "${I2PD_LIBS[@]}"; do + docker cp -L "$id:$lib" "$APP_DIR/opt/i2pd/$lib" + done + docker rm -v "$id" + + for binary in $(printf "%s/%s\n" "$APP_DIR/opt/i2pd" "${I2PD_LIBS[@]}") "$APP_DIR/opt/i2pd/bin/i2pd" "$APP_DIR/bin/sh"; do + patchelf --debug --set-interpreter ./opt/i2pd/lib/ld-musl-x86_64.so.1 "$binary" || true + done +} + +grab_divachain_build() { + DIVACHAIN_LIBS=( + /lib/x86_64-linux-gnu/ld-2.31.so + /lib/x86_64-linux-gnu/libdl.so.2 + /usr/lib/x86_64-linux-gnu/libstdc++.so.6 + /lib/x86_64-linux-gnu/libm.so.6 + /lib/x86_64-linux-gnu/libpthread.so.0 + /lib/x86_64-linux-gnu/libc.so.6 + /lib/x86_64-linux-gnu/libc-2.31.so + # /lib64/ld-linux-x86-64.so.2 + ) + + + id=$(docker create divax/divachain:latest) + docker cp -L "$id:/divachain" "$APP_DIR/usr/bin/divachain" + for f in bin etc genesis keys package.json; do + docker cp -L "$id:/$f" "$APP_DIR/" + done + + set -x + + for lib in "${DIVACHAIN_LIBS[@]}"; do + docker cp -L "$id:$lib" "$APP_DIR/$lib" + done + + + docker rm -v "$id" + + USED_BINARIES=( + "$APP_DIR"/lib/x86_64-linux-gnu/libc.so.6 + "$APP_DIR/bin/divachain" + ) + for binary in "${USED_BINARIES[@]}"; do + + ft="$(file "$binary")" + + if [[ "$ft" =~ ": ELF " ]]; then + patchelf --set-interpreter ./lib64/ld-linux-x86-64.so.2 "$binary" + else + echo "WARNING: $binary is not a binary and therefore cannot be patched" + fi + done +} + +grab_i2pd_build + +grab_divachain_build + +appimagetool "$APP_DIR" build/divachain.AppImage diff --git a/bin/build.sh b/bin/build.sh index 52631ed..de6aacb 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -28,6 +28,7 @@ PROJECT_PATH=$( pwd ) # load helpers source "${PROJECT_PATH}"/bin/util/echos.sh source "${PROJECT_PATH}"/bin/util/helpers.sh +source "${PROJECT_PATH}"/bin/util/commands.sh # env vars I2P_LOGLEVEL=${I2P_LOGLEVEL:-none} @@ -80,7 +81,7 @@ cd "${PATH_DOMAIN}" if [[ -f ./diva.yml ]] then - sudo docker compose -f ./diva.yml down + as_root docker compose -f ./diva.yml down fi if [[ ${PURGE} -gt 0 ]] @@ -91,13 +92,13 @@ then if [[ -f ./diva.yml ]] then - sudo docker compose -f ./diva.yml down --volumes + as_root docker compose -f ./diva.yml down --volumes fi - sudo rm -rf "${PATH_DOMAIN}"/genesis/* - sudo rm -rf "${PATH_DOMAIN}"/keys/* - sudo rm -rf "${PATH_DOMAIN}"/state/* - sudo rm -rf "${PATH_DOMAIN}"/blockstore/* + as_root rm -rf "${PATH_DOMAIN}"/genesis/* + as_root rm -rf "${PATH_DOMAIN}"/keys/* + as_root rm -rf "${PATH_DOMAIN}"/state/* + as_root rm -rf "${PATH_DOMAIN}"/blockstore/* fi if [[ ! -f genesis/local.config ]] @@ -106,12 +107,12 @@ then if [[ -f ./genesis-i2p.yml ]] then - sudo SIZE_NETWORK=${SIZE_NETWORK} docker compose -f ./genesis-i2p.yml down --volumes + SIZE_NETWORK=${SIZE_NETWORK} as_root docker compose -f ./genesis-i2p.yml down --volumes fi cp "${PROJECT_PATH}"/build/genesis-i2p.yml ./genesis-i2p.yml - sudo SIZE_NETWORK=${SIZE_NETWORK} docker compose -f ./genesis-i2p.yml pull - sudo SIZE_NETWORK=${SIZE_NETWORK} docker compose -f ./genesis-i2p.yml up -d + SIZE_NETWORK=${SIZE_NETWORK} as_root docker compose -f ./genesis-i2p.yml pull + SIZE_NETWORK=${SIZE_NETWORK} as_root docker compose -f ./genesis-i2p.yml up -d running "Waiting for key generation" # wait until all keys are created @@ -121,7 +122,7 @@ then done # shut down the genesis container and clean up - sudo SIZE_NETWORK=${SIZE_NETWORK} docker compose -f ./genesis-i2p.yml down --volumes + SIZE_NETWORK=${SIZE_NETWORK} as_root docker compose -f ./genesis-i2p.yml down --volumes rm ./genesis-i2p.yml # handle joining diff --git a/bin/clean.sh b/bin/clean.sh index c3eab2a..04f1d8b 100755 --- a/bin/clean.sh +++ b/bin/clean.sh @@ -28,17 +28,18 @@ PROJECT_PATH=$( pwd ) # load helpers source "${PROJECT_PATH}"/bin/util/echos.sh source "${PROJECT_PATH}"/bin/util/helpers.sh +source "${PROJECT_PATH}"/bin/util/commands.sh BASE_DOMAIN=${BASE_DOMAIN:-} if [[ ${BASE_DOMAIN} = "*" ]] then info "Removing ${PROJECT_PATH}/build/domains/*" - sudo rm -rf "${PROJECT_PATH}"/build/domains/* + as_root rm -rf "${PROJECT_PATH}"/build/domains/* elif [[ -n ${BASE_DOMAIN} && -d ${PROJECT_PATH}/build/domains/${BASE_DOMAIN} ]] then info "Removing ${PROJECT_PATH}/build/domains/${BASE_DOMAIN}" - sudo rm -rf "${PROJECT_PATH}"/build/domains/"${BASE_DOMAIN}" + as_root rm -rf "${PROJECT_PATH}"/build/domains/"${BASE_DOMAIN}" else warn "Set BASE_DOMAIN to a existing directory name (see domains directory)" exit 1 diff --git a/bin/halt.sh b/bin/halt.sh index 53a3d05..fbbf351 100755 --- a/bin/halt.sh +++ b/bin/halt.sh @@ -28,6 +28,7 @@ PROJECT_PATH=$( pwd ) # load helpers source "${PROJECT_PATH}"/bin/util/echos.sh source "${PROJECT_PATH}"/bin/util/helpers.sh +source "${PROJECT_PATH}"/bin/util/commands.sh # env vars DIVA_TESTNET=${DIVA_TESTNET:-0} @@ -54,5 +55,5 @@ then fi running "Halting ${PATH_DOMAIN}" -sudo docker compose -f ./diva.yml down +as_root docker compose -f ./diva.yml down ok "Halted ${PATH_DOMAIN}" diff --git a/bin/purge.sh b/bin/purge.sh index b54f261..75e7043 100755 --- a/bin/purge.sh +++ b/bin/purge.sh @@ -28,6 +28,7 @@ PROJECT_PATH=$( pwd ) # load helpers source "${PROJECT_PATH}/bin/util/echos.sh" source "${PROJECT_PATH}/bin/util/helpers.sh" +source "${PROJECT_PATH}/bin/util/commands.sh" # env vars DIVA_TESTNET=${DIVA_TESTNET:-0} @@ -68,6 +69,6 @@ warn "If you want to keep the data, run a backup first." confirm "Do you want to DELETE all local diva data (y/N)?" || exit 5 running "Purging ${PATH_DOMAIN}" -sudo docker compose -f ./diva.yml down --volumes +as_root docker compose -f ./diva.yml down --volumes BASE_DOMAIN=${BASE_DOMAIN} "${PROJECT_PATH}"/bin/clean.sh ok "Purged ${PATH_DOMAIN}" diff --git a/bin/start.sh b/bin/start.sh index b934351..c25702e 100755 --- a/bin/start.sh +++ b/bin/start.sh @@ -28,6 +28,7 @@ PROJECT_PATH=$( pwd ) # load helpers source "${PROJECT_PATH}/bin/util/echos.sh" source "${PROJECT_PATH}/bin/util/helpers.sh" +source "${PROJECT_PATH}/bin/util/commands.sh" # env vars DIVA_TESTNET=${DIVA_TESTNET:-0} @@ -65,8 +66,8 @@ then fi running "Pulling ${PATH_DOMAIN}" -sudo docker compose -f ./diva.yml pull +as_root docker compose -f ./diva.yml pull running "Starting ${PATH_DOMAIN}" -sudo NO_BOOTSTRAPPING="${NO_BOOTSTRAPPING}" docker compose -f ./diva.yml up -d +NO_BOOTSTRAPPING="${NO_BOOTSTRAPPING}" as_root docker compose -f ./diva.yml up -d ok "Started ${PATH_DOMAIN}" diff --git a/bin/util/commands.sh b/bin/util/commands.sh new file mode 100755 index 0000000..3039d6e --- /dev/null +++ b/bin/util/commands.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +SUDO_CMD="${SUDO_CMD-sudo}" + +function as_root() { + echo "Running privileged command" + echo " $SUDO_CMD " "$@" + + if [[ -n "$SUDO_CMD" ]]; then + "$SUDO_CMD" "$@" + else + "$@" + fi +} + diff --git a/build/exchange.diva.divachain.AppDir/AppRun b/build/exchange.diva.divachain.AppDir/AppRun new file mode 100755 index 0000000..9463e7f --- /dev/null +++ b/build/exchange.diva.divachain.AppDir/AppRun @@ -0,0 +1,79 @@ +#!/usr/bin/env sh +# +# Copyright (C) 2021-2023 diva.exchange +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# Author/Maintainer: DIVA.EXCHANGE Association +# + +set -eu + +cd $APPDIR + +echo "Running from APPDIR: $APPDIR" + + +# SELF=$(readlink -f "$0") +# HERE=${SELF%/*} +HERE=$APPDIR +if [ -z "${DIVAAPPIMG_RELAUNCHED:-}" ]; then + export ORIG_LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" + export LD_LIBRARY_PATH="${HERE}/usr/lib/:${HERE}/usr/lib/i386-linux-gnu/:${HERE}/usr/lib/x86_64-linux-gnu/:${HERE}/usr/lib32/:${HERE}/usr/lib64/:${HERE}/lib/:${HERE}/lib/i386-linux-gnu/:${HERE}/lib/x86_64-linux-gnu/::${HERE}/lib32/:${HERE}/lib64/:${HERE}/lib:${ORIG_LD_LIBRARY_PATH:+:$ORIG_LD_LIBRARY_PATH}" + export PATH="${HERE}/usr/bin/:${HERE}/usr/sbin/:${HERE}/usr/games/:${HERE}/bin/:${HERE}/sbin/${PATH:+:$PATH}" + export PYTHONPATH="${HERE}/usr/share/pyshared/${PYTHONPATH:+:$PYTHONPATH}" + export XDG_DATA_DIRS="${HERE}/usr/share/${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}" + export PERLLIB="${HERE}/usr/share/perl5/:${HERE}/usr/lib/perl5/${PERLLIB:+:$PERLLIB}" + export GSETTINGS_SCHEMA_DIR="${HERE}/usr/share/glib-2.0/schemas/${GSETTINGS_SCHEMA_DIR:+:$GSETTINGS_SCHEMA_DIR}" + export QT_PLUGIN_PATH="${HERE}/usr/lib/qt4/plugins/:${HERE}/usr/lib/i386-linux-gnu/qt4/plugins/:${HERE}/usr/lib/x86_64-linux-gnu/qt4/plugins/:${HERE}/usr/lib32/qt4/plugins/:${HERE}/usr/lib64/qt4/plugins/:${HERE}/usr/lib/qt5/plugins/:${HERE}/usr/lib/i386-linux-gnu/qt5/plugins/:${HERE}/usr/lib/x86_64-linux-gnu/qt5/plugins/:${HERE}/usr/lib32/qt5/plugins/:${HERE}/usr/lib64/qt5/plugins/${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH}" +# EXEC=$(grep -e '^Exec=.*' "${HERE}"/*.desktop | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 1) +# + + export DIVAAPPIMG_RELAUNCHED=1 + echo RELAUNCH with sh from within appimage + # RELAUNCH the script again with own sh, so that it certainly has the correct c library + echo exec "$APPDIR/bin/sh" "$0" "$@" + exec "$APPDIR/bin/sh" "$0" "$@" + exit 0 +fi + + +# APPIMG_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +# cd "${APPIMG_PATH}" +# APPIMG_PATH=$( pwd ) + + +export DATA_DIR="${XDG_DATA_HOME:-$HOME/.local/share/divax}" + +if [ ! -d "$DATA_DIR" ]; then + mkdir -p "$DATA_DIR" + cp -R opt/i2pd/data/ "$DATA_DIR" +fi + + +# START I2P and kill it when the script is done +I2P_PID= +trap "kill \$I2P_PID" EXIT +export LD_LIBRARY_PATH="${HERE}/opt/i2pd/usr/lib/:${HERE}/opt/i2pd/lib:${ORIG_LD_LIBRARY_PATH:+:$ORIG_LD_LIBRARY_PATH}" +# ldd opt/i2pd/bin/i2pd +opt/i2pd/bin/i2pd --datadir="$DATA_DIR/data" --conf=etc/i2pd.conf & +I2P_PID=$! + +echo started i2pd in background + +# cannot exec here, because of TRAP EXIT to kill i2p +# ldd ./divachain +./divachain "$@" + + diff --git a/build/exchange.diva.divachain.AppDir/bin/.gitignore b/build/exchange.diva.divachain.AppDir/bin/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/build/exchange.diva.divachain.AppDir/bin/.gitignore @@ -0,0 +1 @@ +* diff --git a/build/exchange.diva.divachain.AppDir/divax.png b/build/exchange.diva.divachain.AppDir/divax.png new file mode 100644 index 0000000..a2e0399 Binary files /dev/null and b/build/exchange.diva.divachain.AppDir/divax.png differ diff --git a/build/exchange.diva.divachain.AppDir/exchange.diva.divachain.desktop b/build/exchange.diva.divachain.AppDir/exchange.diva.divachain.desktop new file mode 100644 index 0000000..7aa7f67 --- /dev/null +++ b/build/exchange.diva.divachain.AppDir/exchange.diva.divachain.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Terminal=false +Exec=AppRun +Name=divax +Icon=divax +Categories=Network;Economy +# Description=Free Banking Technology. For Everyone. +X-AppImage-Name=divax +# X-AppImage-Version=@VERSION@ +X-AppImage-Arch=x86_64 diff --git a/build/exchange.diva.divachain.AppDir/lib/.gitignore b/build/exchange.diva.divachain.AppDir/lib/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/build/exchange.diva.divachain.AppDir/lib/.gitignore @@ -0,0 +1 @@ +* diff --git a/build/exchange.diva.divachain.AppDir/lib/x86_64-linux-gnu/.gitignore b/build/exchange.diva.divachain.AppDir/lib/x86_64-linux-gnu/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/build/exchange.diva.divachain.AppDir/lib/x86_64-linux-gnu/.gitignore @@ -0,0 +1 @@ +* diff --git a/build/exchange.diva.divachain.AppDir/lib64/.gitignore b/build/exchange.diva.divachain.AppDir/lib64/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/build/exchange.diva.divachain.AppDir/lib64/.gitignore @@ -0,0 +1 @@ +* diff --git a/build/exchange.diva.divachain.AppDir/opt/i2pd/.gitignore b/build/exchange.diva.divachain.AppDir/opt/i2pd/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/build/exchange.diva.divachain.AppDir/opt/i2pd/.gitignore @@ -0,0 +1 @@ +* diff --git a/build/exchange.diva.divachain.AppDir/opt/i2pd/lib/.gitignore b/build/exchange.diva.divachain.AppDir/opt/i2pd/lib/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/build/exchange.diva.divachain.AppDir/opt/i2pd/lib/.gitignore @@ -0,0 +1 @@ +* diff --git a/build/exchange.diva.divachain.AppDir/opt/i2pd/usr/lib/.gitignore b/build/exchange.diva.divachain.AppDir/opt/i2pd/usr/lib/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/build/exchange.diva.divachain.AppDir/opt/i2pd/usr/lib/.gitignore @@ -0,0 +1 @@ +* diff --git a/build/exchange.diva.divachain.AppDir/usr/bin/.gitignore b/build/exchange.diva.divachain.AppDir/usr/bin/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/build/exchange.diva.divachain.AppDir/usr/bin/.gitignore @@ -0,0 +1 @@ +* diff --git a/build/exchange.diva.divachain.AppDir/usr/lib/.gitignore b/build/exchange.diva.divachain.AppDir/usr/lib/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/build/exchange.diva.divachain.AppDir/usr/lib/.gitignore @@ -0,0 +1 @@ +* diff --git a/build/exchange.diva.divachain.AppDir/usr/lib/x86_64-linux-gnu/.gitignore b/build/exchange.diva.divachain.AppDir/usr/lib/x86_64-linux-gnu/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/build/exchange.diva.divachain.AppDir/usr/lib/x86_64-linux-gnu/.gitignore @@ -0,0 +1 @@ +* diff --git a/build/exchange.diva.divachain.AppDir/usr/share/applications/exchange.diva.divachain.desktop b/build/exchange.diva.divachain.AppDir/usr/share/applications/exchange.diva.divachain.desktop new file mode 120000 index 0000000..ef5ed90 --- /dev/null +++ b/build/exchange.diva.divachain.AppDir/usr/share/applications/exchange.diva.divachain.desktop @@ -0,0 +1 @@ +../../../exchange.diva.divachain.desktop \ No newline at end of file diff --git a/build/exchange.diva.divachain.AppDir/usr/share/metainfo/exchange.diva.divachain.appdata.xml b/build/exchange.diva.divachain.AppDir/usr/share/metainfo/exchange.diva.divachain.appdata.xml new file mode 100644 index 0000000..dbbcdf5 --- /dev/null +++ b/build/exchange.diva.divachain.AppDir/usr/share/metainfo/exchange.diva.divachain.appdata.xml @@ -0,0 +1,33 @@ + + + + exchange.diva.divachain + CC0-1.0 + AGPL-1.0 + divax + Free Banking Technology For Everyone + +

You have your own private & secure banking technology. + A free software and network project based on blockchain and I2P technology.

+ +

The creators behind DIVA.EXCHANGE are convinced that digital values are becoming common means of payment and stores of value.

+ +

The free software project demonstrates how the storage, trade and payment transactions with digital values can be carried out without central service providers – securely and with rigorous privacy protection.

+ +

This brings us one step closer to the vision that every person can be his or her own bank in the future.

+
+ exchange.diva.divachain.desktop + https://www.diva.exchange + DIVA.EXCHANGE + + + + + + + + + exchange.diva.divachain.desktop + + +