forked from Atha/update-conf.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
236 lines (156 loc) · 7.63 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
update-conf.d script for flexible /etc/<conf>.d configuration
=============================================================
Origin
------
In January 2008 I wrote a very simple script to manage fstab entries in the way
like environment variables in /etc/env.d are managed. For this I created
separated fstab files in /etc/fstab.d and wrote a script called update-fstab.
I then released it in 2010 on the Gentoo Forum in the hope that it would be
useful to anyone. http://forums.gentoo.org/viewtopic.php?p=6364143
Since then a few people have made enhancements, and the script is now even able
to handle any <conf>.d directory in the same way. It is now called
update-conf.d.
In October 2011 I created a GIT repository, so you can download it easily using
git clone git://github.com/Atha/update-conf.d.git
or visit https://github.com/Atha/update-conf.d to view the script there.
If you want to contribute: every improvement, fix, patch is welcome!
2012-01-05, Atha
Debian libmount
---------------
W A R N I N G
"update-conf.d fstab" is incompatible with Debian bug #663623 which adds
/etc/fstab.d support in libmount, part of util-linux. Adding support to the
mount command was discussed by certain developers on the LKML but not yet
implemented.
Nevertheless on a Debian 6 and 7 system /etc/fstab.d already exists and is
probably used by libmount.
Hence, be very very careful when you use update-conf.d with /etc/fstab on a
Debian 6/7 based distribution!
* http://comments.gmane.org/gmane.linux.utilities.util-linux-ng/5077
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=663623
* https://lkml.org/lkml/2012/1/20/104
In Debian 8 (2015) this libmount behaviour was removed.
Installation
------------
There are two versions: simple and complex.
First, clean previously built versions:
make clean
Then, to build the complex version:
make complex
make install
The simple version may be preferred when size and speed is a concern. It
has less options, but is much simpler, allowing easier modification to the
script itself, should it be needed.
To build the simple version:
make simple
make install
It basically does the same as the complex version, so the usage should be
almost exactly the same.
You will then have to manage /etc/update-conf.d.conf right after the
installation, or update-conf.d will have no function.
To uninstall, run make again.
make uninstall
This will remove /usr/local/sbin/update-conf.d.
You can set the PREFIX variable in the Makefile if you want to install it into
anything other than /.
Usage
-----
Please read the man page for options included in the complex version.
The following will work also for the simple version:
<conf> is any configuration file you like to make .d'ed, i.e. split into
snippets. When reading this, simply substitute <conf> by the name of the
configuration file you want to process. Examples: fstab, hosts
Copy existing configuration:
Copy it to a (newly created) .d'ed directory:
cd /etc
mkdir <conf>.d
cp <conf> <conf>.d/00original
Example: If your <conf> is fstab, you will now have /etc/fstab.d/00original
Add *.d*'ed directory to /etc/update-conf.d.conf:
echo <conf> >> /etc/update-conf.d.conf
You may use your favorite text editor to add/delete entries and manage
/etc/update-conf.d.conf.
Test:
This will take all files in /etc/<conf>.d/ that start with two digits
(^[0-9][0-9]), leave out empty lines and comments (^[#]) and make a new
/etc/<conf> with this information.
update-conf.d <conf>
Example:
update-conf.d fstab
Configure snippets:
Now take your existing 00original apart and split it up into snippets that
suit your needs. If you need examples for snippets and filenames, look at
your /etc/env.d directory. The original configuration file 00original can
then be deleted or renamed, like A0original or .00original or even
<conf>-backup, so it won't be included by the update-conf.d script. Now
re-run update-conf.d <conf> to update /etc/<conf>.
Concept
-------
1. Why would you want to split a configuration file into snippets?
* For one, you may like a modular configuration basis. You can have
individually columned configuration files that would normally only make
your single (original) configuration file harder to read.
Take fstab for example. Lines for proc, sysfs, tmpfs, swap will have
different column sizes than UUID based partitions or partitions assigned
by path in /dev/disk/by-path/, which require different columns than
partitions assigned like /dev/sda1. Now you can have seperate files for
that, each with an individual # comment line for the columns, making each
file very easy to read and edit.
* You can use different sources for each snippet. For example, you could
share a snippet over the network, to have multiple installations updated
at the same time. All you have to do is make sure the update-conf.d script
is run after syncronizing it, and you're done.
2. What other positive effects can I expect?
* Your /etc/<conf> is now reproducable by running the update-conf.d script.
Accidentally deleting it or altering its contents doesn't destroy your
whole configuration.
* You can experiment with <conf> by changing it, which will only be
temporary until you re-run update-conf.d.
* You can easily disable a snippet by renaming it to not start with two
digets. The script will then ignore it and thus it will not be included in
/etc/<conf> when you run update-conf.d.
* Applications or self written scripts cannot harm your <conf> file by
destroying it (accidentally).
3. Are there any negative effects?
* Yes.
* If you rely on applications to update your /etc/<conf>, you must manually
add this update to your /etc/<conf>.d/00something snippet. Otherwise it
will be lost the next time you run update-conf.d. Some Linux distributions
update /etc/fstab and /etc/hosts (and possibly others) when the system
configuration is changed.
* On some systems, other utilities may already use a .d'ed directory in
/etc, which makes it impossible to use update-conf.d without a PREFIX. One
example is Debian's libmount (since around 2011, until 2015) which uses
/etc/fstab.d.
As a sane precaution you should not create a .d-ed directory for this
script when there already is one!
Versioning
----------
No version numbers are used, instead the date in the ISO format (2008-01-20) is
used as the version identification.
There are two versions: a simple and a complex version.
The original script update-fstab is depricated and only included for
completeness and historical nostalgia. Don't use it.
Adaptation
----------
If you require such a script for a very specific task, you may want to modify
it to what is needed for this very task. For that you may find the simple
version of the update-conf.d script or even the depricated update-fstab script
more convenient, since both are certainly simpler and easier to adapt than the
complex version.
If you do consider modification to the complex version, be advised that the
main function is update_confd ().
Contribution
------------
Please, feel free to point out any error. Improvements, fixes and patched are
highly appreciated!
Copyright and license
---------------------
Copyright (c) 2015 Mic92 (fixes)
Copyright (c) 2013 javeree
Copyright (c) 2011 Nicolas Bercher
Copyright (c) 2010 truc (on improvements)
Copyright (c) 2008-2015 Atha
This script is released under the terms of the GNU GENERAL PUBLIC LICENSE
Version 2 or (at your option) any later version.
It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.