Skip to main content

Generate config files from 'conf.d' like directories

Project description

update-conf.py

Test Status Coverage Status PyPI - Downloads PyPI - Version License

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.

Install

This project works in Python 3 (3.7 or newer).

To install:

pip install update-conf.py

It'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 install

Usage

To generate a config file, you can run something like this:

update-conf.py -f /etc/snmp/snmpd.conf

The 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.d

It'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.d

Now, you can run:

update-conf.py -n snmpd

To get help:

update-conf.py --help

Config files

update-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.conf

It's also possible to pass a custom config file via command line args:

update-conf.py -c my_custom_config.conf -n snmpd

More examples

Suppose 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/24

After 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/24

There 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 = ;

License

This software is released under the Revised BSD License.

Changelog

Check the CHANGELOG page.

Contributing

If you want to contribute with this project, check the CONTRIBUTING page.

TODO

  • Publish this software in a Ubuntu PPA.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

update-conf.py-1.1.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

update_conf.py-1.1.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file update-conf.py-1.1.0.tar.gz.

File metadata

  • Download URL: update-conf.py-1.1.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for update-conf.py-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7ca13c707dd1293f80f9335165a5db85ceb995a84ed96bd7b4b2a46ac06ef6f6
MD5 f5badb0602e4b53fecb9a2fc92897a21
BLAKE2b-256 d1957f563011ef17049e10dc81a0adf98fe7e0012c796504c67e24d9eb80c93c

See more details on using hashes here.

File details

Details for the file update_conf.py-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: update_conf.py-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for update_conf.py-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f751b8fd97e3839a8762b0b0e46522bdcbbc8adff347ad8e64183d737c04b926
MD5 29700ce47853c3689034c1eb277d26f5
BLAKE2b-256 902f0eff2c832cf669d04e0a2b3e7b93a695757d8a130401e06efd739a9e3539

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page