Since Power Scripts for JIRA 4.0 (formerly known as JJUPIN) you can configure scripts to run at the start of your plugin (startup script) or at its end (shutdown script). The scripts are run every time Since Power Scripts for JIRA gets started/stopped, either for administrative reasons (i.e. update of the plugin) or at JIRA's own startup/shutdown.
You can configure both of them from Administration → Start/Stop Scripts.