I'd like to suggest a small patch for /usr/local/etc/rc.d/asterisk.sh, actually for the sync_package_asterisk function in /usr/local/pkg/asterisk.inc.
In line 396 in asterisk.inc add
if [ ! -e /var/db/asterisk/astdb ] && [ -e /cf/conf/asterisk/astdb.backup ]; then
cp /cf/conf/asterisk/astdb.backup /var/db/asterisk/astdb
chown asterisk:asterisk /var/db/asterisk/astdb
chmod 0775 /var/db/asterisk/astdb
Then add after line 408:
$stop .= "\n\tif [ -e /var/db/asterisk/astdb ]; then\n\t";
$stop .= "\tcp -f /var/db/asterisk/astdb /cf/conf/asterisk/astdb.backup\n\tfi;"
The associated patch would be:
> if [ ! -e /var/db/asterisk/astdb ] && [ -e /cf/conf/asterisk/astdb.backup ]; then
> cp /cf/conf/asterisk/astdb.backup /var/db/asterisk/astdb
> chown asterisk:asterisk /var/db/asterisk/astdb
> chmod 0775 /var/db/asterisk/astdb
> $stop .= "\n\tif [ -e /var/db/asterisk/astdb ]; then\n\t";
> $stop .= "\tcp -f /var/db/asterisk/astdb /cf/conf/asterisk/astdb.backup\n\tfi;"
The additions save and restore the astdb file when Asterisk gets stopped or restarted. For convenience, I selected the /cf/conf/asterisk directory, such that it gets saved with the configuration backup command.
The background of this patch is to make Asterisk work properly when RAM disks are used (Advanced->Miscellaneous). Asterisk itself always tries to use astdb, regardless of whether app_db, or func_db are loaded, and tries to keep track of current registrations across program invocations. Otherwise, phones have to register again before they can be used. Typical registry expiry times are 1h, so this could be a problem in larger installations. At home one would simply restart the phones, I guess.