Using a script to toggle the day/night mode to desired position

jdwebcc
Posts: 142
Member Since:
2006-09-27

I have written a simple script -- and it is ugly but it works.. This script forces the position of the day/night feature with a cronjob no matter its previous position.

I had a client that wants to be able to close and open by simply pressing a button on his phones.. so I setup a BLF button to the *280 day/night feature.. and it shows a green light for open and red for closed.

I then needed a way to reset this position no matter what position it was in incase the client forgot or the next day was a saturday... ie closed but left in open position.. this because SOME saturdays they are open. So the staff come in on the 2 saturdays (which rotate) per month to open for 4 hours.. the schedule routes to the day/night position for this 4 hour period that don't change.. the script moves the day/night toggle to the Closed position.. this for the saturdays they are closed... now staff only needs to hit the BLF button turning it from RED to GREEN.. then at 12:01 the system goes back to time conditioned position.. and that night the cronjob returns the day/night back to OPEN for Monday morning when the time conditions point back to the day/night feature.

Then if staff is there on a weekday and they close for a snow day -- they can just hit BLF button to change it from GREEN to RED to close.. and then at 18:00 the time conditions go to closed and the script returns the day/night feature back to open if the next day is a weekday.

Lastly, I gave them another DID just for this feature so if they leave the shop during business hours because they closed for snow or something they can just call this DID and it toggles it to the desired position also.

I made one open.sh and the other closed.sh -- chmod 777 to both. -- I have webmin installed so I use the simple schedule cronjob option to execute them.

I had to create a non-used extension that goes to MOH -- inorder to allow a call to be connected to a extension that will auto-answer. Also the script has to put the feature in the opposite mode -- then run the toggle to get to the desired position.

I know I know.. someone is going to say I only need one of these lines but doing so does NOT update the BLF light on the phone.. having them both together does.. and in the order listed..

I am very open to any suggestions.. as I am sure this can be done a smarter way... I just hacked my way through it.

Here is the two files

********************

open.sh

asterisk -rx 'database put DAYNIGHT C0 NIGHT'
asterisk -rx 'originate Local/601@from-internal/n extension *280@from-internal'

********************

closed.sh
asterisk -rx 'database put DAYNIGHT C0 DAY'
asterisk -rx 'originate Local/601@from-internal/n extension *280@from-internal'

Hopefully this helps someone else.. and please no bashing on the crude methods I used.. as it does work.

Jason S Derr, JDWEB.cc LLC
http://www.jdweb.cc

Creator of ASR Manager

--

Jason S Derr, JDWEB.cc LLC
Creator of ASR Manager