Skip to content

Commit e8b2e6e

Browse files
tt
1 parent 4d8e46e commit e8b2e6e

File tree

1 file changed

+91
-1
lines changed

1 file changed

+91
-1
lines changed

README.md

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,91 @@
1-
# Checkin_base_OS
1+
# Checkin_base_OS
2+
Here’s a clean and well-structured **README** in Markdown for your Lua distro base detection script:
3+
4+
---
5+
6+
````markdown
7+
# 🖥️ Linux Distribution Base Detector (Lua)
8+
9+
A lightweight Lua function to detect the **base family** of your Linux distribution.
10+
Supports **Arch**, **Debian**, **Red Hat**, **Alpine**, **Gentoo**, and **Solus** based systems,
11+
and falls back to package manager detection if standard files are missing.
12+
13+
---
14+
15+
## 📋 Supported Bases
16+
17+
| Code | Base Name | Examples |
18+
|------|------------|---------------------------------------------------------------------------|
19+
| -1 | Unknown | Any system that does not match known signatures |
20+
| 0 | Arch | Arch Linux, Manjaro, EndeavourOS, Garuda |
21+
| 1 | Debian | Debian, Ubuntu, Linux Mint, Pop!\_OS, Elementary OS |
22+
| 2 | Red Hat | Red Hat Enterprise Linux (RHEL), Fedora, CentOS, Rocky Linux, AlmaLinux |
23+
| 3 | Alpine | Alpine Linux, PostmarketOS |
24+
| 4 | Gentoo | Gentoo Linux, Funtoo |
25+
| 5 | Solus | Solus OS |
26+
27+
---
28+
29+
## 📦 Features
30+
- **Fast**: Single function call to detect the base.
31+
- **Reliable**: Checks `/etc/os-release`, distro-specific release files, and package managers.
32+
- **Portable**: Works on most Unix-like environments where Lua is available.
33+
- **Extensible**: Easy to add more bases or custom checks.
34+
35+
---
36+
37+
## 🚀 Usage
38+
39+
```lua
40+
-- Paste the detect_base() function here or require it from another file.
41+
42+
local base = detect_base()
43+
44+
if base == 0 then
45+
print("Arch-based system detected!")
46+
elseif base == 1 then
47+
print("Debian-based system detected!")
48+
elseif base == 2 then
49+
print("Red Hat-based system detected!")
50+
elseif base == 3 then
51+
print("Alpine-based system detected!")
52+
elseif base == 4 then
53+
print("Gentoo-based system detected!")
54+
elseif base == 5 then
55+
print("Solus-based system detected!")
56+
else
57+
print("Unknown base")
58+
end
59+
````
60+
61+
---
62+
63+
## 🔍 How It Works
64+
65+
1. **Primary Check**
66+
Reads `/etc/os-release` and matches `ID_LIKE` or `ID` values.
67+
68+
2. **Fallback #1**
69+
Looks for distribution-specific release files:
70+
71+
* `/etc/arch-release`
72+
* `/etc/debian_version`
73+
* `/etc/redhat-release`
74+
* `/etc/alpine-release`
75+
* `/etc/gentoo-release`
76+
* `/etc/solus-release`
77+
78+
4. **Fallback #3**
79+
If none match, returns `-1` (Unknown).
80+
81+
---
82+
83+
## 🛠 Extending the Script
84+
85+
To add a new base:
86+
87+
1. Add `ID_LIKE` / `ID` matching in the `/etc/os-release` check.
88+
2. Add a release file check in the fallback section.
89+
3. Add the package manager command check as a last resort.
90+
91+

0 commit comments

Comments
 (0)