Add swarm key variables to container daemon
License: MIT Signed-off-by: Caian Benedicto <caianbene@gmail.com>
Caian committed
Aug 2, 2019 at 16:27 UTC
427205c1b6d6930784c15e01715957273489f5d3
1 file changed
+27
bin/container_daemon
+27
@@ -24,6 +24,33 @@ else
24
ipfs init $INIT_ARGS
25
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
26
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
27
+
28
+ # Set up the swarm key, if provided
29
+
30
+ SWARM_KEY_FILE="$repo/swarm.key"
31
+ SWARM_KEY_PERM=0400
32
+
33
+ # Create a swarm key from a given environment variable
34
+ if [ ! -z "$IPFS_SWARM_KEY" ] ; then
35
+ echo "Copying swarm key from variable..."
36
+ echo -e "$IPFS_SWARM_KEY" >"$SWARM_KEY_FILE" || exit 1
37
+ chmod $SWARM_KEY_PERM "$SWARM_KEY_FILE"
38
+ fi
39
+
40
+ # Unset the swarm key variable
41
+ unset IPFS_SWARM_KEY
42
+
43
+ # Check during initialization if a swarm key was provided and
44
+ # copy it to the ipfs directory with the right permissions
45
+ # WARNING: This will replace the swarm key if it exists
46
+ if [ ! -z "$IPFS_SWARM_KEY_FILE" ] ; then
47
+ echo "Copying swarm key from file..."
48
+ install -m $SWARM_KEY_PERM "$IPFS_SWARM_KEY_FILE" "$SWARM_KEY_FILE" || exit 1
49
+ fi
50
+
51
+ # Unset the swarm key file variable
52
+ unset IPFS_SWARM_KEY_FILE
53
+
54
fi
55
56
exec ipfs "$@"