Unable to open Asterisk database

opkg update
opkg install asterisk16

root@OpenWrt:~# asterisk -cvvvvv
Asterisk 16.6.1, Copyright (C) 1999 - 2018, Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Unable to open Asterisk database '/var/lib/asterisk/astdb.sqlite3': unable to open database file
ASTdb initialization failed.  ASTERISK EXITING!

root@OpenWrt:~# cat /etc/os-release 
NAME="OpenWrt"
VERSION="SNAPSHOT"
ID="openwrt"
ID_LIKE="lede openwrt"
PRETTY_NAME="OpenWrt SNAPSHOT"
VERSION_ID="snapshot"
HOME_URL="https://openwrt.org/"
BUG_URL="https://bugs.openwrt.org/"
SUPPORT_URL="https://forum.openwrt.org/"
BUILD_ID="r11756-bf43e5bbf9"
OPENWRT_BOARD="sunxi/cortexa7"
OPENWRT_ARCH="arm_cortex-a7_neon-vfpv4"
OPENWRT_TAINTS=""
OPENWRT_DEVICE_MANUFACTURER="OpenWrt"
OPENWRT_DEVICE_MANUFACTURER_URL="https://openwrt.org/"
OPENWRT_DEVICE_PRODUCT="Generic"
OPENWRT_DEVICE_REVISION="v0"
OPENWRT_RELEASE="OpenWrt SNAPSHOT r11756-bf43e5bbf9"

How can I start Asterisk?

I don't have a full answer but I will point out that in OpenWrt, /var is a RAM disk, so it gets erased on reboot. You'll have to store any files that need to be persistent somewhere else.

Thanks @mk24, I could probably store it somewhere else, but where do I even get astdb.sqlite3 from? I think it's a bug if a package doesn't "just work" right out of the box?

It'll be created automatically if it does not exist. Please check permissions of folder /var/lib/asterisk. The user "asterisk" has write permissions in there? Is there enough free space available (df -h)?

Also, did you change varlibdir in /etc/config/asterisk but forgot to configure the same in /etc/asterisk/asterisk.conf?

Thanks @micmac1. I have literally only run the commands I have posted above on an entirely fresh system.

root@OpenWrt:~# ls /var/lib/asterisk
ls: /var/lib/asterisk: No such file or directory

Which package should have installed it?

mkdir -p /var/lib/asterisk

makes it work for me...

The init script. Can you please post the content of /etc/config/asterisk?

Ah, wait, that explains it. You didn't use the init script. And now you created one or more directories manually without chowning them properly.

I suggest to use the init script to start asterisk. You may have to correct some permissions manually, because the init script will only create directories (with the correct permissions) if the directories don't exist. That is to say, it won't fix the permissions on existing folders.

Thanks @micmac1. I will start over from scratch:

firstboot -y && reboot now
okpg update
opkg install asterisk

And then?

root@OpenWrt:~# /etc/init.d/asterisk start
asterisk: service not enabled in /etc/config/asterisk

You have to enable it in /etc/config/asterisk :slight_smile: (option enabled '1')

asterisk16 only installs a small selection of modules:

  • app_dial
  • app_echo
  • app_macro
  • app_playback
  • func_callerid
  • func_logic
  • func_strings
  • func_timeout
  • pbx_config
  • res_crypto

So you probably want to install a few extra modules.

Indeed, after doing

uci set asterisk.general.enabled=1
/etc/init.d/asterisk start

I can now connect to it:

root@OpenWrt:~# asterisk -r
Asterisk 16.6.1, Copyright (C) 1999 - 2018, Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 16.6.1 currently running on OpenWrt (pid = 3287)

I now have Asterisk running as user asterisk. Cool! I wonder why the config file doesn't come enabled out of the box.

1 Like

Mmh, it's a preference I guess, some like it, some don't. But you can script it to enabled easily:

uci set asterisk.general.enabled='1' && uci commit

Thanks, I will put those in a https://oldwiki.archive.openwrt.org/doc/uci#uci-defaults script.

New URL: https://openwrt.org/docs/guide-developer/uci-defaults

The old page is for archival purposes only and does not receive updates any more.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.