scale-catalog/test/qbittorrent/3.1.5/templates/configmap.yaml
2021-05-08 12:31:47 +02:00

46 lines
1.7 KiB
YAML

##
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# `SPDX-License-Identifier: Apache-2.0`
#
# This file is considered to be modified by the TrueCharts Project.
##
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "common.names.fullname" . }}-scripts
labels:
{{- include "common.labels" . | nindent 4 }}
data:
{{- $bittorrentPort := "" -}}
{{- $bittorrentPort = .Values.services.tcp.port.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 }}