Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rmfakecloud-proxy: Set status check timeout to 5s #561

Merged
merged 4 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package/rmfakecloud-proxy/package
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ pkgdesc="Connect Xochitl to a rmfakecloud server"
_url=https://github.com/ddvk/rmfakecloud-proxy
url="$_url"
_upver=0.0.3
pkgver="$_upver-2"
timestamp=2021-09-26T20:38:44Z
pkgver="$_upver-3"
timestamp=2022-02-26T22:59Z
section="utils"
maintainer="Mattéo Delabre <[email protected]>"
license=MIT
Expand Down
26 changes: 17 additions & 9 deletions package/rmfakecloud-proxy/rmfakecloudctl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ green="\033[32m"
yellow="\033[33m"
reset="\033[m"

# ANSI escape to clear line from cursor until end
clearline="\033[K"

# Disconnect Xochitl from the cloud
#
# This is a necessary step when switching cloud servers to prevent the client
Expand Down Expand Up @@ -157,8 +160,11 @@ check-upstream() {
local url="$upstream/service/json/1/test"
local contents
local wget_exit
contents="$(wget --output-document - --quiet "$url" 2>&1)" \
&& wget_exit=$? || wget_exit=$?
contents="$(wget \
--output-document - \
--quiet "$url" \
--tries 1 \
--timeout 5 2>&1)" && wget_exit=$? || wget_exit=$?

if [[ $wget_exit = 8 ]]; then
# HTTP error, the page probably doesn't exist
Expand Down Expand Up @@ -359,20 +365,22 @@ if [[ $0 = "${BASH_SOURCE[0]}" ]]; then
service="$yellow$service"
fi

echo -e "Status: $state$reset ($service$reset)"
echo -en "Upstream server: "

if ! upstream="$(get-upstream)"; then
upstream="(${yellow}not set$reset)"
echo -e "(${yellow}not set$reset)"
else
echo -en "$upstream (checking status...)"
if ! upstream_status="$(check-upstream "$upstream")"; then
upstream="$upstream ($red$upstream_status$reset)"
echo -en "\rUpstream server: $upstream "
echo -e "($red$upstream_status$reset)$clearline"
else
upstream="$upstream ($green$upstream_status$reset)"
echo -en "\rUpstream server: $upstream "
echo -e "($green$upstream_status$reset)$clearline"
fi
fi

echo -e "Status: $state$reset ($service$reset)"
echo -e "Upstream server: $upstream"
echo

if is-enabled; then
echo "Run \`rmfakecloudctl disable\` to disable \
rmfakecloud-proxy."
Expand Down