{{- define "containers-init-linux" -}}
- name: init-volume
  image: "{{ include "image-path" (dict "root" .Values "image" .Values.agents.image) }}"
  imagePullPolicy: {{ .Values.agents.image.pullPolicy }}
  command: ["bash", "-c"]
  args:
    - cp -r /etc/datadog-agent /opt
  volumeMounts:
    - name: config
      mountPath: /opt/datadog-agent
  resources:
{{ toYaml .Values.agents.containers.initContainers.resources | indent 4 }}
- name: init-config
  image: "{{ include "image-path" (dict "root" .Values "image" .Values.agents.image) }}"
  imagePullPolicy: {{ .Values.agents.image.pullPolicy }}
  command: ["bash", "-c"]
  args:
    - for script in $(find /etc/cont-init.d/ -type f -name '*.sh' | sort) ; do bash $script ; done
  volumeMounts:
    - name: logdatadog
      mountPath: /var/log/datadog
    - name: config
      mountPath: /etc/datadog-agent
    {{- if (or (.Values.datadog.confd) (.Values.datadog.autoconf)) }}
    - name: confd
      mountPath: /conf.d
      readOnly: true
    {{- end }}
    {{- if .Values.datadog.checksd }}
    - name: checksd
      mountPath: /checks.d
      readOnly: true
    {{- end }}
    - name: procdir
      mountPath: /host/proc
      mountPropagation: {{ .Values.datadog.hostVolumeMountPropagation }}
      readOnly: true
    {{- include "container-crisocket-volumemounts" . | nindent 4 }}
    {{- if eq (include "should-enable-system-probe" .) "true" }}
    - name: sysprobe-config
      mountPath: /etc/datadog-agent/system-probe.yaml
      subPath: system-probe.yaml
    {{- end }}
  env:
    {{- include "containers-common-env" . | nindent 4 }}
    {{- if and (eq (include "cluster-agent-enabled" .) "false") .Values.datadog.leaderElection }}
    - name: DD_LEADER_ELECTION
      value: {{ .Values.datadog.leaderElection | quote }}
    {{- end }}
  resources:
{{ toYaml .Values.agents.containers.initContainers.resources | indent 4 }}
{{- end -}}
