Fan Shim - Install Service Preempt bug

I have a fan shim. I built it OK, and mostly the software works OK. There is a bug though (IMO) in the script to install the service.

Source for install-service.sh is here

I was trying to enable the “Preempt” option
I tried install-service 50 5 10 True
& I got error in line 8 No command (or something similar)
I tried replacing the True, with Yes, or 1 and still got an error.
Because I got an error about missing command, I tried replacing True with ls on a whim.
It worked!

I think your line 8 is testing if there is a command with that name. What it should be doing is seeing if parameter 4 exists or not.

What do you think?

1 Like

|From what I understand it’s literally running the executable, and seeing if it returns either 0 (true) or 1 (false) as its exit status. But if anything is clear it’s that my bash skills and understanding are still a little rough around the edges.

Probably a better setup would be:

PREEMPT=$4

if [ ! "$PREEMPT" = "" ]; then
fi

Thanks for pointing this out. I was calling it with true as an argument. I should probably add a better argument parser in here outright since the current setup is a little ropey.

I’ve made some improvements, including a fixing a couple of bugbears I had with the installer (always trying to reinstall psutil, and running systemctl status with a confusing paged output).

Great stuff.
I see think you’ve updated some of the website instructions for this, but I think this page needs updating too
https://learn.pimoroni.com/tutorial/sandyj/getting-started-with-fan-shim

Cheers!