Skip to content

Commit 873c8c8

Browse files
committed
webui/kpm: update status on kpm refresh
1 parent dedec1a commit 873c8c8

3 files changed

Lines changed: 44 additions & 13 deletions

File tree

module/service.sh

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ KPNDIR="/data/adb/kp-next"
55
PATH="$MODDIR/bin:$PATH"
66
CONFIG="$KPNDIR/package_config"
77
key="$(cat $KPNDIR/key | base64 -d)"
8-
active="Status: active 😊"
9-
inactive="Status: inactive 😕"
10-
info="info: key incorrect, not set or kernel not patched yet ❌"
11-
string="description=$inactive | $info"
128

13-
sed -i "s/^description=.*/$string/" "$MODDIR/module.prop"
9+
sh "$MODDIR/status.sh" "$key"
1410

1511
if [ -z "$key" ] || [ -z "$(kpatch $key hello)" ]; then
1612
touch "$MODDIR/unresolved"
@@ -37,10 +33,3 @@ tail -n +2 "$CONFIG" | while IFS=, read -r pkg exclude allow uid; do
3733
[ -n "$UID" ] && kpatch "$key" exclude_set "$UID" 1
3834
fi
3935
done
40-
41-
if [ -n "$key" ] && kpatch "$key" hello >/dev/null 2>&1; then
42-
KPM_COUNT="$(kpatch "$key" kpm num 2>/dev/null || echo 0)"
43-
[ -z "$KPM_COUNT" ] && KPM_COUNT=0
44-
string="description=$active | kpmodule: $KPM_COUNT 💉"
45-
sed -i "s/^description=.*/$string/" "$MODDIR/module.prop"
46-
fi

module/status.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
MODDIR=${0%/*}
4+
KPNDIR="/data/adb/kp-next"
5+
PATH="$MODDIR/bin:$PATH"
6+
key="$1"
7+
8+
set_prop() {
9+
local prop="$1"
10+
local value="$2"
11+
local file="$3"
12+
13+
if ! grep -q "^$prop=" "$file"; then
14+
echo "$prop=$value" >> "$file"
15+
return
16+
fi
17+
sed "s/^$prop=.*/$prop=$value/" "$file" > "$file.tmp"
18+
cat "$file.tmp" > "$file"
19+
rm -f "$file.tmp"
20+
}
21+
22+
active="Status: active 😊"
23+
inactive="Status: inactive 😕"
24+
info="info: key incorrect, not set or kernel not patched yet ❌"
25+
string="$inactive | $info"
26+
27+
[ -z "$key" ] && key="$(cat $KPNDIR/key | base64 -d)"
28+
29+
until [ "$(getprop sys.boot_completed)" = "1" ]; do
30+
sleep 1
31+
done
32+
33+
if [ -n "$key" ] && kpatch "$key" hello >/dev/null 2>&1; then
34+
KPM_COUNT="$(kpatch "$key" kpm num 2>/dev/null || echo 0)"
35+
[ -z "$KPM_COUNT" ] && KPM_COUNT=0
36+
string="$active | kpmodule: $KPM_COUNT 💉"
37+
fi
38+
39+
set_prop "description" "$string" "$MODDIR/module.prop"

webui/page/kpm.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ async function getKpmList() {
4242
];
4343
}
4444

45-
const listResult = await exec(`kpatch ${superkey} kpm list`, { env: { PATH: `${modDir}/bin` } });
45+
const listResult = await exec(
46+
`kpatch ${superkey} kpm list && sh "${modDir}/status.sh" "${superkey}"`,
47+
{ env: { PATH: `${modDir}/bin:$PATH` } }
48+
);
4649
const modules = listResult.stdout.trim().split('\n').filter(line => line.trim());
4750

4851
const modulePromises = modules.map(async (moduleName) => {

0 commit comments

Comments
 (0)