-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Zoey <[email protected]>
- Loading branch information
Showing
1 changed file
with
7 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |