Повесить скрипт в cron
#!/bin/bash
#
#This script change IP address in line 'externip=' in
#/etc/asterisk/sip.conf file to current WAN IP address
#
wan_ip=$(dig +short myip.opendns.com @resolver1.opendns.com)
cfg="/etc/asterisk/sip.conf"
current_ip=$(grep '^externip=' $cfg | sed 's/externip=//g')
if
[ "$wan_ip" != "$current_ip" ];
then
tmp_cfg=$cfg".tmp"
echo '[general]' > $tmp_cfg
echo "externip=$wan_ip" >> $tmp_cfg
cat $cfg | sed 1d | sed '/externip=/d' >>$tmp_cfg
mv -f $tmp_cfg $cfg
asterisk -rx "core reload"
else
echo "WAN IP is equal IP in config file"
fi
#!/bin/bash
#
#This script change IP address in line 'externip=' in
#/etc/asterisk/sip.conf file to current WAN IP address
#
wan_ip=$(dig +short myip.opendns.com @resolver1.opendns.com)
cfg="/etc/asterisk/sip.conf"
current_ip=$(grep '^externip=' $cfg | sed 's/externip=//g')
if
[ "$wan_ip" != "$current_ip" ];
then
tmp_cfg=$cfg".tmp"
echo '[general]' > $tmp_cfg
echo "externip=$wan_ip" >> $tmp_cfg
cat $cfg | sed 1d | sed '/externip=/d' >>$tmp_cfg
mv -f $tmp_cfg $cfg
asterisk -rx "core reload"
else
echo "WAN IP is equal IP in config file"
fi
Комментариев нет:
Отправить комментарий