-
Notifications
You must be signed in to change notification settings - Fork 6
/
inotify.sh
executable file
·38 lines (32 loc) · 971 Bytes
/
inotify.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
MODULEID="moduleid"
MODULEDIR="/data/adb/modules/$MODULEID"
if command -v magisk >/dev/null 2>&1; then
if magisk -v | grep -q lite; then
MODULEDIR="/data/adb/lite_modules/$MODULEID"
fi
fi
export PATH="$MODULEDIR/bin:$PATH"
while [ $(getprop sys.boot_completed) != 1 ]; do
sleep 2
done
[ ! -f "$MODULEDIR/disable" ] && "$MODULEDIR/container_ctrl.sh" start
(
inotifyd - "$MODULEDIR" 2>/dev/null | while read -r events _ file; do
if [ "$file" = "disable" ]; then
case "$events" in
d)
"$MODULEDIR/container_ctrl.sh" start
;;
n)
"$MODULEDIR/container_ctrl.sh" stop
;;
*)
:
;;
esac
fi
done
) &
pid=$!
sed -i "6c description=[ PID=$pid ] This container can be quickly controlled by enabling/disabling" "$MODULEDIR/module.prop"