From patchwork Thu Jun 1 15:00:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Devel] scripts: use absolute binaries paths nfs-ports-allow.sh From: Stanislav Kinsburskiy X-Patchwork-Id: 5373 Message-Id: <20170601145616.556345.44860.stgit@skinsbursky-vz7.qa.sw.ru> To: Cc: devel@openvz.org Date: Thu, 1 Jun 2017 18:00:12 +0300 That's the way to support multiple distributions. https://jira.sw.ru/browse/PSBM-66901 Signed-off-by: Stanislav Kinsburskiy --- scripts/nfs-ports-allow.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/scripts/nfs-ports-allow.sh b/scripts/nfs-ports-allow.sh index b16a788..97541dc 100644 --- a/scripts/nfs-ports-allow.sh +++ b/scripts/nfs-ports-allow.sh @@ -25,7 +25,10 @@ JOIN_CT="${NS_ENTER} -t $CRTOOLS_INIT_PID -m -u -p -n" ${JOIN_CT} test -e /proc/self/net/nfsfs || exit 0 -servers=$($JOIN_CT cat /proc/self/net/nfsfs/servers | sed -e '1d' | awk '{ printf $5" ";}') +IPTABLES=/sbin/iptables +CAT=/bin/cat + +servers=$($JOIN_CT ${CAT} /proc/self/net/nfsfs/servers | sed -e '1d' | awk '{ printf $5" ";}') [ -n "$servers" ] || exit 0 @@ -33,10 +36,10 @@ function add_accept_rules { local server=$1 local port=$2 - ${JOIN_CT} iptables -I ${CRTOOLS_IPTABLES_TABLE} -p tcp -s $server --sport $port -j ACCEPT && - ${JOIN_CT} iptables -I ${CRTOOLS_IPTABLES_TABLE} -p tcp -d $server --dport $port -j ACCEPT && - ${JOIN_CT} iptables -I ${CRTOOLS_IPTABLES_TABLE} -p udp -s $server --sport $port -j ACCEPT && - ${JOIN_CT} iptables -I ${CRTOOLS_IPTABLES_TABLE} -p udp -d $server --dport $port -j ACCEPT + ${JOIN_CT} ${IPTABLES} -I ${CRTOOLS_IPTABLES_TABLE} -p tcp -s $server --sport $port -j ACCEPT && + ${JOIN_CT} ${IPTABLES} -I ${CRTOOLS_IPTABLES_TABLE} -p tcp -d $server --dport $port -j ACCEPT && + ${JOIN_CT} ${IPTABLES} -I ${CRTOOLS_IPTABLES_TABLE} -p udp -s $server --sport $port -j ACCEPT && + ${JOIN_CT} ${IPTABLES} -I ${CRTOOLS_IPTABLES_TABLE} -p udp -d $server --dport $port -j ACCEPT } function iptables_allow_nfs_ports { @@ -60,10 +63,10 @@ function allow_portmapper_port { local server=$1 local port=111 - ${JOIN_CT} iptables -I ${CRTOOLS_IPTABLES_TABLE} -p udp -s $server --sport $port -j ACCEPT && - ${JOIN_CT} iptables -I ${CRTOOLS_IPTABLES_TABLE} -p udp -d $server --dport $port -j ACCEPT && - ${JOIN_CT} iptables -I ${CRTOOLS_IPTABLES_TABLE} -p tcp -s $server --sport $port -j ACCEPT && - ${JOIN_CT} iptables -I ${CRTOOLS_IPTABLES_TABLE} -p tcp -d $server --dport $port -j ACCEPT + ${JOIN_CT} ${IPTABLES} -I ${CRTOOLS_IPTABLES_TABLE} -p udp -s $server --sport $port -j ACCEPT && + ${JOIN_CT} ${IPTABLES} -I ${CRTOOLS_IPTABLES_TABLE} -p udp -d $server --dport $port -j ACCEPT && + ${JOIN_CT} ${IPTABLES} -I ${CRTOOLS_IPTABLES_TABLE} -p tcp -s $server --sport $port -j ACCEPT && + ${JOIN_CT} ${IPTABLES} -I ${CRTOOLS_IPTABLES_TABLE} -p tcp -d $server --dport $port -j ACCEPT } for s in $servers; do