As I posted otherwhere, you need no script for this. As USB are powered up by PI when system starts (all systems) and powered down at shutdown, with the PI always under power. So you just need to connect the relay at an USB power line, by cable or breakout adapter, as you want.