Generate config files from conf.d like directories.
Split your config file into smaller files, called snippets, in a conf.d like directory. The generated config file will be the concatenation of all snippets, with snippets ordered by the lexical order of their names.
Files ending with .bak, .old and other similar terminations will be ignored.
This project was based on the update-conf.d project.
This project works in Python 3 (3.7 or newer).
To install:
pip install update-conf.pyIt's possible to clone the project in Github and install it via setuptools:
git clone git@github.com:rarylson/update-conf.py.git
cd update-conf.py
python setup.py installTo generate a config file, you can run something like this:
update-conf.py -f /etc/snmp/snmpd.confThe example above will merge the snippets in the directory /etc/snmp/snmpd.conf.d into the file /etc/snmp/snmpd.conf.
If the directory containing the snippets uses a diferent name pattern, you can pass its name as an argument:
update-conf.py -f /etc/snmp/snmpd.conf -d /etc/snmp/snmpd.dIt's also possible to define frequently used options in a config file. For example, in /etc/update-conf.py.conf:
[snmpd]
file = /etc/snmp/snmpd.conf
dir = /etc/snmp/snmpd.dNow, you can run:
update-conf.py -n snmpdTo get help:
update-conf.py --helpupdate-conf.py will use the global config file (/etc/update-conf.py.conf) or the user-home config file (~/.update-conf.py.conf) if they exist.
You can use the the sample config file (provided within the distributed package) as a start point:
cp ${prefix}/share/update-conf.py/update-conf.py.conf /etc/update-conf.py.confIt's also possible to pass a custom config file via command line args:
update-conf.py -c my_custom_config.conf -n snmpdSuppose you have 2 snippets. One is /etc/snmp/snmpd.conf.d/00-main:
syslocation Unknown
syscontact Root <root@localhost>And the other is /etc/snmp/snmpd.conf.d/01-permissions:
rocommunity public 192.168.0.0/24After running update-conf.py -f /etc/snmp/snmpd.conf, the generated config file will be:
# Auto-generated by update-conf.py
# Do NOT edit this file by hand. Your changes will be overwritten.
syslocation Unknown
syscontact Root <root@localhost>
rocommunity public 192.168.0.0/24There are cases when it's useful to change the prefix used in the auto-generated comment. After running update-conf.py -f /etc/php.ini -p ';', the generated config will start with:
; Auto-generated by update-conf.py
; Do NOT edit this file by hand. Your changes will be overwritten.It's also possible to set the prefix used in the auto-generated comment via config file. For instance, in /etc/update-conf.py.conf:
[php]
file = /etc/php.ini
dir = /etc/php.d
prefix_comment = ;This software is released under the Revised BSD License.
Check the CHANGELOG page.
If you want to contribute with this project, check the CONTRIBUTING page.
- Publish this software in a Ubuntu PPA.