aboutsummarylogtreecommitdiffstats
path: root/go-swarm.install
blob: 121b9e497f0c495bf5cead3fdabe355fc0fec9f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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	
	chown -v bzz:bzz /var/lib/bzz -R
	chmod 700 /var/lib/bzz/.ethereum/keystore 
}