feat: add Apatch support

This commit is contained in:
7a72 2026-01-11 10:53:01 +00:00
commit 8734722cc3
No known key found for this signature in database
GPG key ID: 000AA5D07A725A52
3 changed files with 88 additions and 19 deletions

View file

@ -158,6 +158,18 @@ for d in ${module_dirs}; do
ui_print " ✓ Installed: $d/" ui_print " ✓ Installed: $d/"
done done
if [ "x$KSU" = "xtrue" ] && [ "x$APATCH" = "xtrue" ]; then
abort "err"
elif [ "x$KSU" = "xtrue" ]; then
AOK="KSU"
echo "AOK=KSU" > "$MODPATH/aok"
elif [ "x$APATCH" = "xtrue" ]; then
AOK="APATCH"
ui_print "AOK=APATCH" > "$MODPATH/aok"
else
abort "err"
fi
ui_print "- Initializing configuration" ui_print "- Initializing configuration"
# Create data directory # Create data directory
@ -179,6 +191,9 @@ if [ ! -f "$module_data_dir/mm.conf" ]; then
else else
ui_print " ℹ Existing configuration preserved" ui_print " ℹ Existing configuration preserved"
fi fi
if [ "$AOK" = "APATCH" ]; then
sed -i '/^[[:space:]]*umount=true[[:space:]]*$/d' "$module_data_dir/mm.conf"
fi
ui_print "- Managing metamodule status" ui_print "- Managing metamodule status"

View file

@ -10,12 +10,17 @@
let message = null; let message = null;
let partitionsInput = ""; let partitionsInput = "";
let hideUmount = false;
const CONFIG_FILE_PATH = "/data/adb/magic_mount/mm.conf"; const CONFIG_FILE_PATH = "/data/adb/magic_mount/mm.conf";
async function load() { async function load() {
loading = true; loading = true;
message = null; message = null;
try { try {
const aok = await utils.loadAOK();
hideUmount = aok === "APATCH";
config = await utils.loadConfig(); config = await utils.loadConfig();
partitionsInput = config.partitions.join(", "); partitionsInput = config.partitions.join(", ");
message = $L.config.loadSuccess; message = $L.config.loadSuccess;
@ -35,7 +40,8 @@
.split(",") .split(",")
.map((s) => s.trim()) .map((s) => s.trim())
.filter(Boolean); .filter(Boolean);
await utils.saveConfig(config);
await utils.saveConfig(config, { omitUmount: hideUmount });
message = $L.config.saveSuccess; message = $L.config.saveSuccess;
} catch (e) { } catch (e) {
console.error(e); console.error(e);
@ -70,21 +76,23 @@
</div> </div>
</div> </div>
<div class="field"> {#if !hideUmount}
<span class="field-label">{$L.config.umountLabel}</span> <div class="field">
<div class="loglevel-switch"> <span class="field-label">{$L.config.umountLabel}</span>
<button <div class="loglevel-switch">
type="button" <button
class="lv-btn {!config.umount ? 'active' : ''}" type="button"
on:click={() => (config.umount = false)}>{$L.config.umountOff}</button class="lv-btn {!config.umount ? 'active' : ''}"
> on:click={() => (config.umount = false)}>{$L.config.umountOff}</button
<button >
type="button" <button
class="lv-btn {config.umount ? 'active' : ''}" type="button"
on:click={() => (config.umount = true)}>{$L.config.umountOn}</button class="lv-btn {config.umount ? 'active' : ''}"
> on:click={() => (config.umount = true)}>{$L.config.umountOn}</button
>
</div>
</div> </div>
</div> {/if}
<div class="field"> <div class="field">
<label class="field-label" for="inp-moduledir">{$L.config.moduleDir}</label> <label class="field-label" for="inp-moduledir">{$L.config.moduleDir}</label>

View file

@ -12,6 +12,18 @@ export const DEFAULT_CONFIG = {
}; };
const CONFIG_PATH = "/data/adb/magic_mount/mm.conf"; const CONFIG_PATH = "/data/adb/magic_mount/mm.conf";
const AOK_PATH = "/data/adb/metamodule/aok";
function stripQuotes(s) {
const t = String(s).trim();
if (
(t.startsWith('"') && t.endsWith('"')) ||
(t.startsWith("'") && t.endsWith("'"))
) {
return t.slice(1, -1);
}
return t;
}
function isTrueValue(v) { function isTrueValue(v) {
const s = String(v).trim().toLowerCase(); const s = String(v).trim().toLowerCase();
@ -69,24 +81,31 @@ export async function loadConfig() {
return result; return result;
} }
export async function saveConfig(cfg) { export async function saveConfig(cfg, opts = {}) {
if (import.meta.env.DEV) { if (import.meta.env.DEV) {
return MockAPI.saveConfig(cfg); return MockAPI.saveConfig(cfg);
} }
const omitUmount = !!opts.omitUmount;
const lines = [ const lines = [
"# Magic Mount Configuration File", "# Magic Mount Configuration File",
"# Generated by Web UI", "# Generated by Web UI",
"", "",
]; ];
lines.push(`module_dir=${cfg.moduledir || DEFAULT_CONFIG.moduledir}`); lines.push(`module_dir=${cfg.moduledir || DEFAULT_CONFIG.moduledir}`);
if (cfg.tempdir) lines.push(`temp_dir=${cfg.tempdir}`); if (cfg.tempdir) lines.push(`temp_dir=${cfg.tempdir}`);
lines.push(`mount_source=${cfg.mountsource || DEFAULT_CONFIG.mountsource}`); lines.push(`mount_source=${cfg.mountsource || DEFAULT_CONFIG.mountsource}`);
if (cfg.logfile) lines.push(`log_file=${cfg.logfile}`); if (cfg.logfile) lines.push(`log_file=${cfg.logfile}`);
lines.push(`debug=${cfg.verbose ? "true" : "false"}`); lines.push(`debug=${cfg.verbose ? "true" : "false"}`);
lines.push(`umount=${cfg.umount ? "true" : "false"}`);
if (cfg.partitions.length > 0) if (!omitUmount) {
lines.push(`partitions=${cfg.partitions.join(",")}`); lines.push(`umount=${cfg.umount ? "true" : "false"}`);
}
const parts = Array.isArray(cfg.partitions) ? cfg.partitions : [];
if (parts.length > 0) lines.push(`partitions=${parts.join(",")}`);
const content = lines.join("\n").replace(/'/g, "'\\''"); const content = lines.join("\n").replace(/'/g, "'\\''");
const shell = `mkdir -p "$(dirname "${CONFIG_PATH}")" && printf '%s\n' '${content}' > "${CONFIG_PATH}"`; const shell = `mkdir -p "$(dirname "${CONFIG_PATH}")" && printf '%s\n' '${content}' > "${CONFIG_PATH}"`;
@ -157,3 +176,30 @@ export async function toggleModuleSkip(moduleDir, modName, shouldSkip) {
const { errno, stderr } = await exec(cmd); const { errno, stderr } = await exec(cmd);
if (errno !== 0) throw new Error(stderr); if (errno !== 0) throw new Error(stderr);
} }
export async function loadAOK() {
if (import.meta.env.DEV) {
return "KSU";
}
const { errno, stdout } = await exec(
`[ -f "${AOK_PATH}" ] && cat "${AOK_PATH}" || echo ""`,
);
if (errno !== 0) throw new Error("Read AOK failed");
const lines = (stdout || "").split("\n");
for (let line of lines) {
line = line.trim();
if (!line || line.startsWith("#")) continue;
const [key, ...vals] = line.split("=");
if (!key || !vals.length) continue;
if (key.trim() === "AOK") {
const value = stripQuotes(vals.join("=").trim());
return value;
}
}
return "";
}