mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Check if netstat or iproute2 is available
This commit is contained in:
parent
1aa2a027ed
commit
ceacae42a6
@ -22,13 +22,22 @@ ETCD_PORT=${ETCD_PORT:-2379}
|
||||
|
||||
kube::etcd::validate() {
|
||||
# validate if in path
|
||||
which etcd >/dev/null || {
|
||||
command -v etcd >/dev/null || {
|
||||
kube::log::usage "etcd must be in your PATH"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# validate etcd port is free
|
||||
if netstat -nat | grep "[\.:]${ETCD_PORT:?} .*LISTEN" >/dev/null 2>&1; then
|
||||
local port_check_command
|
||||
if command -v ss &> /dev/null && ss -Version | grep 'iproute2' &> /dev/null; then
|
||||
port_check_command="ss"
|
||||
elif command -v netstat &>/dev/null; then
|
||||
port_check_command="netstat"
|
||||
else
|
||||
kube::log::usage "unable to identify if etcd is bound to port ${ETCD_PORT}. unable to find ss or netstat utilities."
|
||||
exit 1
|
||||
fi
|
||||
if ${port_check_command} -nat | grep "LISTEN" | grep "[\.:]${ETCD_PORT:?}" >/dev/null 2>&1; then
|
||||
kube::log::usage "unable to start etcd as port ${ETCD_PORT} is in use. please stop the process listening on this port and retry."
|
||||
kube::log::usage "`netstat -nat | grep "[\.:]${ETCD_PORT:?} .*LISTEN"`"
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user