-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_ipfs
35 lines (31 loc) · 852 Bytes
/
start_ipfs
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
35
#!/bin/sh
set -e
user=ipfs
repo="$IPFS_PATH"
if [ `id -u` -eq 0 ]; then
echo "Changing user to $user"
# ensure folder is writable
su-exec "$user" test -w "$repo" || chown -R -- "$user" "$repo"
# restart script with new privileges
exec su-exec "$user" "$0" "$@"
fi
# 2nd invocation with regular user
ipfs version
if [ -e "$repo/config" ]; then
echo "Found IPFS fs-repo at $repo"
else
case "$IPFS_PROFILE" in
"") INIT_ARGS="" ;;
*) INIT_ARGS="--profile=$IPFS_PROFILE" ;;
esac
# copy swarm.key to repo
cp /swarm.key $repo/swarm.key
# init ipfs
ipfs init $INIT_ARGS
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
ipfs config Datastore.StorageMax 20GB
ipfs bootstrap rm all
ipfs bootstrap add /dns4/$SWARM_NODE/tcp/4001/ipfs/$SWARM_NODE_ID
fi
exec ipfs "$@"