Skip to content

Commit

Permalink
add healthcheck.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Zoey <[email protected]>
  • Loading branch information
Zoey2936 authored Oct 22, 2023
1 parent d78a7b9 commit 15b1888
Showing 1 changed file with 7 additions and 55 deletions.
62 changes: 7 additions & 55 deletions healthcheck.sh
Original file line number Diff line number Diff line change
@@ -1,63 +1,15 @@
#!/bin/sh

if [ -z "$TZ" ] || ! echo "$TZ" | grep -q "^[A-Za-z/]\+$"; then
echo "TZ is unset or invalid."
exit 1
if ! [ -f /tmp/IPv4.json ] && ! [ -f /tmp/IPv6.json ]; then
exit 1
fi

if [ -z "$DUK" ] || ! echo "$DUK" | grep -q "^[A-Za-z0-9]\+$"; then
echo "DUK is unset or invalid, it can consist of upper letters A-Z, lower letters a-z and numbers 0-9."
exit 1
if [ -f /tmp/IPv4.json ] && [ "$(cat /tmp/IPv4.json | jq -r .status)" != "success" ]; then
exit 1
fi


if [ "$IPv4" = "false" ] || [ "$(curl -s4 ipv64.net; echo $?)" != "7" ]; then
if ! echo "$IPv4" | grep -q "^true$\|^false$"; then
echo "IPv4 needs to be true or false."
exit 1
fi
else
if [ "$IPv4" != "false" ]; then
if ! echo "$IPv4" | grep -q "^true$\|^false$"; then
echo "IPv4 needs to be true or false."
exit 1
fi
echo "IPv4 does not work, disabling it."
export IPv4="false"
fi
fi


if [ "$IPv6" = "false" ] || [ "$(curl -s6 ipv64.net; echo $?)" != "7" ]; then
if ! echo "$IPv6" | grep -q "^true$\|^false$"; then
echo "IPv6 needs to be true or false."
exit 1
fi
else
if [ "$IPv6" != "false" ]; then
if ! echo "$IPv6" | grep -q "^true$\|^false$"; then
echo "IPv6 needs to be true or false."
exit 1
fi
echo "IPv6 does not work, disabling it."
export IPv6="false"
fi
if [ -f /tmp/IPv6.json ] && [ "$(cat /tmp/IPv6.json | jq -r .status)" != "success" ]; then
exit 1
fi


if ! echo "$UI" | grep -q "^[0-9]\+[smhd]\?$"; then
echo "UI needs to be a number which can be followed by one of the chars s, m, h or d."
exit 1
fi

if [ "$IPv4" = "false" ] && [ "$IPv6" = "false" ]; then
echo "IPv4 and IPv6 disabled, stopping."
exit 1
fi

if [ "$IPv4" = "true" ]; then
curl -sLS4 https://ipv64.net/update.php?key="$DUK" || exit 1
fi
if [ "$IPv6" = "true" ]; then
curl -sLS6 https://ipv64.net/update.php?key="$DUK" || exit 1
fi
exit 0

0 comments on commit 15b1888

Please sign in to comment.