magisk-ghid/customize.sh

24 lines
1.1 KiB
Bash
Raw Normal View History

2025-02-16 13:34:52 -08:00
#!/system/bin/sh
2021-04-18 14:27:01 -07:00
$BOOTMODE || abort "! must be installed in the running system"
if [[ -e /proc/config.gz ]]; then
zcat /proc/config.gz | grep -Eq 'CONFIG_USB_(CONFIGFS_)?F_HID=[my]' || abort "! kernel does not have the required modules"
2021-04-18 14:27:01 -07:00
else
test -d /config/usb_gadget || abort "! kernel does not have the required modules"
mkdir /config/usb_gadget/g1 || abort "! kernel does not have the required modules"
mkdir /config/usb_gadget/g1/functions/hid.usb0 || abort "! kernel does not have the required modules"
2021-04-18 14:27:01 -07:00
fi
chmod 755 "$MODPATH/system/bin/ghid.sh"
2025-02-16 13:34:52 -08:00
chmod 755 "$MODPATH/service.sh"
sed -i -e "s@\[MODDIR\]@${MODPATH%_update/ghid}/ghid@g" "$MODPATH/system/bin/ghid.sh"
mkdir -p "$MODPATH/system/system_ext/etc/selinux/" "$MODPATH/system/etc"
{
grep -v /dev/hidg /system_ext/etc/selinux/system_ext_file_contexts
echo "/dev/hidg[0-9]+ u:object_r:null_device:s0"
} >"$MODPATH/system/system_ext/etc/selinux/system_ext_file_contexts"
{
grep -v /dev/hidg /system/etc/ueventd.rc
echo "/dev/hidg* 0666 root root"
} >"$MODPATH/system/etc/ueventd.rc"