femctl: overlay patches and idk
This commit is contained in:
62
femctl
62
femctl
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# femctl - a simplle sysv cli bootscript manager
|
# femctl - a simple sysv cli bootscript manager
|
||||||
# Copyright (C) 2025 Gabriel Di Martino
|
# Copyright (C) 2025 Gabriel Di Martino
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -21,8 +21,9 @@ import urllib.request
|
|||||||
import difflib
|
import difflib
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
|
import json
|
||||||
|
|
||||||
"""This is a small utility frontend for blfs bootscripts, the bootscripts remain to the BLFS Authors"""
|
"""Femctl: small utility frontend for BLFS bootscripts with remote overlays."""
|
||||||
|
|
||||||
BOOTSCRIPT_VER = "20250225"
|
BOOTSCRIPT_VER = "20250225"
|
||||||
BLFS_URL = f"https://anduin.linuxfromscratch.org/BLFS/blfs-bootscripts/blfs-bootscripts-{BOOTSCRIPT_VER}.tar.xz"
|
BLFS_URL = f"https://anduin.linuxfromscratch.org/BLFS/blfs-bootscripts/blfs-bootscripts-{BOOTSCRIPT_VER}.tar.xz"
|
||||||
@@ -30,6 +31,8 @@ CACHE_DIR = Path.home() / ".blfs_cache"
|
|||||||
TARBALL = CACHE_DIR / "blfs-bootscripts.tar.xz"
|
TARBALL = CACHE_DIR / "blfs-bootscripts.tar.xz"
|
||||||
SRC_DIR = CACHE_DIR / f"blfs-bootscripts-{BOOTSCRIPT_VER}"
|
SRC_DIR = CACHE_DIR / f"blfs-bootscripts-{BOOTSCRIPT_VER}"
|
||||||
|
|
||||||
|
OVERLAY_INDEX_URL = "https://rocketleaguechatp.duckdns.org/femctl/overlays.json"
|
||||||
|
|
||||||
def check_root():
|
def check_root():
|
||||||
if os.geteuid() != 0:
|
if os.geteuid() != 0:
|
||||||
print("This script must be run as root!")
|
print("This script must be run as root!")
|
||||||
@@ -82,7 +85,7 @@ def run_make(service, action, services):
|
|||||||
subprocess.run(["make", target], cwd=SRC_DIR, check=True)
|
subprocess.run(["make", target], cwd=SRC_DIR, check=True)
|
||||||
|
|
||||||
def print_version():
|
def print_version():
|
||||||
print("""Femctl version 1.0.1
|
print("""Femctl version 1.0.2
|
||||||
|
|
||||||
Made by gabry for FemboyOS
|
Made by gabry for FemboyOS
|
||||||
Credits to the BLFS authors for the BLFS bootscripts""")
|
Credits to the BLFS authors for the BLFS bootscripts""")
|
||||||
@@ -96,15 +99,60 @@ Commands:
|
|||||||
help Show this message
|
help Show this message
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
femctl enable sshd
|
femctl enable xdm
|
||||||
femctl disable sshd""")
|
femctl disable sshd""")
|
||||||
|
|
||||||
|
# ----------------- remote overlay logic -----------------
|
||||||
|
|
||||||
|
def fetch_overlay_index():
|
||||||
|
"""Fetch overlay index dynamically from server"""
|
||||||
|
with urllib.request.urlopen(OVERLAY_INDEX_URL) as resp:
|
||||||
|
return json.load(resp)
|
||||||
|
|
||||||
|
def apply_remote_overlay_live(service, patch_name):
|
||||||
|
"""Download and apply a patch directly to /etc/init.d/{service}"""
|
||||||
|
url = f"https://rocketleaguechatp.duckdns.org/femctl/patches/{service}/{patch_name}"
|
||||||
|
target_script_dir = Path("/etc/init.d")
|
||||||
|
target_script_path = target_script_dir / service
|
||||||
|
|
||||||
|
if not target_script_path.exists():
|
||||||
|
print(f"Service script {target_script_path} not found!")
|
||||||
|
return
|
||||||
|
|
||||||
|
print(f"Downloading and applying overlay {patch_name} to {target_script_path}...")
|
||||||
|
|
||||||
|
# download patch in memory
|
||||||
|
with urllib.request.urlopen(url) as resp:
|
||||||
|
patch_data = resp.read().decode("utf-8")
|
||||||
|
|
||||||
|
# apply patch to /etc/init.d
|
||||||
|
subprocess.run(
|
||||||
|
["patch", str(target_script_path)],
|
||||||
|
input=patch_data,
|
||||||
|
text=True,
|
||||||
|
check=True
|
||||||
|
)
|
||||||
|
|
||||||
|
def apply_service_overlays(service):
|
||||||
|
"""Fetch overlay index and apply all patches for a service"""
|
||||||
|
index = fetch_overlay_index()
|
||||||
|
|
||||||
|
# optionally warn if BLFS versions mismatch
|
||||||
|
if index.get("blfs_version") != BOOTSCRIPT_VER:
|
||||||
|
print("Warning: overlay BLFS version mismatch")
|
||||||
|
|
||||||
|
patches = index.get("overlays", {}).get(service, [])
|
||||||
|
for patch_name in patches:
|
||||||
|
apply_remote_overlay(service, patch_name)
|
||||||
|
|
||||||
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
check_root()
|
check_root()
|
||||||
if len(sys.argv) < 2 or sys.argv[1] in ("help", "-h", "--help"):
|
if len(sys.argv) < 2 or sys.argv[1] in ("help", "-h", "--help"):
|
||||||
print_help()
|
print_help()
|
||||||
return
|
return
|
||||||
elif len(sys.argv) <2 or sys.argv[1] in ("version"):
|
elif len(sys.argv) < 2 or sys.argv[1] in ("version"):
|
||||||
print_version()
|
print_version()
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -118,6 +166,9 @@ def main():
|
|||||||
return
|
return
|
||||||
service = sys.argv[2]
|
service = sys.argv[2]
|
||||||
|
|
||||||
|
# apply remote overlays first
|
||||||
|
apply_service_overlays(service)
|
||||||
|
|
||||||
if command == "enable":
|
if command == "enable":
|
||||||
run_make(service, "install", services)
|
run_make(service, "install", services)
|
||||||
elif command == "disable":
|
elif command == "disable":
|
||||||
@@ -127,4 +178,3 @@ def main():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|||||||
11
overlays.json
Normal file
11
overlays.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"blfs_version": "20250225",
|
||||||
|
"overlays": {
|
||||||
|
"sddm": {
|
||||||
|
"target": "xdm",
|
||||||
|
"patches": [
|
||||||
|
"0001-plymouth-quit.patch"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
patches/xdm/0001-plymouth-quit.patch
Normal file
11
patches/xdm/0001-plymouth-quit.patch
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
--- /tmp/xdm.orig 2025-12-21 11:19:37.763436780 +0100
|
||||||
|
+++ /etc/init.d/xdm 2025-12-21 11:19:49.884939311 +0100
|
||||||
|
@@ -16,6 +16,8 @@
|
||||||
|
|
||||||
|
source /etc/sysconfig/xdm
|
||||||
|
|
||||||
|
+plymouth quit || true
|
||||||
|
+
|
||||||
|
if [ -z "${DISPLAY_MANAGER}" ]; then
|
||||||
|
echo Please set DISPLAY_MANAGER in /etc/sysconfig/xdm \
|
||||||
|
before running /etc/rc.d/init.d/xdm
|
||||||
Reference in New Issue
Block a user