#!/bin/sh export BITMESSAGE_API_USER=${BITMESSAGE_API_USER:-bitmessage_api_user} export BITMESSAGE_API_PASSWORD=${BITMESSAGE_API_PASSWORD:-bitmessage_api_password} export BITMESSAGE_SEED_ADDRESSES=${BITMESSAGE_SEED_ADDRESSES:-1} export BITMESSAGE_API_PORT=${BITMESSAGE_API_PORT:-8442} export BITMESSAGE_TTL=${BITMESSAGE_TTL:-172800} export BITMESSAGE_STOPRESENDINGAFTERXDAYS=${BITMESSAGE_STOPRESENDINGAFTERXDAYS:-30} SEED_FILE="address_seed.txt" test -e "$SEED_FILE" || gosu bitmessage touch "$SEED_FILE" # Save seed to file, or use saved seed if [ -n "$BITMESSAGE_SEED_PHRASE" ] then export BITMESSAGE_SEED_PHRASE grep -q "$BITMESSAGE_SEED_PHRASE" "$SEED_FILE" \ || echo "$BITMESSAGE_SEED_PHRASE" >> "$SEED_FILE" else OLD_SEED="$(tail -n1 $SEED_FILE)" NEW_SEED="$(cat /dev/random | tr -dc "a-z" | head -c32)" export BITMESSAGE_SEED_PHRASE="${OLD_SEED:-$NEW_SEED}" fi # this command must be run as root (for bind mounts to container) chown bitmessage:bitmessage keys.dat chmod 600 keys.dat # set config values gosu bitmessage sed -i -e "s|\(apiinterface = \).*|\10\.0\.0\.0|g" \ -e "s|\(apivariant = \).*|\1legacy|g" \ -e "s|\(apiusername = \).*|\1$BITMESSAGE_API_USER|g" \ -e "s|\(apipassword = \).*|\1$BITMESSAGE_API_PASSWORD|g" \ -e "s|\(apiport = \).*|\1$BITMESSAGE_API_PORT|g" \ -e "s|\(apienabled = \).*|\1True|g" \ -e "s|\(ttl = \).*|\1$BITMESSAGE_TTL|g" \ -e "s|\(stopresendingafterxdays = \).*|\1$BITMESSAGE_STOPRESENDINGAFTERXDAYS|g" \ -e "s|\(udp = \).*|\1False|g" keys.dat # generate address from seed for i in {1..4} do sleep 15 gosu bitmessage /usr/bin/python /usr/local/bin/seed_addr_gen.py done & exec gosu bitmessage pybitmessage -d