UConf,一个用于管理配置文件的智能工具
项目描述
UConf是一个小巧的工具,旨在为异构计算机集提供简单的配置文件处理。
其核心概念包括
将特定于主机的配置抽象到通用特性(服务器、中继等)
特定于主机的配置可能从单行更改到整个文件重写
配置文件在原地修改,而不是在源版本控制库中。
换句话说,它提供了以下功能
将每个主机映射到一组类别(例如笔记本电脑、服务器、开发、远程等)
对于每个类别(或其组合),列出要安装的文件及其目标位置
对于每个文件,根据活动类别有条件地包含一些部分
用法
配置
首先,创建文件夹结构
$ cd ~/conf
$ mkdir .uconf
$ touch .uconf/config
然后,设置一些设置
# .uconf/config
[core]
# Install files to my home folder
target = ~/
[categories]
# The host names "myhostname" belongs to the 'shell' and 'x11' categories
myhostname: shell x11
[files]
# Hosts in the 'shell' category should install
# the 'shell/gitconfig' and 'ssh/config' files
shell: shell/gitconfig ssh/config
# Hosts in the 'shell' but not the 'work' category should install
# our authorized_keys
shell && !work: ssh/authorized_keys
[actions]
# Files located in ~/conf/ssh are parsed and written to ~/.ssh/
ssh/* = parse destdir=".ssh/"
# shell/gitconfig goes to ~/.gitconfig
shell/gitconfig = parse destdir="~/.gitconfig"
文件
uconf的核心是其文件处理引擎。
从表面上看,它是一个简单的预处理器,将基于.uconf/config文件中定义的类别解析文件。
换句话说,如果文件shell/gitconfig包含
[user]
#@if work
name = Raphaël Barrois
email = raphael.barrois@example.org
#@else
name = Xelnor
email = raphael.barrois@polytechnique.org
#@endif
并且基于上面的示例中的myhostname构建,则输出将是
# ~/.gitconfig
[user]
name = Xelnor
email = raphael.barrois@polytechnique.org
命令
一旦您的配置文件夹设置完毕,基本命令将包括
$ cd ~/conf
$ uconf make
Building file shell/gitconfig (FileProcessingAction)
Building file ssh/config (FileProcessingAction)
Building file ssh/authorized_keys (FileProcessingAction)
如果您已修改文件,只需回滚其更改即可
$ cd ~/conf
$ uconf back shell/gitconfig
Backporting file shell/gitconfig (FileProcessingAction)
这将更新源文件(例如,在本例中为 ~/conf/shell/gitconfig)以合并目标文件(在此处为 ~/.gitconfig)中的更改。
即使文件包含分支,这也适用,即如果源文件是
[user]
#@if work
name = Raphaël Barrois
email = raphael.barrois@example.org
#@else
name = Xelnor
email = raphael.barrois@polytechnique.org
#@endif
并且目标文件(在非工作机上)被修改为读取
[user]
name = Raphaël "Xelnor" Barrois
email = raphael.barrois@polytechnique.org
然后运行 uconf back shell/gitconfig 的结果将是
[user]
#@if work
name = Raphaël Barrois
email = raphael.barrois@example.org
#@else
name = Raphaël "Xelnor" Barrois
email = raphael.barrois@polytechnique.org
#@endif
项目详情
下载文件
下载您平台上的文件。如果您不确定选择哪一个,请了解更多关于 安装包 的信息。
源分发
uconf-0.4.1.tar.gz (23.7 kB 查看哈希值)
构建分发
uconf-0.4.1-py3-none-any.whl (24.8 kB 查看哈希值)
关闭
uconf-0.4.1.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | c4d7da64932e4c19e4e935f2f3ec66860971dae71e0deb47959b3c1206825fc4 |
|
MD5 | f83b74c8739b254a8e9f54c7c8e40721 |
|
BLAKE2b-256 | 27ad211e3cca1c439376e4f3bc7bf7e3d90f477980b81962f55c90927de414fd |
关闭
uconf-0.4.1-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 45fd6d8df1dcb80e296e3d7782514332e5d45008331eb1f3c48dee6a8c4eab28 |
|
MD5 | 10c32aa1eb6d6899d010c460d7b33de6 |
|
BLAKE2b-256 | b755bc48eecdd13262a4af56414ed048333c84f605644e6814e63d7d4267a64b |