Metadata-Version: 2.1
Name: update-conf.py
Version: 1.1.0
Summary: Generate config files from 'conf.d' like directories
Home-page: https://github.com/rarylson/update-conf.py
Author: Rarylson Freitas
Author-email: rarylson@gmail.com
License: Revised BSD
Keywords: system unix config split merge snippets sysadmin
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved
Classifier: Natural Language :: English
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

update-conf.py
==============

[![Test Status](https://github.com/rarylson/update-conf.py/actions/workflows/tests.yml/badge.svg?branch=master&event=push)](https://github.com/rarylson/update-conf.py/actions/workflows/tests.yml)
[![Coverage Status](https://coveralls.io/repos/github/rarylson/update-conf.py/badge.svg?branch=master)](https://coveralls.io/github/rarylson/update-conf.py?branch=master)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/update-conf.py.svg)](https://pypi.python.org/pypi/update-conf.py/)
[![PyPI - Version](https://img.shields.io/pypi/v/update-conf.py.svg)](https://pypi.python.org/pypi/update-conf.py/)
[![License](https://img.shields.io/pypi/l/update-conf.py.svg)](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](https://github.com/Atha/update-conf.d).

Install
-------

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

To install:

```bash
pip install update-conf.py
```

It's possible to clone the project in Github and install it via `setuptools`:

```bash
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:

```bash
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:

```bash
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`:

```ini
[snmpd]
file = /etc/snmp/snmpd.conf
dir = /etc/snmp/snmpd.d
```

Now, you can run:

```bash
update-conf.py -n snmpd
```

To get help:

```bash
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:

```bash
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:

```bash
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`:

```ini
syslocation Unknown
syscontact Root <root@localhost>
```

And the other is `/etc/snmp/snmpd.conf.d/01-permissions`:

```ini
rocommunity public 192.168.0.0/24
```

After running `update-conf.py -f /etc/snmp/snmpd.conf`, the generated config file will be:

```ini
# 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:

```ini
; 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`:

```ini
[php]
file = /etc/php.ini
dir = /etc/php.d
prefix_comment = ;
```

License
-------

This software is released under the [Revised BSD License](LICENSE).

Changelog
---------

Check the [CHANGELOG](CHANGELOG.md) page.

Contributing
------------

If you want to contribute with this project, check the [CONTRIBUTING](CONTRIBUTING.md) page.

TODO
----

- Publish this software in a Ubuntu PPA.
