From 86cee821ba58cbaa08b0947506526e040923d68c Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Fri, 26 Mar 2021 22:42:27 +0100 Subject: [PATCH] Extended log option for updateip --- seqs/coturn.sh | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/seqs/coturn.sh b/seqs/coturn.sh index cd4ca54..2a82934 100755 --- a/seqs/coturn.sh +++ b/seqs/coturn.sh @@ -2,6 +2,7 @@ toolName=coturn toolConf="/etc/turnserver.conf" +toolServiceName="coturn.service" # Get script working directory # (when called from a different directory) @@ -31,31 +32,44 @@ step_config() { return 0 } -step_1_info() { echo "Install coturn"; } +step_1_info() { echo "Install $toolName"; } step_1_alias() { ALIAS="install"; } step_1() { exe apt update exe apt install coturn $APTOPT } -step_10_info() { echo "Update coturn 'external-ip' using dig [CUSTOM DNS]"; } +step_10_info() { + echo "Update $toolName 'external-ip' using dig [OPTION] [CUSTOM DNS]" + echoinfo " [OPTION]" + echoinfo " -l : Always output informations (even with -qq)" +} step_10_alias() { ALIAS="updateip"; } step_10() { shift + local lecho="echoseq" + if [ "$1" == "-l" ]; then + lecho="echo" + shift + fi + local dnsUrl="46.182.19.48" #digitalcourage.de/support/zensurfreier-dns-server [ ! -z "$1" ] && dnsUrl="$1" + local pubIp=$(dig @$dnsUrl +short cloud.imoff.de) local confIp=`cat "$toolConf" | grep "^external-ip" | cut -d'=' -f2` - - echoseq "Current public ip: $pubIp" - echoseq "Configured public ip: $confIp" + local locDate=`date` if [ "$pubIp" != "$confIp" ]; then - echoseq " [I] Update required" + $lecho " [I] Update required. New public ip: $pubIp" + $lecho " $locDate" exe sed -i "s/^external-ip[[:space:]]*=.*/external-ip=${pubIp}/" "$toolConf" - exe service coturn restart + exe sleep 1 + $lecho " [I] Restarting $toolName" + exe /bin/systemctl restart $toolServiceName else - echoseq " [I] No update required" + echoseq " [I] No update required. Current ip: $confIp" + echoseq " $locDate" fi }