aboutsummaryrefslogtreecommitdiffhomepage
path: root/docker/rootfs/etc/s6-overlay/s6-rc.d/key-secret/up.real
blob: 90a13dcd84ef558f3bffb04b38dd7928dcbd46d1 (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
35
#!/command/with-contenv sh

if [ ! -d /data ] ; then
  mkdir /data
fi

# normal docker secrets
if [ ! -f /data/id_ed25519.pub ] && [ -r /run/secrets/key_pub ] ; then
  cp /run/secrets/key_pub /data/id_ed25519.pub
  echo "Public key created from secret"
fi

if [ ! -f /data/id_ed25519 ] && [ -r /run/secrets/key_priv ] ; then
  cp /run/secrets/key_priv /data/id_ed25519
  echo "Private key created from secret"
fi

# ENV variables
if [ ! -f /data/id_ed25519.pub ] && [ ! "$KEY_PUB" = "" ] ; then
  echo -n "$KEY_PUB" > /data/id_ed25519.pub
  echo "Public key created from ENV variable"
fi

if [ ! -f /data/id_ed25519 ] && [ ! "$KEY_PRIV" = "" ] ; then
  echo -n "$KEY_PRIV" > /data/id_ed25519
  echo "Private key created from ENV variable"
fi

# fix perms
if [ -f /data/id_ed25519.pub ] ; then
  chmod 600 /data/id_ed25519.pub 
fi
if [ -f /data/id_ed25519 ] ; then
  chmod 600 /data/id_ed25519
fi