From 53b8fe837640f472c1fa03971e8d8652170c03e2 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Wed, 8 Apr 2020 00:32:15 +0200 Subject: [PATCH] extract variable "jail_sshd_config" --- lib/bkctld-port | 6 ++++-- lib/includes | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/bkctld-port b/lib/bkctld-port index 499c53b..1ee67c7 100755 --- a/lib/bkctld-port +++ b/lib/bkctld-port @@ -17,15 +17,17 @@ jail_path=$(jail_path "${jail_name}") test -d "${jail_path}" || error "${jail_name}: jail is missing." +jail_sshd_config="${jail_path}/${SSHD_CONFIG}" + if [ -z "${port}" ]; then - grep -E "Port [0-9]+" "${jail_path}/${SSHD_CONFIG}"|grep -oE "[0-9]+" + grep -E "Port [0-9]+" "${jail_sshd_config}"|grep -oE "[0-9]+" else if [ "${port}" = "auto" ]; then port=$(grep -h Port "${JAILDIR}"/*/"${SSHD_CONFIG}" 2>/dev/null | grep -Eo "[0-9]+" | sort -n | tail -1) port=$((port+1)) [ "${port}" -le 1 ] && port=2222 fi - sed -i "s/^Port .*/Port ${port}/" "${jail_path}/${SSHD_CONFIG}" + sed -i "s/^Port .*/Port ${port}/" "${jail_sshd_config}" notice "${jail_name}: port has been updated to ${port}" diff --git a/lib/includes b/lib/includes index 2b9227a..adc4691 100755 --- a/lib/includes +++ b/lib/includes @@ -226,12 +226,13 @@ setup_jail_config() { jail_name=${1:?} jail_path=$(jail_path "${jail_name}") + jail_sshd_config="${jail_path}/${SSHD_CONFIG}" - sshd_config="${TPLDIR}/sshd_config" - test -f "${LOCALTPLDIR}/sshd_config" && sshd_config="${LOCALTPLDIR}/sshd_config" + sshd_config_tpl="${TPLDIR}/sshd_config" + test -f "${LOCALTPLDIR}/sshd_config" && sshd_config_tpl="${LOCALTPLDIR}/sshd_config" info "4 - Copie default sshd_config" - install -m 0640 "${sshd_config}" "${jail_path}/${SSHD_CONFIG}" + install -m 0640 "${sshd_config_tpl}" "${jail_sshd_config}" inctpl="${TPLDIR}/inc.tpl" test -f "${LOCALTPLDIR}/inc.tpl" && inctpl="${LOCALTPLDIR}/inc.tpl"