Perhaps you could use the Situations app to execute a script containing those commands. The trigger could be plugging in a charge cable.