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
237
238
239
240
241
242
|
#+OPTIONS: ^:nil num:nil
#+html: <p align="center"><img src="res/logo.png"></p>
* ck
*The Config Keeper*
Have you ever wondered:
#+BEGIN_QUOTE
"Jeez Luiz, how can I manage all my configs across my desktop and server?"
-- You
#+END_QUOTE
or maybe:
#+BEGIN_QUOTE
"How can I possibly keep all my configs in sync across computers?"
-- You again
#+END_QUOTE
*ck* is the solution you've been looking for all your life.
With it you can keep track of all the configs you cherish and love,
and store them neat and tidy in a folder you can later sync using
your favorite sync solution (git, nextcloud, rsync). You can even gift
your precious data to Google and use GDrive (//not recommended!!//).
After you create your local config db you can list them, edit them
and even search in them, all within the comforting hands of *ck*, your
faithful companion.
You can also use *ck* to store sensitive configurations (with passwords, etc)
and instruct it to save them in a different folder, so they won't be in the
same place with the normal ones (in the event you want to share your configs
with the rest of us).
** Technicalities
Upon adding a config to *ck*, it moves it to the specified folder and adds a symbolic link
back where it came from (=ln -s=).
Make sure that the target program can read it's configuration from a symlink (the vast
majority should).
** Download
Go ahead and download *ck* and give it a try. It comes with a help sub-command
that explains any inquires you might have.
Grab the latest zip/tarball from the tag section in the [[https://ubuntos.dynu.net/git/ck][repo]] and proceed to
the [[#build-instructions][build]] section.
You can also read the manpage [[#manpage][down below]].
* build it
:PROPERTIES:
:CUSTOM_ID: build-instructions
:END:
** requirements
- cmake
- sqlite3-dev
- build tools (gcc/llvm, make...)
** make && install
Use =-DCMAKE_INSTALL_PREFIX= when running cmake to change the install path.
#+BEGIN_SRC sh
# clone the repo
> cd ~/code; git clone https://gitlab.com/grm-grm/ck
# make a build directory and enter it
> mkdir ~/ck_build; cd ~/ck_build;
# run cmake
> cmake ~/code/ck
# run make
> make
# install it
> make install
# run ck
> ck
#+END_SRC
* for devs
Please be [[https://www.gnu.org/philosophy/kind-communication.html][kind]] to each other.
** CMake options
cmake accepts the following options:
#+BEGIN_SRC cmake
option(CK_DEBUG "Build with debug symbols, asan and warnings")
option(CK_TESTS "Make the tests")
option(CK_SHARED "Build with shared lib")
#+END_SRC
To use any one of them append it after the cmake command like so:
#+BEGIN_SRC sh
cmake -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck
#+END_SRC
** compiler
Pick your favorite
#+BEGIN_SRC sh
> export CC=clang
# or
> export CC=gcc
#+END_SRC
#+BEGIN_SRC sh
# clone the repo
> cd ~/code; git clone https://gitlab.com/grm-grm/ck
# make a build directory and enter it
> mkdir ~/ck_build; cd ~/ck_build;
# run cmake
> cmake -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck
# run make
> make
# check ck
> ./test-ck
# run ck
> ./ck
#+END_SRC
** tests
The testing "suite" is a bash script that runs regression
and unit tests. Regression tests are under the =tests/= directory
and are bash scripts that test =ck= functionality. Unit tests reside
under =unit/= directory and test the code.
*** run tests
First make sure you build ck with the =-DCK_TESTS=1= option. Then
go to the build directory and type:
#+BEGIN_SRC sh
$ ./test-ck
#+END_SRC
*** test suite
#+BEGIN_SRC sh
$ ./test-ck -h
ck test suite
use without flags to run all tests
flags:
-u, --unit run only the unit tests
-r, --regression run only the regression tests
-c, --clear remove test files
use if the tests crush unexpectedly
-h, --help, * print this
#+END_SRC
* ck configuration
See the [[#manpage][manpage]] below.
* Usage
:PROPERTIES:
:CUSTOM_ID: usage
:END:
ck's goal is to assist with the configuration file management.
This section is an example usage.
** Initialize
#+BEGIN_SRC sh
cd ~
# make the directories for the configs
$ mkdir -p configs/vc configs/sec
# initialize new ck
$ ck init configs/vc configs/sec
#+END_SRC
** Add configs
#+BEGIN_SRC sh
# add emacs configs
## primary config
$ ck add emacs .emacs.d/orgconf.org -p
## secret config, with passwords and naughty words
$ ck add emacs .emacs.d/accounts.org -s
## and another one for emacs
$ ck add emacs .emacs.d/init.el
# add tmux config
$ ck add tmux .tmux.conf -p
# add X configs
$ ck add X .xinitrc
$ ck add X .Xresources
# add ssh configs (secret)
$ ck add ssh .ssh/config -s -p
$ ck add ssh .ssh/authorized_keys -s
# When running with sudo, we need to specify the ck config
# location.
$ sudo ck -c /home/ckuser add ssh /etc/ssh/sshd_config -s
#+END_SRC
** Using the ck actions
#+BEGIN_SRC sh
# list the configs in a treelike structure with basename only
$ ck list tree -b
# or with the full path & attributes
$ ck list tree -a
# list only the paths in python or lisp like lists
$ ck list paths -t lisp
$ ck list programs -t python -b -a
# list emacs configs
$ ck list -p emacs
# search the configs
$ ck search Hostname
$ ck search "search term with spaces"
# escape symbols
$ ck search \(
# edit the primary config of emacs wiht $EDITOR
$ ck edit emacs
# or with vi
$ ck e emacs --editor vi
# run the command cat to it
$ ck edit emacs --command cat
# or a complex editor call
$ ck edit emacs --command "emacsclient -a \"\" -t"
# edit a non-primary config of ssh
$ ck e emacs init.el
# edit a root config
$ ck e ssh -s
# delete a program with all the configs
$ ck delete emacs
# or a specific config
$ ck del emacs init.el
# restore all links (on a new instalation)
$ ck restore all
# restore a program's links
$ ck r -p emacs
# get help for an action
$ ck h add
$ ck --help e
#+END_SRC
* manpage
:PROPERTIES:
:CUSTOM_ID: manpage
:END:
#+BEGIN_SRC sh :results output html :exports results
groff ck.1 -mandoc -Thtml
#+END_SRC
|