-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_ipfs
46 lines (41 loc) · 1.53 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
#!/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
ipfs init
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials '["true"]'
fi
# if the first argument is daemon
if [ "$1" = "daemon" ]; then
# filter the first argument until
# https://github.com/ipfs/go-ipfs/pull/3573
# has been resolved
shift
else
# print deprecation warning
# go-ipfs used to hardcode "ipfs daemon" in it's entrypoint
# this workaround supports the new syntax so people start setting daemon explicitly
# when overwriting CMD, making this PR safe to merge
echo "DEPRECATED: arguments have been set but the first argument isn't 'daemon'" >&2
echo "DEPRECATED: run 'docker run ipfs/go-ipfs daemon $@' instead" >&2
echo "DEPRECATED: see the following PRs for more information:" >&2
echo "DEPRECATED: * https://github.com/ipfs/go-ipfs/pull/3573" >&2
echo "DEPRECATED: * https://github.com/ipfs/go-ipfs/pull/3685" >&2
fi
exec ipfs daemon "$@"