magisk-ghid/customize.sh
Timmy Welch ff422dbc23 Fix basically everything
Add permission handling with ueventd
Add selinux context to system_ext/etc/selinux/system_ext_file_contexts
Remove init changes and boot image patching
Only initialize the keyboard once on boot with a non-standard name
  Standard names are f[1-9] we use fhid
2025-02-16 12:46:56 -08:00

23 lines
1.0 KiB
Bash

#!/bin/sh
$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"
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"
fi
chmod 755 "$MODPATH/system/bin/ghid.sh"
sed -i -e "s@\[MODDIR\]@${MODPATH%_update}@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"