post_install () { if [ -f /var/lib/bzz/.swarm-pass ]; then echo "you already have a Swarm data dir. I'll leave it alone ;)" return 0 fi mkdir -p /var/lib/bzz/.ethereum/keystore gethbin=$(which geth) if [ ! -z $gethbin ]; then echo "generating wallet with geth" tmpkey=$(mktemp -d) pushd ${tmpkey} dd if=/dev/urandom of=.swarm-pass bs=1 count=64 geth --datadir /var/lib/bzz/.ethereum --password ${tmpkey}/.swarm-pass account new install -v -D -m600 .swarm-pass /var/lib/bzz/.swarm-pass popd rm -vrf ${tmpkey} elif [ -x /usr/local/bin/swarm-genkey ]; then echo "generating wallet with swarm-genkey" tmpkey=$(mktemp -d) pushd ${tmpkey} /usr/local/bin/swarm-genkey install -v -D -m600 .swarm-pass /var/lib/bzz/.swarm-pass install -v -D -m600 UTC* /var/lib/bzz/.ethereum/keystore/ popd rm -vrf ${tmpkey} else echo "Missing optional dependencies required to automatically generate a ethereum wallet for the swarm node" echo "You will not be able to run a node with it" echo "You can generate it manually later using go-ethereum or the swarm-genkey.py script provided this package, provided dependencies are met" fi echo "setting up variables for systemd service" account=$(ls /var/lib/bzz/.ethereum/keystore | sed -e 's/^.*--\([a-fA-F0-9]*\)$/\1/') echo "SWARM_ACCOUNT=$account" > /etc/systemd/system/swarm.service.d/42-swarm.conf echo "SWARM_PASSWORD=/var/lib/bzz/.swarm-pass" >> /etc/systemd/system/swarm.service.d/42-swarm.conf chown -v bzz:bzz /var/lib/bzz -R chmod 700 /var/lib/bzz/.ethereum/keystore }