Files
truecharts/charts/qbittorrent/1.0.0/templates/configmap.yaml
T
renovate[bot]kjeld Schouten-LebbingRenovate Botrenovate[bot] <renovate[bot]@users.noreply.github.com>
c4bfa5cab1 [0.1.2] Update Helm chart common to v1 (#116)
* [0.1.2] Update Helm chart common to v1

* Update-Folder-Names-and-Dependencies

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: renovate[bot] <renovate[bot]@users.noreply.github.com>
2021-02-16 15:24:44 +01:00

33 lines
1.3 KiB
YAML

apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "common.names.fullname" . }}-scripts
labels:
{{- include "common.labels" . | nindent 4 }}
data:
{{- /* Determine if the bittorrent port is set somewhere */ -}}
{{- $bittorrentPort := "" -}}
{{- range $extraServices := .Values.service.additionalServices }}
{{- if and .enabled (eq "bittorrent" .nameSuffix) -}}
{{- $bittorrentPort = .port.port -}}
{{- end }}
{{- end }}
{{- if $bittorrentPort }}
31-update-port: |-
#!/bin/bash
QBITTORRENT_CONFIGFILE="/config/qBittorrent/qBittorrent.conf"
INCOMING_PORT={{- $bittorrentPort }}
incoming_port_exist=$(cat ${QBITTORRENT_CONFIGFILE} | grep -m 1 'Connection\\PortRangeMin='${INCOMING_PORT})
if [[ -z "${incoming_port_exist}" ]]; then
incoming_exist=$(cat ${QBITTORRENT_CONFIGFILE} | grep -m 1 'Connection\\PortRangeMin')
if [[ ! -z "${incoming_exist}" ]]; then
# Get line number of Incoming
LINE_NUM=$(grep -Fn -m 1 'Connection\PortRangeMin' ${QBITTORRENT_CONFIGFILE} | cut -d: -f 1)
sed -i "${LINE_NUM}s@.*@Connection\\\PortRangeMin=${INCOMING_PORT}@" ${QBITTORRENT_CONFIGFILE}
else
echo "Connection\\PortRangeMin=${INCOMING_PORT}" >> ${QBITTORRENT_CONFIGFILE}
fi
fi
{{- end }}