Files
truecharts/charts/stable/qbittorrent/templates/_configmap.tpl
T
Stavros KoisandGitHub a4b896dabf fix(apps): revert combine ports (#3119)
* Revert "chore(apps): combine some ports"

This reverts commit 6c3a74ab81c77e49a7a115f991862ba920092d51.

* Revert "lints"

This reverts commit b7f3ef949e26b4c4593b69dc2e910ff9dada932f.

* bumps
2022-07-10 11:21:55 +02:00

33 lines
1.2 KiB
Smarty

{{/* Define the configmap */}}
{{- define "qbittorrent.configmap" -}}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "tc.common.names.fullname" . }}-scripts
labels:
{{- include "tc.common.labels" . | nindent 4 }}
data:
{{- $bittorrentPort := "" -}}
{{- $bittorrentPort = .Values.service.torrent.ports.torrent.port -}}
{{- 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 }}
{{- end -}}