Linux script for Asterisk (updating IP)
Go to solution
Solved by Fetzie,
A few pointers that could help you:
#!/bin/bash myIP=$(dig +short myip.opendns.com @resolver1.opendns.com)
Assuming the config file is formatted like this:
externalip=192.168.0.1
then you can call eval:
extIPSetting=$(cat /path/to/Unistim.conf | grep externalip)
eval ${extIPSetting}
extIpFromFile=${externalip}
Then compare them and if they aren't equal, replace it with something like this:
if [ "${extIpFromFile}" != "${myIP}" ]; then
sed -i "s/externalip=${extIpFromFile}/externalip=${myIP}/g" /path/to/Unistim.conf
fi
You can execute "restart gracefully" to stop Asterisk from accepting new calls and restart when call volume is empty, which should be:
asterisk -rx"restart gracefully"
Double-check the sed command (I always seem to get that wrong at the first attempt
) and the asterisk execution command, but it should work like that ![]()

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now