Script for "Core Restart Now"

Hi all, I have been here before for a script that I can use for an alert to when the TRUNK or REGISTRY fail, this works 100%, Now I have another question, How can I add the “core restart now” to my script as to when it finds that the TRUNK or REGISTRY failed that it can automatically do a core restart now.

I have found that when this happens I need to log in to my FPBX server and do the CLI “core restart now” for all to register again.

Look at my script I’m running at this moment for the alert.

####script start####

#!/bin/bash

[email protected]
HOST=XXXXXXXXXXX.co.za
asteriskbin=/usr/sbin/rasterisk

thistrunk=Screamer
checkifok=$asteriskbin -rx "sip show peer $thistrunk" | grep Status | grep -wc OK
if [[ $checkifok == 0 ]]; then
echo “Trunk is DOWN” | mail -s " - Trunk is Down [$HOST] -" "$EMAIL"
else
echo "Trunk OK"
fi

####script end####

I would like to add this to the "echo “Trunk is DOWN” line as to sent me an e-mail as it does and then do the core restart now command.

Would that be possible and are there someone out there that might be able to help me.

Thank you

$asteriskbin -rx "core restart now"

or

$asteriskbin -rx "core restart when convenient"

BTW those are back-tick not single quotes. That tells the script to start a shell and run the command.

Thank you, It was really dumb of me not to think of that… Thank you it works nice.

Regards

You are welcome. Always happy to help.