I try to find a way to make Asterisk configure from a given
configuration folder. Thus I will have to simply switch between
configuration folders.
Default is /etc/asterisk. So I will copy it in /etc/asterisk_test1
then I will make some modifications and I will want to select it on the
next start of Asterisk.
I tried asterisk -C /etc/asterisk_test1/asterisk.conf configured with
the directive astetcdir => /etc/asterisk_test, but this does not
working.
You are right the [directories] context was a template, but after removing it and restarting the system the problem is not solved.
I precise this is a fresh Asterisk v22 on Debian 12 install (in virtual environment Qemu/KVM) to learn.
To obtain the test config folder I had copied with cp -a /etc/asterisk /etc/asterisk_test1, to have the same rights.
Here is the reduced effective configuration (the full file is attached to this post (6.3 KB)) :
grep -ivE "^([[:space:]]*;|$)" /etc/asterisk_test1/asterisk.conf
#> [directories]
#> astcachedir => /var/cache/asterisk
#> astetcdir => /etc/asterisk_test1
#> astmoddir => /usr/lib/asterisk/modules
#> astvarlibdir => /var/lib/asterisk
#> astdbdir => /var/lib/asterisk
#> astkeydir => /var/lib/asterisk
#> astdatadir => /var/lib/asterisk
#> astagidir => /var/lib/asterisk/agi-bin
#> astspooldir => /var/spool/asterisk
#> astrundir => /var/run/asterisk
#> astlogdir => /var/log/asterisk
#> astsbindir => /usr/sbin
#> [options]
#> runuser = asterisk ; The user to run as.
#> rungroup = asterisk ; The group to run as.
#> documentation_language = en_US ; Set the language you want documentation
Too there is no references to the default folder from the copied folder :
grep -r /etc/asterisk /etc/asterisk_test1/
#> /etc/asterisk_test1/asterisk.conf:astetcdir => /etc/asterisk_test1
#> /etc/asterisk_test1/asterisk.conf: ; configuration files (/etc/asterisk) with a
#> /etc/asterisk_test1/cli_aliases.conf:;#include "/etc/asterisk/aliases"
#> /etc/asterisk_test1/resolver_unbound.conf:;ta_file = /etc/asterisk/dnssec_keys ; Full path to a trusted anchors key file. These keys are
Too I observed if I set a nonexistent user/group (here foo/bar) when I execute the console the good configuration file is parsed as it is indicated the bar group not exists :
asterisk -C /etc/asterisk_test1/asterisk.conf -d
#> Seeding global EID '52:54:00:26:83:4e' from 'lan' using 'siocgifhwaddr'
#> Parsing /etc/asterisk_test1/asterisk.conf
#> No such group 'bar'!
I restored the asterisk group and I started an interactive console to notice the next step parsed the logger.conf which seems working but the core seems to not seeing the new configuration :
asterisk -C /etc/asterisk_test1/asterisk.conf -rd
#> Seeding global EID '52:54:00:26:83:4e' from 'lan' using 'siocgifhwaddr'
#> Parsing /etc/asterisk_test1/asterisk.conf
#> ...
#> Running as user 'foo'
#> Running under group 'asterisk'
#> Connected to Asterisk 22.1.1 currently running on asterisk-22 (pid = 672)
#> Parsing /etc/asterisk_test1/logger.conf
#> Core debug was OFF and is now 1.
# asterisk-22*CLI> core show settings
#> ...
#> Configuration file: /etc/asterisk/asterisk.conf
#> ...
systemctl is-enabled asterisk
#> asterisk.service is not a native service, redirecting to systemd-sysv-install.
#> Executing: /lib/systemd/systemd-sysv-install is-enabled asterisk
#> enabled
Finally the asterisk -C seems useless or broken ā¦ and to be honest I do not understand in what providing an alternate configuration file (asterisk.conf) can modify the configuration of the running instance without explicitly restart it.
It doesnāt modify the running daemon instance if using it as a console, it configures the Asterisk instance running for remote console so it knows where to look for certain things - specifically the Unix socket to connect to the specific running instance.
Not as clear as the capacity of my poor brain allows ā¦
You say the role of the master configuration (-C) is not to give an alternate one, but only provide a few settings for a remote Asterisk instance ? That is right ?
Then my way to switch between configurations is it the good way to perform this ?
When Asterisk is started as a daemon providing -C will cause it to use that configuration for the running process.
When Asterisk is started as a remote console -C will cause that remote console to use the configuration for itself, to contact the appropriate Asterisk daemon.
I deduced from above all is good, then why this impossibility to access ?
Then we can see the first parsed file is the expected /etc/asterisk_test1/asterisk.conf but apparently it is overwritten by /etc/asterisk/asterisk.conf
Furthermore it is strange that the core sees the good configuration file (/etc/asterisk_test1/asterisk.conf) but not the good configuration directory (/etc/asterisk).
Is my one-shot way to start Asterisk with providing the configuration file is the good one ?