* remove duplicate chained function calls (lb_rtp_interfaces_sync
rtp_interfaces_sync), etc.
* structurise the code by having vars init section first then
function calls and then code execution.
* add main() function as the general entry point and move
all the logic function calls into main() for isolated readability.
* call main() after function definitions and exit with a valid return
code.
* improve main() code readability.
* generic_enum_sync(): improve SQL readability.
* improve SQL error handling.
* all "die" calls are now suffixed with "\n".
Change-Id: I6abce886acedb325892031add1c406be6da5f065
* new function sync_rtp_interface() that, when multi site is enabled,
adds the site name as a prefix for the generated rtp intefaces names
(not their values), enabling the 'rtp_interface' preferences list
to contain rtp_interfaces from all sites.
Change-Id: I8b4e85541747dc46c76135ab05d4424ea79dcf39
* kamailio.lb.extra_socket definitions are now prefixed
with the site name when multi site is enabled
Change-Id: Ia156f2b80c80daee28abafffe2b82522ca499156
* merge duplicate multi site info data preparation into
a dedicated function get_multi_site_data()
* use the function in the related functions instead of the
duplicated code there.
Change-Id: I2eb1a888553ebd00ee69b8ed031078bfde794d3f
* scripts/commit: add $SITES_CONFIG to sync-db command line args
so that the file is loaded (but only if it exists).
* new function get_current_site() that returns a hash containing
current site name,id,role as keys
* "site_name:" preference name prefix is automatically added when
lb_and_extra_sockets_sync() is running with enabled multi site
* preference names with prefixes from non-current sites are ignored
and not removed (so that multiple different sites populate own
preferences, while removing old non multi site ones).
* always show the IP addres in the built 'outbound_socket' preference
name, regardless of the shared ips amount, for consistency and
easier visual recognition when working with the values list
(especially with the multi site enabled).
Change-Id: Ibb1bf13e919f29c9a97f9f0ca3c9b2a6b8121a59
* Central db connection must not be used when syncing db data
in the sync-db helper as it causes possible unexpected data
behaviours when for instance changes in outbound_socket on web01
immediately applied to the central db node when running
ngcpcfg apply on web01.
Therefore, central db connection is switched to the pair
(localhost:3306) one.
Change-Id: Ie6b17d1bf074deca9cf8a7ac626211af6a43d0e1
* 1 is returned in do_sync_db_timezones() when no errors
occured, including version match, to let dependent functions
be called properly in the chain.
* move mysql_tzinfo_to_sql capture after version comparsion
so that the data is not gathered needlessly.
Change-Id: I88ab0ef67ee40da064b9884c65b27d542550dd8f
* disable perlcritic for the comma separated line, mainly for
bookworm as in trixie it's no longer triggered
Change-Id: I3a0af2ad6fedec8bff5d61128a1a4fcf4560ae83
* instead of only central db connection, there are 3
db connections now, pair, central and local. all
fetched from constants.yml database.{central|pair|local}.
* read /etc/default/ngcp-roles to fetch NGCP_TYPE and NGCP_IS_PROXY
* adjust existing functions the following way to work with the db:
- sync_lb_and_extra_sockets
sync_rtp_interfaces
sync_smsc_peers -- all using generic_enum_sync(), use the central
db connection.
- sync_general_timezone
sync_db_timezones
sync_timezone_version -- use pair+local on carrier+proxy, otherwise
pair only. This is to address the issue where on carrier, nodes there
could not sync db timezones locally because they always read the
version info from the central db.
* add log line when syncing db timezones.
Change-Id: I236fb55871ed2a80d8ff62efedc6140218c14c6f
* only 'sip_ext' interfaces are included into the automatic
lb outbound_socket selection as 'sip_int' does not provide
with the external traffic.
Change-Id: Id35fcfdb69ff9ffc2caefd2fb588d0bb4f61f31e
* $extra_sockets_config can be undef, a check for undef
and that the value is a HASH ref is added to prevent
unexpected behaviour
Change-Id: I6914a8d4eddc7f35ba69fe92c7acc130c0475aca
* sync_extra_sockets() renamed into sync_lb_and_extra_sockets()
* extra_sockets_sync() renamed into lb_and_extra_sockets_sync()
* $config now also contains merged $NETWORK_CONFIG (network.yml)
* lb_and_extra_sockets_sync does the following and then calls
generic_enum_sync() to provide with the gathered data:
* all shared ips from interfaces that
- host have 'lb' role
- host status 'online'
- interface has type '^sip_'
are added into the outbound sockets list of protos (udp, tcp, tls)
as: 'host:interface:proto' = 'proto:shared_ip:port'
(port is taken from config.kamailio.lb.port in case of ('udp', 'tcp')
and config.kamailio.tls.port in case of 'tls'
)
- if an interface has multiple shared IPs,
the key becomes 'host:interface:shared_ip:proto'
- $config->{kamailio}{lb}{extra_sockets} keys are merged
with the gathered config
* generic_enum_sync() - processes hash keys are now sorted
to have consistent output/processing
Change-Id: I218f1ae584e2dc9dfeb3a51c43d9f3fc950e829b
* sync_timezone_version() checks the current olson database
version from DateTime::TimeZone vs ngcp.timezone.version
and updates billing.contacts.timezone field with the new
names following the "links" (aliases)
Change-Id: Iacb552a9151ffb8eaaa40a16b530cbde0cc4b718
This reverts commit 2fa57561b0.
Reason for revert: Feature was partially backported and lawful intercept admins were deleted from databse. Feature needs redesign.
Change-Id: Ie83bb5888474bd0f7e8af15b518be8723c01592c
* Completely manage LI admins by editing
www_admin->lawful_intercept_admins in config.yml
* Executing ngcpcfg apply will now add new admins
found in config.yml, update their email if it is
changed in config.yml, and delete them from DB
if they're not found in config.yml
Change-Id: Iae5874fe77443469354e4446b83a68b178e4730c
* add support for MariaDB timezones sync sql
delimiter as now in the generated sql stream output
there are sections with '\d' changing the delimiter behaviour.
Change-Id: If226db7018f431ff4248dcf6ff5a614ff96a45c7
The DBI connect call can be specified the PrintError option, which will
make the function print the contents of the $DBI:errstr, but then we do
that again, which results in redudant output, so we disable this option.
The $DBI::errstr variable contains an error string that is *not*
terminated with a newline. The perl die built-in has magic behavior
when the string it gets does not end in a newline character, it will
then emit the source line, file name and a newline where the error
happened, which is in most cases not what we want. We just avoid
this by adding an explicit newline.
Replace a print + exit with a die, and a printf without a terminating
newline which would mess up further output with a warn call with an
explicit newline, which will also make it go to stderr.
And remove the local PrintError overrides which are now unnecessary.
Change-Id: I348b8cc676da7f255c6c823de2a774694dbca826
There is no need to read the text file and search for password inside,
we have properly formatted credentials file /etc/mysql/sipwise_extra.cnf
which is fully supported by MySQL/MariaDB client library and Perl DBI.
Also we have plans to remove /etc/mysql/sipwise.cnf to prevent it usage
(to prevent password leakage through Linux process list).
Change-Id: I62006ae01d9097642a3dae063781a621f5050842
The dpkg-query command already has an interface to fetch the field
value, so there is no need to use --status, grep and then parse the
output.
Change-Id: I13a2f601bde4ca01bfbd7db35f8a1ff11175fba3
* ngcp.timezone table is not updated if
new timezone=old timezone
* ngcp.timezone change is not replicated to
preserve stability of the other (active) node
and to address the replication issue during upgrade
Change-Id: Id8f7b291c188792a33093ac3ed706b55d1b0a654
* sync_smsc_peers() is used to sync the 'smsc_peer' domain
preference
* generic_enum_sync() is extended and accepts boolean args
$usr_pref, $dom_pref, $peer_pref
Change-Id: I376a2ba823bef53b3548b88c38960c893a74efc8
* sync_db_timezones use 'mysql_tzinfo_to_sql'
to load timezone info from /usr/share/zoneinfo into
MariaDB.
* tzdata package version is checked and the timezone data
sync is skipped if the version in ngcp.tzinfo_version
is already up to date.
Change-Id: I92c87fb52fea20df0366c93c2e3568c25833b9bb
* general.timezone value from config.yml
is now populated into ngcp.timezone DB table.column
* it produces an error if general.timezone field is undefined
Change-Id: I975f786a7f8ff42916d92e13f6fe9971d5b1e2f0
The latter does not support YAML 1.1, nor many parts of the
specification. Use the more compliant implementation, in addition to try
to converge to a single one, so that we do not get serialization delta
surprises.
Change-Id: Ie51f1c79859d40ef0877fc0ab75f86ee72e14ea4
This module is more compliant and it is faster than the pure perl
implementation. The latter is also deprecated in favor of the former
(see man YAML for more details).
Change-Id: I3fccca4ab57ad7c316b6cf58a81bc4baa1bdabe1
* fax gateways are no longer needed in kamailio.dispatcher
as asterisk is the only destination for fax2mail now
* error messages are prefixed with Error:
Change-Id: I865fda3ed0aab967c62cea519f3ad42716ed5878