OpenSIPS / opensips-cli

OpenSIPS CLI tool - an interactive command line tool that can be used to control and monitor OpenSIPS servers.
GNU General Public License v3.0
85 stars 48 forks source link

running with -f, it keeps complaining of missing section headers despite the file was generated by "make menuconfig" #47

Closed anexiole closed 4 years ago

anexiole commented 4 years ago

To replicate:

  1. install opensips 3.0
  2. run "make menuconfig"
  3. Generate any conf file. In my case, a residential file.
  4. Install opensips-cli . Run "opensips -f "
  5. Error is thrown as below:

✘ ⚡ root@localhost  /opt/opensips  ➦ 6a49622 ● opensips-cli -f etc/opensips_residential_2020-3-4_13:11:2.cfg Traceback (most recent call last): File "/usr/local/bin/opensips-cli", line 4, in import('pkg_resources').run_script('opensipscli==0.1.0', 'opensips-cli') File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 654, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python3.6/site-packages/pkg_resources/init.py", line 1434, in run_script exec(code, namespace, namespace) File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 9, in run_console() File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console main.main() File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/main.py", line 77, in main shell = cli.OpenSIPSCLIShell(args) File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/cli.py", line 69, in init cfg.parse(cfg_file) File "/usr/local/lib/python3.6/site-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/config.py", line 41, in parse self.config.read(in_file) File "/usr/lib64/python3.6/configparser.py", line 697, in read self._read(fp, filename) File "/usr/lib64/python3.6/configparser.py", line 1080, in _read raise MissingSectionHeaderError(fpname, lineno, line) configparser.MissingSectionHeaderError: File contains no section headers. file: 'etc/opensips_residential_2020-3-4_13:11:2.cfg', line: 18 'log_level=3\n' ✘ ⚡ root@localhost  /opt/opensips  ➦ 6a49622 ● 

I read another post online and i tried to feed it a [default] tag on the top line to no success.

opensips_residential_2020-3-4_13%3A11%3A2.cfg.txt

anexiole commented 4 years ago

https://docs.python.org/3.2/library/configparser.html says

"A configuration file consists of sections, each led by a [section] header, followed by key/value entries"

I suppose the opensips team need to get on this? I will close this call. I noticed that it's normal for the opensips.cfg to have duplicates (ie. aliases). Sadly, that doesn't work well with configparser as the DuplicateOptionError will be thrown.

See https://github.com/OpenSIPS/opensips/issues/1989