Fix clear and network check for curl pipe execution
- Guard `clear` with terminal check so it doesn't fail when TERM is unset (common in curl pipe context) - Use curl instead of ping for network check (ICMP often blocked in LXC) - Fix ((tries++)) from 0 evaluating as falsy under set -e https://claude.ai/code/session_013gJJD3cxafQSVmyn9pXcdn
This commit is contained in:
parent
039a441a5d
commit
286a97d68c
1 changed files with 4 additions and 4 deletions
|
|
@ -148,7 +148,7 @@ get_ip() {
|
||||||
# -- Header --------------------------------------------------------------------
|
# -- Header --------------------------------------------------------------------
|
||||||
|
|
||||||
header_info() {
|
header_info() {
|
||||||
clear
|
[[ -t 1 ]] && clear 2>/dev/null || true
|
||||||
echo ""
|
echo ""
|
||||||
cat <<"BANNER"
|
cat <<"BANNER"
|
||||||
____ _ ____
|
____ _ ____
|
||||||
|
|
@ -199,14 +199,14 @@ arch_check() {
|
||||||
|
|
||||||
network_check() {
|
network_check() {
|
||||||
msg_info "Checking network connectivity"
|
msg_info "Checking network connectivity"
|
||||||
local tries=0
|
local tries=1
|
||||||
while ! ping -c 1 -W 3 github.com &>/dev/null; do
|
while ! curl -fsSL --max-time 5 https://github.com >/dev/null 2>&1; do
|
||||||
((tries++))
|
|
||||||
if [[ $tries -ge 3 ]]; then
|
if [[ $tries -ge 3 ]]; then
|
||||||
msg_error "No network connectivity (cannot reach github.com)"
|
msg_error "No network connectivity (cannot reach github.com)"
|
||||||
echo -e "${TAB}${DIM}Ensure your LXC has a working network configuration.${CL}" >&2
|
echo -e "${TAB}${DIM}Ensure your LXC has a working network configuration.${CL}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
((tries++)) || true
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
msg_ok "Network connectivity verified"
|
msg_ok "Network connectivity verified"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue