Extended log option for updateip
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
toolName=coturn
|
toolName=coturn
|
||||||
toolConf="/etc/turnserver.conf"
|
toolConf="/etc/turnserver.conf"
|
||||||
|
toolServiceName="coturn.service"
|
||||||
|
|
||||||
# Get script working directory
|
# Get script working directory
|
||||||
# (when called from a different directory)
|
# (when called from a different directory)
|
||||||
@@ -31,31 +32,44 @@ step_config() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
step_1_info() { echo "Install coturn"; }
|
step_1_info() { echo "Install $toolName"; }
|
||||||
step_1_alias() { ALIAS="install"; }
|
step_1_alias() { ALIAS="install"; }
|
||||||
step_1() {
|
step_1() {
|
||||||
exe apt update
|
exe apt update
|
||||||
exe apt install coturn $APTOPT
|
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_alias() { ALIAS="updateip"; }
|
||||||
step_10() {
|
step_10() {
|
||||||
shift
|
shift
|
||||||
|
local lecho="echoseq"
|
||||||
|
if [ "$1" == "-l" ]; then
|
||||||
|
lecho="echo"
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
local dnsUrl="46.182.19.48" #digitalcourage.de/support/zensurfreier-dns-server
|
local dnsUrl="46.182.19.48" #digitalcourage.de/support/zensurfreier-dns-server
|
||||||
[ ! -z "$1" ] && dnsUrl="$1"
|
[ ! -z "$1" ] && dnsUrl="$1"
|
||||||
|
|
||||||
local pubIp=$(dig @$dnsUrl +short cloud.imoff.de)
|
local pubIp=$(dig @$dnsUrl +short cloud.imoff.de)
|
||||||
local confIp=`cat "$toolConf" | grep "^external-ip" | cut -d'=' -f2`
|
local confIp=`cat "$toolConf" | grep "^external-ip" | cut -d'=' -f2`
|
||||||
|
local locDate=`date`
|
||||||
echoseq "Current public ip: $pubIp"
|
|
||||||
echoseq "Configured public ip: $confIp"
|
|
||||||
|
|
||||||
if [ "$pubIp" != "$confIp" ]; then
|
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 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
|
else
|
||||||
echoseq " [I] No update required"
|
echoseq " [I] No update required. Current ip: $confIp"
|
||||||
|
echoseq " $locDate"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user