kaysond / spki

A bash script wrapper for OpenSSL that generates and manages a simple PKI suitable for small deployments
GNU General Public License v3.0
45 stars 8 forks source link

Allow external configuration file #6

Closed michaelkrieger closed 5 years ago

michaelkrieger commented 5 years ago

An external configuration file can be useful:

This patch will obey symbolic links, as well as any changes to the name of the script so either of these methods could be used:

    mkdir companyname
    cd companyname
    ln -s ../spki-master/spki spki
    cat << EOF >> spki.conf
    ROOT_DIR='/path/to/data/folder'
    ROOT_CRL_DP=''
    EOF
    ./spki

or

    ln -s spki-master/spki spki-company
    cat << EOF >> spki-company.conf
    ROOT_DIR='/path/to/data/folder'
    ROOT_CRL_DP=''
    EOF
    ./spki-company

and it will override these config settings for when it's run from a script in that folder. This works whether you run it in the current folder or using a relative or absolute path. If the file doesn't exist, it will use the old behaviour.

kaysond commented 5 years ago

I definitely agree this would be a useful feature. But I think using the name of the script file as the config file prefix could be confusing. The config file should have a consistent name, or even be specified directly.

I can think of a few alternative options:

In either case, it should definitely be documented in the readme, and a note added in the file itself to indicate the variables could be overwritten.

I'm leaning towards the second one as it seems the most versatile and is a common config practice. Thoughts?

kaysond commented 5 years ago

Implemented via e4bcd95