This solution is for older Asterisk/FreePBX installations (v2.11 and below) where the Time Condition module doesn’t have the Time Zone dropdown.
This script will help you to automate DST changes easily and and have peace of mind about not having to manually change every year.
PABX is for an Australian company which has offices in multiple states. Main office is in NSW which observes daylight saving whereas a branch office is in QLD which does not observe daylight saving. Server time is set for NSW timezone.
Create 2 time groups for QLD office, one for normal and one for when DST is observed by NSW.
Upload checkDST script to /var/lib/asterisk/bin/, change ownership to asterisk and set 0755 permissions.
Modify the values for Asterisk DB (DB name, username and password) accordingly.
Set the time group settings as required (time=x)
Set the Time Condition ID (timeconditions_id=x)
Modify the patterns to match (ex: PDT/PST). In this case AEDT for DST and AEST for standard.
Set below crontab code so that this script will be executed on the first Sunday of the month where daylight saving will change. In our example this will be April and October.
0 3 * apr,oct sun [ $(date +\%d) -le 07 ] && /var/lib/asterisk/bin/checkDST.sh>/dev/null 2>&1
Sit back and enjoy the show.
So how does this script work? It’s quite simple actually. This script gets today’s date and yesterdays date from the system and compares the date strings if they contain the timezone pattern in a certain order.
The script first checks if we’ve moved into DST from standard i.e. yesterday should be AEST and today is AEDT. If so, switch the time groups and apply the settings.
If above is not matching, then it will check the reveres, set the time group and apply the settings.