Update var in ini file using bash

前端 未结 4 1445
我寻月下人不归
我寻月下人不归 2021-01-02 02:55

I am attempting to write a bash script to configure various aspects of a server. The context here is replacing a value of a variable in a conf file (ini format) with another

4条回答
  •  我在风中等你
    2021-01-02 03:18

    If you are open to use external applications, you could be interested into the use of crudini.

    Example:

    [oauth2provider]
    module = SippoServiceOAuth2Provider
    backend[] = none
    wiface = public
    
    ; [calldirection]
    ; module = SippoServiceCallDirection
    ; backend[] = none
    ; wiface = internal
    

    A standard grep will not filter commented exceptions.

    With crudini things for consulting, setting and modify are easier:

    $ crudini --get /myproject/config/main.ini oauth2provider wiface
    public
    $ crudini --get /myproject/config/main.ini calldirection wiface
    Section not found: calldirection
    

    I was on a bash-only app and moved to this approach. Just a suggestion.

    Regards,

提交回复
热议问题