The basic idea is to set a special profilematic 'alarm rule' which executes its actions when an alarm with a certain title goes off. The rule gets deactivated when the next active alarm is not one with the set title or there are no alarms. The alarm title is set in the script as the passwd variable. By default, it's Test.
Now, how to make it run as a daemon on startup?