Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions bin/appimg.sh
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
#
# Author/Maintainer: DIVA.EXCHANGE Association <contact@diva.exchange>
#

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
21 changes: 11 additions & 10 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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 ]]
Expand All @@ -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 ]]
Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions bin/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion bin/halt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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}"
3 changes: 2 additions & 1 deletion bin/purge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}"
5 changes: 3 additions & 2 deletions bin/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}"
14 changes: 14 additions & 0 deletions bin/util/commands.sh
Original file line number Diff line number Diff line change
@@ -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
}

79 changes: 79 additions & 0 deletions build/exchange.diva.divachain.AppDir/AppRun
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
#
# Author/Maintainer: DIVA.EXCHANGE Association <contact@diva.exchange>
#

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 "$@"


1 change: 1 addition & 0 deletions build/exchange.diva.divachain.AppDir/bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
Binary file added build/exchange.diva.divachain.AppDir/divax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions build/exchange.diva.divachain.AppDir/lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
1 change: 1 addition & 0 deletions build/exchange.diva.divachain.AppDir/lib64/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
1 change: 1 addition & 0 deletions build/exchange.diva.divachain.AppDir/opt/i2pd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
1 change: 1 addition & 0 deletions build/exchange.diva.divachain.AppDir/usr/bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
1 change: 1 addition & 0 deletions build/exchange.diva.divachain.AppDir/usr/lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
Loading