I want to write a script and put it in
/etc/rc.local so that
if lan is connected then
rfkill block all
nmcli con up id 'Network id' --nowait
How should I write the
if part and how should I check for "lan is connected" ?
If the LAN is up, then you'll have a default route; otherwise, you shouldn't. So rather than check for particular interfaces, I'd just check for a default route.
I don't have a Linux box to test on, so can't tell what ip(8) gives you, but route(8) has rather poor error exit codes when there's no routes, so instead I'd just rely upon the exit code of grep -- if there's an interface: line, then you have a LAN.