minaki 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- minaki-0.1.0/LICENSE +202 -0
- minaki-0.1.0/NOTICE +4 -0
- minaki-0.1.0/PKG-INFO +243 -0
- minaki-0.1.0/README.md +212 -0
- minaki-0.1.0/pyproject.toml +49 -0
- minaki-0.1.0/setup.cfg +4 -0
- minaki-0.1.0/src/minaki/__init__.py +5 -0
- minaki-0.1.0/src/minaki/__main__.py +7 -0
- minaki-0.1.0/src/minaki/cli.py +111 -0
- minaki-0.1.0/src/minaki/plugin.py +105 -0
- minaki-0.1.0/src/minaki/plugins/__init__.py +8 -0
- minaki-0.1.0/src/minaki/plugins/grub/__init__.py +23 -0
- minaki-0.1.0/src/minaki/plugins/grub/checks.py +407 -0
- minaki-0.1.0/src/minaki/plugins/grub/cli.py +99 -0
- minaki-0.1.0/src/minaki/sdk.py +83 -0
- minaki-0.1.0/src/minaki.egg-info/PKG-INFO +243 -0
- minaki-0.1.0/src/minaki.egg-info/SOURCES.txt +20 -0
- minaki-0.1.0/src/minaki.egg-info/dependency_links.txt +1 -0
- minaki-0.1.0/src/minaki.egg-info/entry_points.txt +5 -0
- minaki-0.1.0/src/minaki.egg-info/top_level.txt +1 -0
- minaki-0.1.0/tests/test_core.py +268 -0
- minaki-0.1.0/tests/test_grub.py +406 -0
minaki-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
minaki-0.1.0/NOTICE
ADDED
minaki-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: minaki
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MinakiLabs command-line tools. v0.1 ships one plugin: a read-only GRUB config check (minaki grub check).
|
|
5
|
+
Author: MinakiLabs
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/MinakiLabs-Official/minaki
|
|
8
|
+
Project-URL: Issues, https://github.com/MinakiLabs-Official/minaki/issues
|
|
9
|
+
Keywords: minaki,grub,grub.cfg,bootloader,ubuntu,debian,update-grub,sysadmin
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: System Administrators
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Topic :: System :: Boot
|
|
25
|
+
Classifier: Topic :: System :: Systems Administration
|
|
26
|
+
Requires-Python: >=3.8
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
License-File: NOTICE
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# minaki
|
|
33
|
+
|
|
34
|
+
MinakiLabs command-line tools: one install, one command. Version 0.1 ships one
|
|
35
|
+
command, `minaki grub`, a read-only check that your GRUB config can boot.
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
pip install minaki # not on PyPI yet; for now: pip install . (from a clone)
|
|
39
|
+
minaki grub check
|
|
40
|
+
minaki grub pin
|
|
41
|
+
minaki --help
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Targets Ubuntu 24.04 first, and also Ubuntu 20.04, 22.04 and 26.04 and Debian 12.
|
|
45
|
+
It needs Python 3.8 or newer and only the standard library. It reads files and
|
|
46
|
+
runs `grub-script-check` (Debian/Ubuntu package `grub-common`). Run it as root,
|
|
47
|
+
since `grub.cfg` is often readable only by root.
|
|
48
|
+
|
|
49
|
+
## `minaki grub check`
|
|
50
|
+
|
|
51
|
+
`check` reads `/boot/grub/grub.cfg` once and runs every check on that one copy:
|
|
52
|
+
|
|
53
|
+
| Check | Fails when |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `exists` | the file is missing (and GRUB is installed), or cannot be read |
|
|
56
|
+
| `size` | the file is empty (`--min-size BYTES` raises the floor) |
|
|
57
|
+
| `no-nul-bytes` | the file has NUL bytes, as a file zero-filled after a crash does |
|
|
58
|
+
| `menuentry` | there is no `menuentry` line, so GRUB has nothing to boot |
|
|
59
|
+
| `sections` | a `### BEGIN /etc/grub.d/... ###` section written by grub-mkconfig never reaches its `### END` |
|
|
60
|
+
| `grub-script-check` | `grub-script-check` rejects the file (it gets the same bytes on stdin) |
|
|
61
|
+
|
|
62
|
+
The required checks are: the file exists, is not empty, has a `menuentry`, and
|
|
63
|
+
`grub-script-check` accepts it. Two more checks are added. `no-nul-bytes`
|
|
64
|
+
catches a file that was zero-filled after a crash. `sections` catches a file
|
|
65
|
+
that grub-mkconfig started but that ends before a section it opened is closed.
|
|
66
|
+
A hand-written config with no section markers skips that check.
|
|
67
|
+
|
|
68
|
+
Exit codes:
|
|
69
|
+
|
|
70
|
+
| Code | Meaning |
|
|
71
|
+
|---|---|
|
|
72
|
+
| 0 | every check passed |
|
|
73
|
+
| 1 | the file is bad (the output names what failed and where the last-good copy is) |
|
|
74
|
+
| 2 | could not check: bad usage, `grub-script-check` missing, permission denied, or not applicable |
|
|
75
|
+
|
|
76
|
+
On a system that boots with systemd-boot, or that has no GRUB at all, there is no
|
|
77
|
+
GRUB config to check. `check` then reports `NOT APPLICABLE`, exits 2, and does
|
|
78
|
+
not crash.
|
|
79
|
+
|
|
80
|
+
It also warns, without failing, when a `grub-mkconfig` or `update-grub` is
|
|
81
|
+
running at that moment (read from `/proc`) or when `grub.cfg.new` exists. Either
|
|
82
|
+
one means the file may be in the middle of being written.
|
|
83
|
+
|
|
84
|
+
A healthy Ubuntu 24.04 system (real output from a lab VM):
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
$ sudo minaki grub check
|
|
88
|
+
minaki 0.1.0 grub check: /boot/grub/grub.cfg
|
|
89
|
+
PASS exists 7918 bytes, modified 2026-11-30T05:22:46Z
|
|
90
|
+
PASS size 7918 bytes, not empty
|
|
91
|
+
PASS no-nul-bytes no NUL bytes
|
|
92
|
+
PASS menuentry 6 menuentry lines
|
|
93
|
+
PASS sections 12 generated sections, all closed
|
|
94
|
+
PASS grub-script-check /usr/bin/grub-script-check exit 0
|
|
95
|
+
Result: OK (exit 0)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
A syntax error:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
$ sudo minaki grub check
|
|
102
|
+
minaki 0.1.0 grub check: /boot/grub/grub.cfg
|
|
103
|
+
PASS exists 7917 bytes, modified 2026-11-30T05:23:16Z
|
|
104
|
+
PASS size 7917 bytes, not empty
|
|
105
|
+
PASS no-nul-bytes no NUL bytes
|
|
106
|
+
PASS menuentry 6 menuentry lines
|
|
107
|
+
PASS sections 12 generated sections, all closed
|
|
108
|
+
FAIL grub-script-check exit 1: Syntax error at line 54
|
|
109
|
+
Result: FAILED: grub-script-check (exit 1)
|
|
110
|
+
Last good copy: /var/lib/minaki/grub.cfg.last (pinned 2026-11-30T05:23:16Z, 7918 bytes, sha256 04b7dfc37181d1d8)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## `minaki grub pin`
|
|
114
|
+
|
|
115
|
+
`pin` runs `check`. If every check passes, it saves those exact bytes to
|
|
116
|
+
`/var/lib/minaki/grub.cfg.last`, with a small `grub.cfg.last.json` holding the
|
|
117
|
+
sha256, size and time. Because it writes the bytes it checked, a file that
|
|
118
|
+
changes in between can never be pinned unchecked. The directory is mode 0700
|
|
119
|
+
and the files are 0600, since a GRUB config can hold password hashes. If the
|
|
120
|
+
copy already matches, it reports `unchanged`. If `check` fails, nothing is
|
|
121
|
+
written and the old last-good copy stays. It refuses a state directory under
|
|
122
|
+
`/boot`.
|
|
123
|
+
|
|
124
|
+
A good time to pin is after a kernel update that booted fine.
|
|
125
|
+
|
|
126
|
+
If `check` fails, run `sudo update-grub` once, with no other package manager
|
|
127
|
+
or `update-grub` running, then run `minaki grub check` again. The last-good copy
|
|
128
|
+
is there to compare against, or to restore by hand as a last resort. Before you
|
|
129
|
+
restore it, read it: it may name kernels that have since been removed.
|
|
130
|
+
|
|
131
|
+
## `--json`
|
|
132
|
+
|
|
133
|
+
Both commands take `--json` and print one object:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"tool": "minaki", "plugin": "grub", "version": "0.1.0", "command": "check",
|
|
138
|
+
"status": "ok | failed | error | not_applicable", "exit_code": 0,
|
|
139
|
+
"config": {"path": "/boot/grub/grub.cfg", "size": 9123, "sha256": "...", "mtime": "..."},
|
|
140
|
+
"checks": [{"name": "exists", "status": "pass | fail | skip | error", "detail": "..."}],
|
|
141
|
+
"failed": [], "errors": [], "warnings": [], "writers": [],
|
|
142
|
+
"last_good": {"path": "/var/lib/minaki/grub.cfg.last", "sha256": "...", "pinned_at": "...", "matches_current": true}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
`pin` adds `pinned` (true/false) and `pin_detail`.
|
|
147
|
+
|
|
148
|
+
## What it never does
|
|
149
|
+
|
|
150
|
+
- It never writes to `/boot`. It never runs `update-grub`, `grub-mkconfig` or
|
|
151
|
+
`grub-install`, and never installs wrappers or hooks.
|
|
152
|
+
- It never touches the network: no telemetry, no update check, no account.
|
|
153
|
+
- It has no mode that runs two GRUB config writers at once. It reports on the
|
|
154
|
+
race below; it is not a way to reproduce it.
|
|
155
|
+
|
|
156
|
+
What it does read: `grub.cfg`, `/proc/*/cmdline` (to spot running writers), and
|
|
157
|
+
the usual ESP paths (to spot systemd-boot). What it runs: `grub-script-check`,
|
|
158
|
+
which reads the config on stdin.
|
|
159
|
+
|
|
160
|
+
## The concurrent update-grub race
|
|
161
|
+
|
|
162
|
+
Two GRUB config writers running at the same time (for example a package hook
|
|
163
|
+
and a snapshot daemon, or two services at boot, each running `update-grub` or
|
|
164
|
+
`grub-mkconfig`) can leave the boot config broken or missing. Public reports
|
|
165
|
+
of this class of problem:
|
|
166
|
+
|
|
167
|
+
- [grub-btrfs issue #288](https://github.com/Antynea/grub-btrfs/issues/288)
|
|
168
|
+
(2023): with `grub-btrfsd` running, a config rebuild during a pacman update
|
|
169
|
+
failed with "cannot open `/boot/grub/grub.cfg.new'". The reporter suspected
|
|
170
|
+
the daemon and the package hook were rebuilding at the same time.
|
|
171
|
+
- [TrueNAS middleware commit a50f509](https://github.com/truenas/middleware/commit/a50f509e0595b54010f88ee9016ecb75077a237b)
|
|
172
|
+
(May 2026): two boot-time listeners both ran `grub-mkconfig` at the same
|
|
173
|
+
time, "racing on `/boot/grub/grub.cfg.tmp(.new)`". The fix left one writer.
|
|
174
|
+
- [Launchpad #396381](https://bugs.launchpad.net/bugs/396381) (2009):
|
|
175
|
+
`update-grub` ran twice during one package operation; the report suggests a
|
|
176
|
+
dpkg trigger so it runs once.
|
|
177
|
+
|
|
178
|
+
`minaki grub` does not prevent this race. It tells you whether the file on disk
|
|
179
|
+
right now will boot, and keeps a copy of the last one that passed.
|
|
180
|
+
|
|
181
|
+
## Plugins
|
|
182
|
+
|
|
183
|
+
`minaki` parses only its own flags (`--help`, `--version`, `--plugins`) and
|
|
184
|
+
the command name. Everything after `minaki <command>` goes to that command
|
|
185
|
+
unchanged. Commands are plugins registered on the Python entry-point group
|
|
186
|
+
`minaki.plugins`. The core asks that group what is installed and never imports a
|
|
187
|
+
plugin by name.
|
|
188
|
+
|
|
189
|
+
Every plugin MinakiLabs writes ships inside the `minaki` package, so
|
|
190
|
+
`pip install minaki` gets all of them. Anyone can publish their own
|
|
191
|
+
`minaki-<something>` package that depends on `minaki` and registers on the same
|
|
192
|
+
group. There is no plugin store, downloader or auto-install.
|
|
193
|
+
|
|
194
|
+
Plugins build on a small SDK, `minaki.sdk`: an optional base class, the exit
|
|
195
|
+
codes, an argument parser named `minaki <name>`, and the standard `--json`. The
|
|
196
|
+
plugin API is versioned (now 1); a plugin that needs a newer API is refused with
|
|
197
|
+
a message to upgrade. `minaki --plugins [--json]` lists every registered
|
|
198
|
+
plugin, where it came from, and whether it loads.
|
|
199
|
+
|
|
200
|
+
- Guide and contract: [docs/PLUGINS.md](docs/PLUGINS.md)
|
|
201
|
+
- A complete plugin to copy: [examples/minaki-hello](examples/minaki-hello)
|
|
202
|
+
|
|
203
|
+
If two packages register the same name, the one inside `minaki` wins, and
|
|
204
|
+
`minaki --help` shows the clash. A plugin that fails to load is listed with its
|
|
205
|
+
error, and the other commands still work.
|
|
206
|
+
|
|
207
|
+
## Development
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
python3 -m unittest discover -s tests -v # standard library only
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
The real `grub-script-check` tests run when `grub-common` is installed. CI runs
|
|
214
|
+
the suite inside Ubuntu 20.04, 22.04, 24.04 and 26.04 and Debian 12 containers,
|
|
215
|
+
as root and as a normal user. `tests/lab/` holds the scripts we run on
|
|
216
|
+
throwaway VMs. Those scripts break `grub.cfg` on purpose, so never run them on a
|
|
217
|
+
machine you care about.
|
|
218
|
+
|
|
219
|
+
## Tested on
|
|
220
|
+
|
|
221
|
+
Every case on a throwaway VM, 2026-11-30, minaki 0.1.0 installed from the wheel.
|
|
222
|
+
The cases: the real generated config passes, both as text and as JSON. `pin`,
|
|
223
|
+
then `pin` again, which reports unchanged. `/boot` is unchanged by the tool, and
|
|
224
|
+
the pinned copy is mode 0600 and byte-identical. Then the harness breaks the
|
|
225
|
+
file: empty, cut in half, cut at a clean line, syntax error, zero-filled,
|
|
226
|
+
missing, `grub.cfg.new` present, and `grub-script-check` removed. A run as
|
|
227
|
+
`nobody`, one real `update-grub`, and a final restore that is byte-identical
|
|
228
|
+
close it out. On the systemd-boot VM, `check` and `pin` report not applicable.
|
|
229
|
+
|
|
230
|
+
| System | Kernel | Python | Lab cases |
|
|
231
|
+
|---|---|---|---|
|
|
232
|
+
| Ubuntu 20.04 | 5.4.0-216-generic | 3.8.10 | 30 of 30 passed |
|
|
233
|
+
| Ubuntu 22.04 | 5.15.0-203-generic | 3.10.12 | 30 of 30 passed |
|
|
234
|
+
| Ubuntu 24.04 | 6.8.0-147-generic | 3.12.3 | 30 of 30 passed |
|
|
235
|
+
| Ubuntu 26.04 | 7.0.0-43-generic | 3.14.4 | 30 of 30 passed |
|
|
236
|
+
| Debian 12 | 6.1.0-56-cloud-amd64 | 3.11.2 | 30 of 30 passed |
|
|
237
|
+
| Ubuntu 24.04, UEFI, systemd-boot, GRUB removed | 6.8.0-151-generic | 3.12.3 | 6 of 6 passed |
|
|
238
|
+
|
|
239
|
+
## License
|
|
240
|
+
|
|
241
|
+
Apache-2.0. Copyright 2026 MinakiLabs LLC. See [LICENSE](LICENSE).
|
|
242
|
+
|
|
243
|
+
This checks the bootloader file and does not remove packages; Minaki Tuner ([minakilabs.com/tuner](https://minakilabs.com/tuner)) is the product that does.
|
minaki-0.1.0/README.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# minaki
|
|
2
|
+
|
|
3
|
+
MinakiLabs command-line tools: one install, one command. Version 0.1 ships one
|
|
4
|
+
command, `minaki grub`, a read-only check that your GRUB config can boot.
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
pip install minaki # not on PyPI yet; for now: pip install . (from a clone)
|
|
8
|
+
minaki grub check
|
|
9
|
+
minaki grub pin
|
|
10
|
+
minaki --help
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Targets Ubuntu 24.04 first, and also Ubuntu 20.04, 22.04 and 26.04 and Debian 12.
|
|
14
|
+
It needs Python 3.8 or newer and only the standard library. It reads files and
|
|
15
|
+
runs `grub-script-check` (Debian/Ubuntu package `grub-common`). Run it as root,
|
|
16
|
+
since `grub.cfg` is often readable only by root.
|
|
17
|
+
|
|
18
|
+
## `minaki grub check`
|
|
19
|
+
|
|
20
|
+
`check` reads `/boot/grub/grub.cfg` once and runs every check on that one copy:
|
|
21
|
+
|
|
22
|
+
| Check | Fails when |
|
|
23
|
+
|---|---|
|
|
24
|
+
| `exists` | the file is missing (and GRUB is installed), or cannot be read |
|
|
25
|
+
| `size` | the file is empty (`--min-size BYTES` raises the floor) |
|
|
26
|
+
| `no-nul-bytes` | the file has NUL bytes, as a file zero-filled after a crash does |
|
|
27
|
+
| `menuentry` | there is no `menuentry` line, so GRUB has nothing to boot |
|
|
28
|
+
| `sections` | a `### BEGIN /etc/grub.d/... ###` section written by grub-mkconfig never reaches its `### END` |
|
|
29
|
+
| `grub-script-check` | `grub-script-check` rejects the file (it gets the same bytes on stdin) |
|
|
30
|
+
|
|
31
|
+
The required checks are: the file exists, is not empty, has a `menuentry`, and
|
|
32
|
+
`grub-script-check` accepts it. Two more checks are added. `no-nul-bytes`
|
|
33
|
+
catches a file that was zero-filled after a crash. `sections` catches a file
|
|
34
|
+
that grub-mkconfig started but that ends before a section it opened is closed.
|
|
35
|
+
A hand-written config with no section markers skips that check.
|
|
36
|
+
|
|
37
|
+
Exit codes:
|
|
38
|
+
|
|
39
|
+
| Code | Meaning |
|
|
40
|
+
|---|---|
|
|
41
|
+
| 0 | every check passed |
|
|
42
|
+
| 1 | the file is bad (the output names what failed and where the last-good copy is) |
|
|
43
|
+
| 2 | could not check: bad usage, `grub-script-check` missing, permission denied, or not applicable |
|
|
44
|
+
|
|
45
|
+
On a system that boots with systemd-boot, or that has no GRUB at all, there is no
|
|
46
|
+
GRUB config to check. `check` then reports `NOT APPLICABLE`, exits 2, and does
|
|
47
|
+
not crash.
|
|
48
|
+
|
|
49
|
+
It also warns, without failing, when a `grub-mkconfig` or `update-grub` is
|
|
50
|
+
running at that moment (read from `/proc`) or when `grub.cfg.new` exists. Either
|
|
51
|
+
one means the file may be in the middle of being written.
|
|
52
|
+
|
|
53
|
+
A healthy Ubuntu 24.04 system (real output from a lab VM):
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
$ sudo minaki grub check
|
|
57
|
+
minaki 0.1.0 grub check: /boot/grub/grub.cfg
|
|
58
|
+
PASS exists 7918 bytes, modified 2026-11-30T05:22:46Z
|
|
59
|
+
PASS size 7918 bytes, not empty
|
|
60
|
+
PASS no-nul-bytes no NUL bytes
|
|
61
|
+
PASS menuentry 6 menuentry lines
|
|
62
|
+
PASS sections 12 generated sections, all closed
|
|
63
|
+
PASS grub-script-check /usr/bin/grub-script-check exit 0
|
|
64
|
+
Result: OK (exit 0)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
A syntax error:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
$ sudo minaki grub check
|
|
71
|
+
minaki 0.1.0 grub check: /boot/grub/grub.cfg
|
|
72
|
+
PASS exists 7917 bytes, modified 2026-11-30T05:23:16Z
|
|
73
|
+
PASS size 7917 bytes, not empty
|
|
74
|
+
PASS no-nul-bytes no NUL bytes
|
|
75
|
+
PASS menuentry 6 menuentry lines
|
|
76
|
+
PASS sections 12 generated sections, all closed
|
|
77
|
+
FAIL grub-script-check exit 1: Syntax error at line 54
|
|
78
|
+
Result: FAILED: grub-script-check (exit 1)
|
|
79
|
+
Last good copy: /var/lib/minaki/grub.cfg.last (pinned 2026-11-30T05:23:16Z, 7918 bytes, sha256 04b7dfc37181d1d8)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## `minaki grub pin`
|
|
83
|
+
|
|
84
|
+
`pin` runs `check`. If every check passes, it saves those exact bytes to
|
|
85
|
+
`/var/lib/minaki/grub.cfg.last`, with a small `grub.cfg.last.json` holding the
|
|
86
|
+
sha256, size and time. Because it writes the bytes it checked, a file that
|
|
87
|
+
changes in between can never be pinned unchecked. The directory is mode 0700
|
|
88
|
+
and the files are 0600, since a GRUB config can hold password hashes. If the
|
|
89
|
+
copy already matches, it reports `unchanged`. If `check` fails, nothing is
|
|
90
|
+
written and the old last-good copy stays. It refuses a state directory under
|
|
91
|
+
`/boot`.
|
|
92
|
+
|
|
93
|
+
A good time to pin is after a kernel update that booted fine.
|
|
94
|
+
|
|
95
|
+
If `check` fails, run `sudo update-grub` once, with no other package manager
|
|
96
|
+
or `update-grub` running, then run `minaki grub check` again. The last-good copy
|
|
97
|
+
is there to compare against, or to restore by hand as a last resort. Before you
|
|
98
|
+
restore it, read it: it may name kernels that have since been removed.
|
|
99
|
+
|
|
100
|
+
## `--json`
|
|
101
|
+
|
|
102
|
+
Both commands take `--json` and print one object:
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"tool": "minaki", "plugin": "grub", "version": "0.1.0", "command": "check",
|
|
107
|
+
"status": "ok | failed | error | not_applicable", "exit_code": 0,
|
|
108
|
+
"config": {"path": "/boot/grub/grub.cfg", "size": 9123, "sha256": "...", "mtime": "..."},
|
|
109
|
+
"checks": [{"name": "exists", "status": "pass | fail | skip | error", "detail": "..."}],
|
|
110
|
+
"failed": [], "errors": [], "warnings": [], "writers": [],
|
|
111
|
+
"last_good": {"path": "/var/lib/minaki/grub.cfg.last", "sha256": "...", "pinned_at": "...", "matches_current": true}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`pin` adds `pinned` (true/false) and `pin_detail`.
|
|
116
|
+
|
|
117
|
+
## What it never does
|
|
118
|
+
|
|
119
|
+
- It never writes to `/boot`. It never runs `update-grub`, `grub-mkconfig` or
|
|
120
|
+
`grub-install`, and never installs wrappers or hooks.
|
|
121
|
+
- It never touches the network: no telemetry, no update check, no account.
|
|
122
|
+
- It has no mode that runs two GRUB config writers at once. It reports on the
|
|
123
|
+
race below; it is not a way to reproduce it.
|
|
124
|
+
|
|
125
|
+
What it does read: `grub.cfg`, `/proc/*/cmdline` (to spot running writers), and
|
|
126
|
+
the usual ESP paths (to spot systemd-boot). What it runs: `grub-script-check`,
|
|
127
|
+
which reads the config on stdin.
|
|
128
|
+
|
|
129
|
+
## The concurrent update-grub race
|
|
130
|
+
|
|
131
|
+
Two GRUB config writers running at the same time (for example a package hook
|
|
132
|
+
and a snapshot daemon, or two services at boot, each running `update-grub` or
|
|
133
|
+
`grub-mkconfig`) can leave the boot config broken or missing. Public reports
|
|
134
|
+
of this class of problem:
|
|
135
|
+
|
|
136
|
+
- [grub-btrfs issue #288](https://github.com/Antynea/grub-btrfs/issues/288)
|
|
137
|
+
(2023): with `grub-btrfsd` running, a config rebuild during a pacman update
|
|
138
|
+
failed with "cannot open `/boot/grub/grub.cfg.new'". The reporter suspected
|
|
139
|
+
the daemon and the package hook were rebuilding at the same time.
|
|
140
|
+
- [TrueNAS middleware commit a50f509](https://github.com/truenas/middleware/commit/a50f509e0595b54010f88ee9016ecb75077a237b)
|
|
141
|
+
(May 2026): two boot-time listeners both ran `grub-mkconfig` at the same
|
|
142
|
+
time, "racing on `/boot/grub/grub.cfg.tmp(.new)`". The fix left one writer.
|
|
143
|
+
- [Launchpad #396381](https://bugs.launchpad.net/bugs/396381) (2009):
|
|
144
|
+
`update-grub` ran twice during one package operation; the report suggests a
|
|
145
|
+
dpkg trigger so it runs once.
|
|
146
|
+
|
|
147
|
+
`minaki grub` does not prevent this race. It tells you whether the file on disk
|
|
148
|
+
right now will boot, and keeps a copy of the last one that passed.
|
|
149
|
+
|
|
150
|
+
## Plugins
|
|
151
|
+
|
|
152
|
+
`minaki` parses only its own flags (`--help`, `--version`, `--plugins`) and
|
|
153
|
+
the command name. Everything after `minaki <command>` goes to that command
|
|
154
|
+
unchanged. Commands are plugins registered on the Python entry-point group
|
|
155
|
+
`minaki.plugins`. The core asks that group what is installed and never imports a
|
|
156
|
+
plugin by name.
|
|
157
|
+
|
|
158
|
+
Every plugin MinakiLabs writes ships inside the `minaki` package, so
|
|
159
|
+
`pip install minaki` gets all of them. Anyone can publish their own
|
|
160
|
+
`minaki-<something>` package that depends on `minaki` and registers on the same
|
|
161
|
+
group. There is no plugin store, downloader or auto-install.
|
|
162
|
+
|
|
163
|
+
Plugins build on a small SDK, `minaki.sdk`: an optional base class, the exit
|
|
164
|
+
codes, an argument parser named `minaki <name>`, and the standard `--json`. The
|
|
165
|
+
plugin API is versioned (now 1); a plugin that needs a newer API is refused with
|
|
166
|
+
a message to upgrade. `minaki --plugins [--json]` lists every registered
|
|
167
|
+
plugin, where it came from, and whether it loads.
|
|
168
|
+
|
|
169
|
+
- Guide and contract: [docs/PLUGINS.md](docs/PLUGINS.md)
|
|
170
|
+
- A complete plugin to copy: [examples/minaki-hello](examples/minaki-hello)
|
|
171
|
+
|
|
172
|
+
If two packages register the same name, the one inside `minaki` wins, and
|
|
173
|
+
`minaki --help` shows the clash. A plugin that fails to load is listed with its
|
|
174
|
+
error, and the other commands still work.
|
|
175
|
+
|
|
176
|
+
## Development
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
python3 -m unittest discover -s tests -v # standard library only
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
The real `grub-script-check` tests run when `grub-common` is installed. CI runs
|
|
183
|
+
the suite inside Ubuntu 20.04, 22.04, 24.04 and 26.04 and Debian 12 containers,
|
|
184
|
+
as root and as a normal user. `tests/lab/` holds the scripts we run on
|
|
185
|
+
throwaway VMs. Those scripts break `grub.cfg` on purpose, so never run them on a
|
|
186
|
+
machine you care about.
|
|
187
|
+
|
|
188
|
+
## Tested on
|
|
189
|
+
|
|
190
|
+
Every case on a throwaway VM, 2026-11-30, minaki 0.1.0 installed from the wheel.
|
|
191
|
+
The cases: the real generated config passes, both as text and as JSON. `pin`,
|
|
192
|
+
then `pin` again, which reports unchanged. `/boot` is unchanged by the tool, and
|
|
193
|
+
the pinned copy is mode 0600 and byte-identical. Then the harness breaks the
|
|
194
|
+
file: empty, cut in half, cut at a clean line, syntax error, zero-filled,
|
|
195
|
+
missing, `grub.cfg.new` present, and `grub-script-check` removed. A run as
|
|
196
|
+
`nobody`, one real `update-grub`, and a final restore that is byte-identical
|
|
197
|
+
close it out. On the systemd-boot VM, `check` and `pin` report not applicable.
|
|
198
|
+
|
|
199
|
+
| System | Kernel | Python | Lab cases |
|
|
200
|
+
|---|---|---|---|
|
|
201
|
+
| Ubuntu 20.04 | 5.4.0-216-generic | 3.8.10 | 30 of 30 passed |
|
|
202
|
+
| Ubuntu 22.04 | 5.15.0-203-generic | 3.10.12 | 30 of 30 passed |
|
|
203
|
+
| Ubuntu 24.04 | 6.8.0-147-generic | 3.12.3 | 30 of 30 passed |
|
|
204
|
+
| Ubuntu 26.04 | 7.0.0-43-generic | 3.14.4 | 30 of 30 passed |
|
|
205
|
+
| Debian 12 | 6.1.0-56-cloud-amd64 | 3.11.2 | 30 of 30 passed |
|
|
206
|
+
| Ubuntu 24.04, UEFI, systemd-boot, GRUB removed | 6.8.0-151-generic | 3.12.3 | 6 of 6 passed |
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
Apache-2.0. Copyright 2026 MinakiLabs LLC. See [LICENSE](LICENSE).
|
|
211
|
+
|
|
212
|
+
This checks the bootloader file and does not remove packages; Minaki Tuner ([minakilabs.com/tuner](https://minakilabs.com/tuner)) is the product that does.
|