Auto-start node script and safe-shutdown solution
# │forum
t
While waiting for further updates to the BMC firmware, I thought I'd share two scripts that help me keep the home network chugging along. The first is an init script that lives on the BMC at /etc/init.d/S99timstart.sh. It automatically starts a Raspberry Pi (in Node 4) which runs core network services and my Zigbee lights across the house. The script waits until the BMC's API is up and responding, then assigns the USB port to Node 1 briefly to clear some kind of error, reassigns USB to Node 4 and then powers up Node 4. (It took*** a lot*** of troubleshooting to discover that my Zigbee controller issues weren't a bad power cable or my Pi 🤨 ). This script is pretty barebones, but deliberately designed to only use tools already installed on the BMC. The second is a bash script that lives on the Raspberry Pi and allows for API-style shutdown requests via https by the BMC. I'm serving it via nginx's built in fastcgi feature. The BMC's init script makes a call as part of the shutdown routine. There's some pretty rudimentary anti-replay security in the script (mainly to stop me accidentally nuking the Pi with a bookmarked link) and I also restrict access to local IPs via nginx rules. This isn't intended to provide Fort Knox-levels of security, but I wanted a solution that didn't require me to keep SSH keys on the BMC and also minimised replay attack risks on the API. Sharing as these features are frustratingly absent from the default firmware, and I can't be the only person that has this use case. It'd be very simple to extend this skeleton to multiple host power on scenarios. I'm also keen for any feedback on the script, and any tips on if there's a programmatic way for the BMC to determine if the Pi is fully powered down. I suspect not, but would be keen to do something more precise than my "guessing 15 seconds is approximately right" approach. Keen for your thoughts and feedback
Script 2 - Raspberry Pi / nginx-fastcgi
and I shared the wrong BMC script, because of course I forgot that when setting the USB settings, Node 4 is actually "node = 3" 🤬 Seriously, Firefox dev tools picks up the following call when you set Node 4 in the "Connet node" pulldown http://[your IP here]/api/bmc?opt=set&type=usb&mode=0&node=3
19 Views