forked from evolix/evobackup
24 lines
724 B
Plaintext
24 lines
724 B
Plaintext
|
#!/bin/sh
|
||
|
|
||
|
LIBDIR="$(dirname $0)" && . "${LIBDIR}/config"
|
||
|
|
||
|
jail="${1:-}"
|
||
|
port="${2:-}"
|
||
|
[ -n "${jail}" ] || usage
|
||
|
check_jail "${jail}" || error "${jail} : inexistant jail'"
|
||
|
|
||
|
if [ -z "${port}" ]; then
|
||
|
grep -E "Port [0-9]+" "${JAILDIR}/${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}/" "${JAILDIR}/$jail/${SSHD_CONFIG}"
|
||
|
set_firewall "${jail}"
|
||
|
notice "${jail} : update port => ${port}"
|
||
|
|
||
|
check_jail_on "${jail}" && . "${LIBDIR}/bkctld-reload" "${jail}"
|
||
|
fi
|