#!/bin/bash toolName=coturn toolConf="/etc/turnserver.conf" # Get script working directory # (when called from a different directory) WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)" APTOPT= CONFIG=0 SCRIPT_FILE=$(basename -- $0) SCRIPT_NAME=${SCRIPT_FILE%%.*} CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg" CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example" step_config() { #echo "Called once before executing steps." ## e.g. to source a config file manually: #. "$CONFIG_FILE" ## or to use sequencer api with global config file: #initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" ## or to use sequencer api with profile config file support: #initSeqConfig -p "$SCRIPT_NAME" "$CONFIG_FILE_TEMPLATE" #if [ $? -eq 0 ] ; then # CONFIG=1 #else # # End if no configuration file exists # [ $DRY -eq 0 ] && return -1 #fi [ $QUIET -ne 0 ] && APTOPT="-y" return 0 } step_1_info() { echo "Install coturn"; } 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_alias() { ALIAS="updateip"; } step_10() { shift 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" if [ "$pubIp" != "$confIp" ]; then echoseq " [I] Update required" exe sed -i "s/^external-ip[[:space:]]*=.*/external-ip=${pubIp}/" "$toolConf" exe service coturn restart else echoseq " [I] No update required" fi } step_12_info() { echo "Setup public ip update cron job every 5 minutes"; } step_12_alias() { ALIAS="cronip"; } step_12() { echoseq " [I] Setup $ipCronLoc" addConf -s "$ipCron" "$ipCronLoc" } ipCronLoc="/etc/cron.d/update_public_ip" ipCron="*/5 * * * * root $WDIR/$SCRIPT_FILE -qq updateip" VERSION_SEQREV=12 . /usr/local/bin/sequencer.sh