This post is at: ForumFeatures Wanted
8 posts / 0 new
Last post
joshjacoby
joshjacoby's picture
Joined: 2010/10/14
Points: 0

Not sure if this exists now, but it would be nice if the reload and restart functions in the GUI could perhaps execute a script file that I could edit. Initial purpose here is when I reload the system I want to execute a script to back-up the configuration files so I could potentially regress to a previous system state should the need arise. Easiest way would be to just add a quick command to the existing reload script to run my file.

eeman
eeman's picture
Joined: 2007/11/06
Points: 290

no, I don't think you understand what reload is or does.. because potentially there could have been 2000 different changes since the last reload. The file gets altered as soon as you click 'save' on a specific page. You could make hundreds of changes, before clicking reload. If you are using MTE there is also the automatic reloading process that runs every 15min to scan for a pending reload and you wouldn't know when your customer makes a change. There is also the question of reversion because one tenant screwed up (nothing is actually crashing asterisk or anything, he just screwed up his route) and you go and hit the rewind button, and suddenly all the work another tenant just spent time doing is wiped out.

your best option is just using the thirdlane backup utility and keep nightly backups, with the option of an immediate backup if you're really paranoid. There really should not exist the need to press the rewind button because your inbound route isnt doing what you want it to do, its simpler just to re-edit the inbound route than to restore a backup.

Erik Smith
dCAP
Thirdlane/Asterisk Support available
esmith.bgnv@gmail.com

joshjacoby
joshjacoby's picture
Joined: 2010/10/14
Points: 0

I do actually understand the function of reload quite well, and while you make valid points, they don't answer my question of whether we can execute our own custom script at the time of reload. In our situation we don't give the tenants access to the system in the way you describe and our changes are tightly controlled. I was trying to improve our internal workflow.

eeman
eeman's picture
Joined: 2007/11/06
Points: 290

unfortunately no, the reload event is an AMI communication, there are no hooks to allow for that.

Erik Smith
dCAP
Thirdlane/Asterisk Support available
esmith.bgnv@gmail.com

rfrantik
rfrantik's picture
Joined: 2010/11/16
Points: 0

Erik, you mention the "MTE automatic reloading", how is that supposed to work? Does it actually do the reload or just scan for the need to prompt for a reload in the GUI? We are on Asterisk v1.6.2.11 and MTE v6.1.1.12. I don't see it doing an actual reload, so I'm assuming it's just prompting.

As a followup. I've got the MTE set to do a cron reload at 1am using the following command:

>asterisk -rx "reload"

It looks like the the CLI reload doesn't clear the prompt in the GUI. Is there a way to do this?

rfrantik
rfrantik's picture
Joined: 2010/11/16
Points: 0

Yes, that thread had the info I was looking for... for anyone else that finds this...

Any time the MTE updates data that needs a reload it writes this file out to the drive, /etc/webmin/asterisk/reload_default. This file doesn't appear to contain any data, but is just an indicator that a reload is necessary. If this file exists, the "reload" button appears on the webpage. The manual reload

asterisk -rx "reload"

doesn't clear this file, so we issue a remove command to clear the file and remove the button via the cron script.

rm /etc/webmin/asterisk/reload_default

moshe
moshe's picture
Joined: 2008/11/30
Points: 10

@rfrantik just a thought you might use the same cron job that executes the reload to run your script followed by the reload

joshjacoby
joshjacoby's picture
Joined: 2010/10/14
Points: 0

I have found a workable solution to this initial problem using the INCRON functionality. INCRON allows me to monitor a specific folder for changes and then execute a shell script upon such a change. Very handy. More details here http://www.cyberciti.biz/faq/linux-inotify-examples-to-replicate-directo...

So I need to make an entry using incrontab -e
/etc/webmin/asterisk IN_DELETE /path-to-script.bat $#

This means I want to monitor the /etc/webmin/asterisk folder for any deletions, and upon a deletion, execute /path-to-script.bat. The $# passes the deleted file name to the script as a parameter.

Of course I need to make sure the deleted file is actually called reload_default and not just some other file in that folder. I do that by adding some logic to the start of my script.

#!/bin/bash
if test $1 != "reload_default"
then
exit
fi
## put commands to execute here ##

This looks at the first parameter ($1) and if it is anything other than "reload_default", the script exits. Otherwise it continues and executes my commands.

This works very well for what I need.