apiVersion: v1
kind: ConfigMap
metadata:
  name: "initial-scripts"
  annotations:
    rollme: {{ randAlphaNum 5 | quote }}

data:
  init_config.sh: |-
    #!/bin/sh
    if ! [ -f ${DEFAULT_CERT_PATH} ] && ! [ -f ${DEFAULT_IDENTITY_CERT_PATH} ]; then
      curl -L https://github.com/storj/storj/releases/latest/download/identity_linux_amd64.zip -o identity_linux_amd64.zip
      unzip -o identity_linux_amd64.zip
      chmod +x identity
      ./identity create storagenode
      ./identity authorize storagenode ${AUTH_KEY}
      chown -R {{ .Values.runAsUser }}:{{ .Values.runAsGroup }} {{ .Values.identityCreationMountPath }}
    fi
