Merge pull request #17061 from geekpi/translating

translated
This commit is contained in:
geekpi 2020-01-16 08:59:21 +08:00 committed by GitHub
commit 6b04375c30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 60 deletions

View File

@ -1,60 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Use Stow for configuration management of multiple machines)
[#]: via: (https://opensource.com/article/20/1/configuration-management-stow)
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney)
Use Stow for configuration management of multiple machines
======
Learn how to use Stow to manage configurations across machines in the
second article in our series on 20 ways to be more productive with open
source in 2020.
![A person programming][1]
Last year, I brought you 19 days of new (to you) productivity tools for 2019. This year, I'm taking a different approach: building an environment that will allow you to be more productive in the new year, using tools you may or may not already be using.
### Manage symlinks with Stow
Yesterday, I explained how I keep my files in sync across multiple machines with [Syncthing][2]. But that's only one of the tools I use to keep my configurations consistent. The other is a seemingly simple tool called [Stow][3].
![Stow help screen][4]
Stow manages symlinks. By default, it makes symlinks from the directory it is in to the directory below it. There are also options to set a source and target directory, but I don't usually use them.
As I mentioned in the Syncthing [article][5], I use Syncthing to keep a directory called **myconfigs** consistent across all of my machines. The **myconfigs** directory has several subdirectories underneath it. Each subdirectory contains the configuration files for one of the applications I use regularly.
![myconfigs directory][6]
On each machine, I change to the **myconfigs** directory and run **stow -S <directory name>** to symlink the files inside the directory to my home directory. For example, under the **vim** directory, I have my **.vimrc** and **.vim** directories. On each machine, I run **stow -S vim** to create the symlinks **~/.vimrc** and **~/.vim**. When I make a change to my Vim configuration on one machine, it applies to ALL of my machines.
Sometimes, though, I need something machine-specific, which is why I have directories like **msmtp-personal** and **msmtp-elastic** (my employer). Since my **msmtp** SMTP client needs to know what email server to relay through, and each one has different setups and credentials, I can use Stow to swap between the two by "unstowing" one with the **-D** flag and then putting the other in place.
![Unstow one, stow the other][7]
Sometimes I find myself adding files to a configuration. For that, there is the "restow" option with **-R**. For example, I like to use a specific font when I use Vim as a graphical application and not a console. The **.gvimrc** file lets me set options that apply only to the graphical version, in addition to the standard **.vimrc** file. When I first set this up, I moved **~/.gvimrc** to **~/myconfigs/vim** and then ran **stow -R vim**, which unlinks and relinks everything in that directory.
Stow lets me switch between several configurations with a simple command line and, in combination with Syncthing, I can be sure that I have the setup I like for the tools I use ready to go, no matter where I am or where I make changes.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/1/configuration-management-stow
作者:[Kevin Sonney][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/ksonney
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming)
[2]: https://syncthing.net/
[3]: https://www.gnu.org/software/stow/
[4]: https://opensource.com/sites/default/files/uploads/productivity_2-1.png (Stow help screen)
[5]: https://opensource.com/article/20/1/20-productivity-tools-syncthing
[6]: https://opensource.com/sites/default/files/uploads/productivity_2-2.png (myconfigs directory)
[7]: https://opensource.com/sites/default/files/uploads/productivity_2-3.png (Unstow one, stow the other)

View File

@ -0,0 +1,58 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Use Stow for configuration management of multiple machines)
[#]: via: (https://opensource.com/article/20/1/configuration-management-stow)
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney)
使用 Stow 管理多台机器配置
======
2020 年,在我们的 20 个使用开源提升生产力的系列文章中,让我们了解如何使用 Stow 跨机器管理配置。
![A person programming][1]
去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。
### 使用 Stow 管理符号链接
昨天,我解释了如何使用 [Syncthing][2] 在多台计算机上保持文件同步。但是,这只是我用来保持配置一致性的工具之一。还有另一个简单的工具 [Stow][3]。
![Stow help screen][4]
Stow 管理符号链接。默认情况下,它会链接目录到上一级目录。还有设置源和目标目录的选项,但我通常不使用它们。
正如我在 Syncthing 的[文章][5] 中提到的,我使用 Syncthing 来保持 **myconfigs** 目录在我所有的计算机上一致。**myconfigs** 目录下面有多个子目录。每个子目录包含我经常使用的应用之一的配置文件。
![myconfigs directory][6]
在每台计算机上,我进入 **myconfigs** 目录,并运行 **stow -S <目录名称>** 以将目录中的文件符号链接到我的家目录。例如,在**vim** 目录下,我有 **.vimrc** 和 **.vim** 目录。在每台机器上,我运行 **stow -S vim** 来创建符号链接 **~/.vimrc** 和 **~/.vim**。当我在一台计算机上更改 Vim 配置时,它会应用到我的所有机器上。
然而,有时候,我需要一些特定于机器的配置,这就是为什么我有如 **msmtp-personal****msmtp-elastic**(我的雇主)这样的目录。由于我的 **msmtp** SMTP 客户端需要知道要中继的电子邮件服务器,并且每个服务器都有不同的设置和凭据,我会使用 **-D** 标志来取消链接,接着链接另外一个。
![Unstow one, stow the other][7]
有时我要给配置添加文件。为此,有一个 **-R** 选项来”重新链接“。例如,我喜欢在图形化 Vim 中使用一种与控制台不同的特定字体。除了标准 **.vimrc** 文件,**.gvimrc** 文件能让我设置特定于图形化版本的选项。当我第一次设置它时,我移动 **~/.gvimrc** 到 **~/myconfigs/vim** 中,然后运行 **stow -R vim**,它取消链接并重新链接该目录中的所有内容。
Stow 让我使用一个简单的命令行在多种配置之间切换,并且,结合 Syncthing我可以确保无论我身在何处或在哪里进行更改我都有我喜欢的工具的设置。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/1/configuration-management-stow
作者:[Kevin Sonney][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/ksonney
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming)
[2]: https://syncthing.net/
[3]: https://www.gnu.org/software/stow/
[4]: https://opensource.com/sites/default/files/uploads/productivity_2-1.png (Stow help screen)
[5]: https://opensource.com/article/20/1/20-productivity-tools-syncthing
[6]: https://opensource.com/sites/default/files/uploads/productivity_2-2.png (myconfigs directory)
[7]: https://opensource.com/sites/default/files/uploads/productivity_2-3.png (Unstow one, stow the other)