The “fi” is ok, that’s just the close for the “if”.
I believe it is there in the default rc.local, because sometimes “hostname -I” may fail because the network connection is not yet stable at the time the script runs and so the _IP would not exist and the printf would fail and the script would abort. Note that the “|| true” on the line before the if is there as an override in the case that “hostname -I” fails. If it were not there, the script would abort at that point.
The next line has the potential of failing for the same reason.
host=$(hostname -I | sed 's/ *$//g')
That’s why I added the “sleep 30” in my script. It gives the PI 30 seconds to get the network figured out before it tries to get the IP address and start the ospi.py program.
But, as I look at your script, I think your biggest issue is that you are missing the last line that actually starts the ospi.py program:
/usr/bin/python ospi.py $host$port
But, you want to make sure that is before the