Hi there,
recently, I added a cooling fan to my RPi4. In order to control it, I tested a Python script by FranzAT, however this didn't work well, since some Python lib is not supported anymore plus the lib which replaces it, I think it's gpiozero, cannot do pwm at frequencies higher than 10kHz and the fan makes weird noise at those low frequencies.
Anyway, since Python is not needed to do this job, I kind of ported the script in order to make it run by the Bourne Shell which is available on LibreElec by default. The script handles enabling the dtoverlay, too.
If you're interested, you can get anything needed from my Github repo (except for two resistors, one NPN transistor and a fan of course ;D)
If you want/need some changes to be added, you can make a pull request.