From bf3f0ed24fcf396bc351538df9ea8ef2a5075dc5 Mon Sep 17 00:00:00 2001 From: Neshura Date: Sun, 27 Nov 2022 17:08:20 +0100 Subject: [PATCH] Closes #4 Does not break usage outside of a Docker container, specify "docker" for use in a docker container --- set_ip.sh | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/set_ip.sh b/set_ip.sh index a1549e7..149b3f5 100644 --- a/set_ip.sh +++ b/set_ip.sh @@ -1,10 +1,21 @@ #!/bin/bash -cd "/usr/bin/app" || exit -while : -do -ipv4=$(curl -k -s https://am.i.mullvad.net/ip) -ipv6=$(curl -k -s https://ipv6.am.i.mullvad.net/) -python3 ./cloudflare_script.py 4 "$ipv4" -python3 ./cloudflare_script.py 6 "$ipv6" -sleep 120 -done \ No newline at end of file +if [ "$1" = "docker" ]; then + cd "/usr/bin/app" || exit + while : + do + ipv4=$(curl -k -s https://am.i.mullvad.net/ip) + ipv6=$(curl -k -s https://ipv6.am.i.mullvad.net/) + python3 ./cloudflare_script.py 4 "$ipv4" + python3 ./cloudflare_script.py 6 "$ipv6" + sleep 120 + done +else + if [ ! -e cloudflare.json ] || [ ! -e config.ini ]; then + echo "Cloudflare config not found, is the script run in the correct directory?" + else + ipv4=$(curl -k -s https://am.i.mullvad.net/ip) + ipv6=$(curl -k -s https://ipv6.am.i.mullvad.net/) + python3 ./cloudflare_script.py 4 "$ipv4" + python3 ./cloudflare_script.py 6 "$ipv6" + fi +fi \ No newline at end of file